# 🎨 ToolBox 全站設計風格規範 (Style Guide)

本規範定義了 ToolBox 所有頁面（包括入口首頁及所有獨立工具頁）的統一視覺語言、色彩系統、UI 元件標準與開發規範。

---

## 1. 核心設計原則

1. **簡約現代（Modern & Clean）**：以板岩灰（Slate）與科技藍（Blue）為主調，保持清爽、俐落、高可讀性的工程師美學。
2. **純靜態・零相依（Zero Dependency）**：全站使用原生 HTML5、CSS3 與 Vanilla JavaScript，無須打包編譯工具（Zero Build）。
3. **原生雙主題（Dark / Light Mode First）**：所有元件均預設完美適配深淺色模式，切換無延遲、無白光閃爍（FOUC），狀態跨頁同步。
4. **極致響應式（Responsive RWD）**：小至手機（360px），大至寬螢幕桌面，元件與排版皆自動適配。

---

## 2. 色彩系統 (Design Tokens)

所有頁面統一透過 `common.css` 定義之 CSS 變數取用色彩，**嚴禁在各工具頁面中直接寫死 Hex 色碼**。

| CSS 變數 | 淺色模式 (Light) | 深色模式 (Dark) | 用途說明 |
| :--- | :--- | :--- | :--- |
| `--accent` | `#2563eb` (Blue 600) | `#3b82f6` (Blue 500) | 主要互動色、按鈕、聚焦環 |
| `--accent-hover` | `#1d4ed8` (Blue 700) | `#60a5fa` (Blue 400) | 懸停狀態重點色 |
| `--bg` | `#f8fafc` (Slate 50) | `#0f172a` (Slate 900) | 全站頁面背景底色 |
| `--card-bg` | `#ffffff` | `#1e293b` (Slate 800) | 主要卡片、容器背景 |
| `--card-secondary-bg`| `#f8fafc` | `#0f172a` | 次級容器、時段列背景 |
| `--text-main` | `#0f172a` (Slate 900) | `#f1f5f9` (Slate 100) | 主要標題、內文文字 |
| `--text-muted` | `#64748b` (Slate 500) | `#94a3b8` (Slate 400) | 次要輔助文字、單位標註 |
| `--border` | `#e2e8f0` (Slate 200) | `#334155` (Slate 700) | 邊框線、分割線 |
| `--border-hover` | `#cbd5e1` (Slate 300) | `#475569` (Slate 600) | 懸停時的邊框線 |
| `--success` | `#10b981` | `#34d399` | 正常、儲存成功、達成目標 |
| `--warning` | `#f59e0b` | `#fbbf24` | 警示、注意提示 |
| `--danger` | `#ef4444` | `#f87171` | 刪除、警告、錯誤 |
| `--summary-bg` | `#0f172a` | `#0b1120` | 重點結算面板背景深色盒 |

---

## 3. 字體排版與間距規範

### 字體棧 (Font Stack)
```css
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
```

### 字級與字重階層
- **頁面主標題 (H1)**：`1.75rem` (28px)，字重 `800`，行高 `1.2`
- **卡片/區塊標題 (H2)**：`1.15rem` ~ `1.25rem` (20px)，字重 `700`
- **欄位標籤 (Label)**：`0.85rem` (13.6px)，字重 `600`
- **內文正文 (Body)**：`0.95rem` (15.2px)，行高 `1.6`
- **輔助註解/標籤 (Muted / Tag)**：`0.75rem` ~ `0.85rem` (12px ~ 13.6px)

### 圓角規範 (Border Radius)
- 按鈕、輸入框 (`--radius-sm`)：`6px`
- 內部設備框、次要卡片 (`--radius-md`)：`10px`
- 主要大卡片、外層容器 (`--radius-lg`)：`14px`

---

## 4. UI 元件標準使用指南

### ① 頂部導覽列 (Navbar)
每個工具頁頂部必須具備 `.tb-nav` 容器，包含：
1. 左側：返回工具箱首頁按鈕（`.tb-nav-back`）
2. 右側：主題切換按鈕（`.theme-toggle-btn`）以及 GitHub 連結按鈕

```html
<nav class="tb-nav">
    <div class="tb-nav-left">
        <a href="index.html" class="tb-nav-back">
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
                <line x1="19" y1="12" x2="5" y2="12"></line>
                <polyline points="12 19 5 12 12 5"></polyline>
            </svg>
            回到工具箱
        </a>
    </div>
    <div class="tb-nav-actions">
        <!-- 主題切換按鈕 -->
        <button class="icon-btn theme-toggle-btn" title="切換深淺色模式">
            <svg class="theme-icon-sun" style="display:none;" viewBox="0 0 24 24" stroke-width="2"><circle cx="12" cy="12" r="5"></circle>...</svg>
            <svg class="theme-icon-moon" viewBox="0 0 24 24" stroke-width="2"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
        </button>
        <!-- GitHub 按鈕 -->
        <a href="https://github.com/ZhongKuo0228/ToolBox" target="_blank" class="icon-btn icon-btn-github" title="GitHub">...</a>
    </div>
</nav>
```

### ② 內容容器 (Container)
- 工具頁面推薦寬度：`.tb-container`（最大寬度 `860px`）。
- 入口網站推薦寬度：`.tb-container.tb-container-wide`（最大寬度 `1080px`）。

### ③ 卡片與表單 (Card & Form Controls)
- 統一使用 `.card` 包裹獨立邏輯區塊。
- 表單群組使用 `.field`，內含 `<label>` 與 `<input>` 或 `<select>`。
- 聚焦時統一具備 `box-shadow: 0 0 0 3px var(--accent-soft)` 柔光環。

### ④ 按鈕系統 (Buttons)
- **主要行動按鈕**：`.btn.btn-primary`
- **次要行動按鈕**：`.btn.btn-secondary` 或小按鈕 `.btn-sm`
- **虛線新增按鈕**：`.btn-dashed`（常用於「＋ 新增設備」、「＋ 新增欄位」）

### ⑤ 統計面板 (Summary Box)
數據運算結果統一放置於 `.summary-box`，內含 `.summary-grid` 與 `.summary-item`。

---

## 5. 新工具標準樣板 (Boilerplate)

未來建立任何新工具時，請直接複製以下骨架，即可保證與全站風格 100% 一致：

```html
<!DOCTYPE html>
<html lang="zh-TW">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>工具名稱 - ToolBox</title>
    <link rel="stylesheet" href="common.css">
    <!-- 防閃爍主題腳本 -->
    <script src="common.js"></script>
</head>

<body>
    <div class="tb-container">
        <!-- 頂部導覽列 -->
        <nav class="tb-nav">
            <div class="tb-nav-left">
                <a href="index.html" class="tb-nav-back">
                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                        <line x1="19" y1="12" x2="5" y2="12"></line>
                        <polyline points="12 19 5 12 12 5"></polyline>
                    </svg>
                    回到工具箱
                </a>
            </div>
            <div class="tb-nav-actions">
                <button class="icon-btn theme-toggle-btn" title="切換深淺色模式" aria-label="切換主題">
                    <svg class="theme-icon-sun" style="display: none;" viewBox="0 0 24 24" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <circle cx="12" cy="12" r="5"></circle>
                        <line x1="12" y1="1" x2="12" y2="3"></line>
                        <line x1="12" y1="21" x2="12" y2="23"></line>
                        <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
                        <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
                        <line x1="1" y1="12" x2="3" y2="12"></line>
                        <line x1="21" y1="12" x2="23" y2="12"></line>
                        <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
                        <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
                    </svg>
                    <svg class="theme-icon-moon" viewBox="0 0 24 24" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
                    </svg>
                </button>
                <a href="https://github.com/ZhongKuo0228/ToolBox" target="_blank" rel="noopener noreferrer" class="icon-btn icon-btn-github" title="GitHub 原始碼">
                    <svg viewBox="0 0 24 24">
                        <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
                    </svg>
                </a>
            </div>
        </nav>

        <!-- 工具標題區 -->
        <header class="tb-header">
            <h1>工具名稱</h1>
            <p>工具簡述說明</p>
        </header>

        <!-- 主體內容卡片 -->
        <main>
            <div class="card">
                <!-- 工具介面放置於此 -->
            </div>
        </main>

        <!-- 全站統一頁尾 -->
        <footer class="tb-footer">
            <p>ToolBox &copy; 2026 &middot; 實用純靜態 Web 工具箱</p>
            <div class="tb-footer-links">
                <a href="index.html">工具箱首頁</a>
                <span>&middot;</span>
                <a href="https://github.com/ZhongKuo0228/ToolBox" target="_blank">GitHub</a>
            </div>
        </footer>
    </div>
</body>

</html>
```
