/* ═══════════════════════════════════════════════════════════
   tools.akuku.monster — Design System v2.0
   支援新舊 class 名稱，向後相容現有工具頁
   ───────────────────────────────────────────────────────────
   引入方式（每個工具頁）：
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
   <link rel="stylesheet" href="/assets/css/style.css">
   ══════════════════════════════════════════════════════════= */

/* ──────────────────────────────────────────
   1. DESIGN TOKENS
   新名稱（推薦用於新工具頁）
   舊名稱（向後相容現有工具頁）
   ────────────────────────────────────────── */
:root {
  /* 背景層次 */
  --bg:          #0b1120;
  --surface:     #101926;
  --raised:      #16253a;

  /* 向後相容舊名稱 */
  --bg-base:     #0b1120;
  --bg-surface:  #101926;
  --bg-raised:   #16253a;

  /* 邊框 */
  --border:        #1c2d46;
  --border-focus:  #60a5fa;

  /* 主色 — Blue（呼應 Mascot 藍髮） */
  --accent:        #60a5fa;
  --accent-mid:    #3b82f6;
  --accent-hover:  #93c5fd;
  --accent-dim:    rgba(96,165,250,.12);
  --accent-line:   rgba(96,165,250,.24);

  /* 語義色 */
  --success: #22c55e;
  --warning: #f59e0b;
  --error:   #ef4444;

  /* 文字層次 — 新名稱 */
  --text:  #eef4ff;
  --sub:   #7b9ac4;
  --muted: #3d5070;
  --code:  #93c5fd;

  /* 文字層次 — 舊名稱（向後相容） */
  --text-primary:   #eef4ff;
  --text-secondary: #7b9ac4;
  --text-muted:     #3d5070;
  --text-code:      #93c5fd;

  /* 字型 */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* 間距（4px 基準） */
  --sp-1:  4px;   --sp-2:  8px;   --sp-3:  12px;  --sp-4:  16px;
  --sp-5:  20px;  --sp-6:  24px;  --sp-8:  32px;  --sp-10: 40px;
  --sp-12: 48px;  --sp-16: 64px;

  /* 圓角 */
  --r-sm: 6px;    --r-md: 10px;   --r-lg: 14px;   --r-xl: 20px;

  /* 陰影 */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.6);
  --shadow-md:   0 4px 16px rgba(0,0,0,.5), 0 2px 4px rgba(0,0,0,.3);
  --shadow-lg:   0 20px 40px rgba(0,0,0,.6);
  --shadow-glow: 0 0 20px rgba(59,130,246,.2);
}

/* ──────────────────────────────────────────
   2. RESET & BASE
   ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ──────────────────────────────────────────
   3. LAYOUT
   ────────────────────────────────────────── */
.container {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

main { flex: 1; padding: var(--sp-10) 0 var(--sp-12); }

/* ──────────────────────────────────────────
   4. NAVBAR（工具頁）
   ────────────────────────────────────────── */
.navbar {
  height: 52px;
  background: rgba(16,25,38,.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-inner {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--sp-6);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: .04em;
}
.navbar-logo span { color: var(--accent); }

/* 返回按鈕 — 新名稱 .back-btn 與舊名稱 .navbar-back 都支援 */
.back-btn,
.navbar-back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sub);
  text-decoration: none;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  margin-left: calc(var(--sp-3) * -1);
  transition: color .15s, background .15s;
}
.back-btn:hover,
.navbar-back:hover { color: var(--text); background: var(--raised); }
.back-btn svg,
.navbar-back svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ──────────────────────────────────────────
   5. TOOL HEADER
   ────────────────────────────────────────── */
.tool-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-5);
  margin-bottom: var(--sp-10);
  /* 舊版 tool-header 有 border-bottom，這裡移除以對齊新設計 */
  padding: var(--sp-8) 0 0;
  border-bottom: none;
}
.tool-header-icon {
  font-size: 2.25rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 3px;
}
.tool-title,
.tool-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.2;
  margin-bottom: var(--sp-2);
}
.tool-subtitle,
.tool-header p {
  font-size: 0.875rem;
  color: var(--sub);
  line-height: 1.65;
}

/* 舊版 tool-header-tag（tag 風格標籤） */
.tool-header-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-hover);
  background: var(--accent-dim);
  border: 1px solid rgba(96,165,250,.25);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  margin-bottom: var(--sp-3);
}

/* ──────────────────────────────────────────
   6. TOOL PANEL
   ────────────────────────────────────────── */
.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

/* ──────────────────────────────────────────
   7. FORM ELEMENTS
   ────────────────────────────────────────── */
/* .field 舊版用 margin-bottom，新版用 gap in flex parent */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.tool-panel .field { margin-bottom: 0; } /* panel 內用 gap，不加 margin */

/* 標籤 — 新名稱 .label 與舊名稱 .field-label 都支援 */
.label,
.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sub);
  margin-bottom: var(--sp-2);
  letter-spacing: .01em;
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 0.9375rem;
  color: var(--text);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder,
.textarea::placeholder { color: var(--muted); }
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input:disabled,
.textarea:disabled { opacity: .5; cursor: not-allowed; }

.textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* 程式碼 / 數值 mono 變體 */
.input-mono  { font-family: var(--font-mono); font-size: .875rem; color: var(--code); }
.textarea-mono { font-family: var(--font-mono); font-size: .875rem; color: var(--code); }

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237b9ac4' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  color-scheme: dark;
}

/* ──────────────────────────────────────────
   8. OUTPUT BOX
   ────────────────────────────────────────── */
.output-box {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  min-height: 80px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--code);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}
.output-box-tall { min-height: 120px; }

.output-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: .875rem;
  color: var(--code);
  line-height: 1.6;
  word-break: break-all;
}
.output-text.empty,
.output-box.empty {
  border-style: dashed;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: .875rem;
  font-style: normal;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ──────────────────────────────────────────
   9. COPY BUTTON
   ────────────────────────────────────────── */
.copy-btn {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  flex-shrink: 0;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--sub);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all .15s;
}
.copy-btn:hover { border-color: var(--accent-line); color: var(--accent); }
.copy-btn.copied { border-color: var(--success); color: var(--success); }

/* ──────────────────────────────────────────
   10. SWAP / CONVERTER DIVIDER
   新名稱 .swap-divider 與舊名稱 .converter-divider 都支援
   ────────────────────────────────────────── */
.swap-divider,
.converter-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--sp-2) 0;
  gap: var(--sp-3);
}
.converter-divider-line { flex: 1; height: 1px; background: var(--border); }

.swap-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.swap-btn:hover { border-color: var(--accent-line); color: var(--accent); transform: rotate(180deg); }

/* ──────────────────────────────────────────
   11. BUTTONS
   ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 42px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s ease;
  text-decoration: none;
  outline: none;
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-dim); border-color: var(--border-focus); }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary  { background: var(--accent-mid); color: #fff; border-color: var(--accent-mid); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--raised); border-color: var(--accent-line); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--sub); }
.btn-ghost:hover { background: var(--raised); color: var(--text); }

.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:hover { opacity: .85; }

.btn-icon { width: 42px; padding: 0; }
.btn-sm   { height: 34px; padding: 0 var(--sp-4); font-size: .875rem; }
.btn-lg   { height: 50px; padding: 0 var(--sp-8); font-size: 1rem; }
.btn-full { width: 100%; }

/* ──────────────────────────────────────────
   12. LAYOUT HELPERS
   ────────────────────────────────────────── */
.row  { display: flex; gap: var(--sp-4); align-items: flex-start; }
.col  { flex: 1; min-width: 0; }
.btn-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-5); }

/* ──────────────────────────────────────────
   13. TABS
   ────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  background: var(--raised); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 3px;
  margin-bottom: var(--sp-5); width: fit-content;
}
.tab-btn {
  padding: 6px 14px; border-radius: 7px;
  border: none; background: transparent;
  color: var(--sub); font-size: .875rem; font-weight: 500;
  font-family: var(--font-sans); cursor: pointer; transition: all .15s;
}
.tab-btn.active { background: var(--accent-mid); color: #fff; }
.tab-btn:not(.active):hover { background: var(--bg); color: var(--text); }

/* ──────────────────────────────────────────
   14. BADGES
   ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 3px var(--sp-3); border-radius: var(--r-sm);
  font-size: .75rem; font-weight: 500; border: 1px solid transparent;
}
.badge-blue,
.badge-info  { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-line); }
.badge-green { background: rgba(34,197,94,.1); color: #4ade80; border-color: rgba(34,197,94,.22); }
.badge-yellow { background: rgba(245,158,11,.1); color: #fbbf24; border-color: rgba(245,158,11,.22); }
.badge-red   { background: rgba(239,68,68,.1); color: #f87171; border-color: rgba(239,68,68,.22); }

/* ──────────────────────────────────────────
   15. TIPS（折疊說明）
   ────────────────────────────────────────── */
.tips-toggle {
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: .875rem; color: var(--muted);
  font-family: var(--font-sans); padding: var(--sp-2) 0;
  transition: color .15s;
}
.tips-toggle:hover { color: var(--sub); }

.tips-body {
  display: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-6);
  margin-top: var(--sp-2); font-size: .875rem;
  color: var(--sub); line-height: 1.75;
}
.tips-body.open { display: block; }
.tips-body p + p { margin-top: var(--sp-3); }

/* ──────────────────────────────────────────
   16. HERO（首頁用）
   ────────────────────────────────────────── */
.hero { text-align: center; padding: var(--sp-16) 0 var(--sp-12); }
.hero-badge {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--accent-dim); border: 1px solid var(--accent-line);
  border-radius: 999px; padding: var(--sp-1) var(--sp-4);
  font-size: .8125rem; color: var(--accent-hover); margin-bottom: var(--sp-6);
}
.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700; line-height: 1.2;
  letter-spacing: -.03em; margin-bottom: var(--sp-4);
}
.hero p { font-size: 1.0625rem; color: var(--sub); max-width: 480px; margin: 0 auto; }

/* ──────────────────────────────────────────
   17. FOOTER
   ────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-6);
  text-align: center;
  font-family: var(--font-mono);
  font-size: .6875rem;
  color: var(--muted);
}
footer .container { display: flex; justify-content: space-between; align-items: center; }
footer a { color: var(--muted); }
footer a:hover { color: var(--sub); }

/* ──────────────────────────────────────────
   18. DONATE FAB（由 common.js 注入）
   ────────────────────────────────────────── */
.donate-fab {
  position: fixed; bottom: var(--sp-6); left: var(--sp-6);
  z-index: 200; display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 16px;
  font-size: .875rem; font-weight: 500; color: var(--sub);
  font-family: var(--font-sans); text-decoration: none;
  box-shadow: var(--shadow-md); transition: all .2s; white-space: nowrap;
}
.donate-fab:hover {
  border-color: #f59e0b; color: #fbbf24;
  background: rgba(245,158,11,.08);
  box-shadow: 0 0 16px rgba(245,158,11,.2), var(--shadow-md);
}
.donate-fab-icon { font-size: 1rem; line-height: 1; }
.donate-fab-text { font-size: .8125rem; }

/* ──────────────────────────────────────────
   19. UTILITIES
   ────────────────────────────────────────── */
.text-code    { font-family: var(--font-mono); font-size: .875rem; color: var(--code); }
.text-muted   { color: var(--muted); font-size: .8125rem; }
.text-sub     { color: var(--sub); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.mono         { font-family: var(--font-mono); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ──────────────────────────────────────────
   20. RESPONSIVE
   ────────────────────────────────────────── */
@media (max-width: 640px) {
  .tool-header   { flex-direction: column; gap: var(--sp-3); }
  .tool-title, .tool-header h1 { font-size: 1.5rem; }
  .tool-panel    { padding: var(--sp-5); border-radius: var(--r-lg); }
  .container     { padding: 0 var(--sp-4); }
  main           { padding: var(--sp-8) 0 var(--sp-10); }
  .row           { flex-direction: column; }
  .donate-fab    { bottom: var(--sp-4); left: var(--sp-4); padding: 9px 13px; }
  .donate-fab-text { display: none; }
}
