/* 基礎：色彩變數（含深色模式）、字體、按鈕、輸入框、標籤 */
:root {
  --accent: #F28C28;
  --accent-strong: #E07A12;
  --accent-ink: #A9560A;
  --accent-soft: #FDEEDD;
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --surface-2: #F0EEE9;
  --surface-3: #E8E5DE;
  --line: #E3DFD7;
  --line-strong: #CFCAC0;
  --ink: #1D1B18;
  --ink-2: #57524A;
  --muted: #8A847A;
  --ok: #1F9D6B;
  --ok-soft: #E2F5EC;
  --danger: #D2413A;
  --danger-soft: #FCE8E6;
  --warn: #C98A06;
  --info: #2F6FDB;
  --shadow-1: 0 1px 2px rgba(30, 24, 16, .06), 0 1px 1px rgba(30, 24, 16, .04);
  --shadow-2: 0 8px 28px rgba(30, 24, 16, .14), 0 2px 6px rgba(30, 24, 16, .06);
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --tap: 44px;
  --side-w: 264px;
  --top-h: 60px;
  --tab-h: 60px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* 平台色 */
  --pf-ig: #E1306C; --pf-reels: #A23CC4; --pf-threads: #1F1F1F; --pf-fb: #1877F2; --pf-tiktok: #00A99F; --pf-yt: #E62117; --pf-line: #06A84F; --pf-web: #6B7280;
  /* 狀態色 */
  --st-idea: #8B6FD6; --st-draft: #8A847A; --st-review: #D99A0B; --st-changes: #D2413A; --st-approved: #1F9D6B; --st-scheduled: #2F6FDB; --st-published: #0E8C8C; --st-archived: #A8A29A;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent-ink: #F6A456;
    --accent-soft: #3A2814;
    --bg: #121110;
    --surface: #1B1A18;
    --surface-2: #24221F;
    --surface-3: #2E2B27;
    --line: #34312C;
    --line-strong: #4A463F;
    --ink: #F3F0EB;
    --ink-2: #CBC5BB;
    --muted: #918A7F;
    --ok-soft: #12382A;
    --danger-soft: #3D1A18;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);
    --pf-threads: #E8E8E8;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow-x: hidden; min-height: 100vh; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: .01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 16px; }
.pad-x { padding: 0 16px; }
.pad-lg { padding: 20px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.ic { display: inline-flex; flex: none; line-height: 0; }

/* 按鈕 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s; user-select: none; -webkit-user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  width: var(--tap); height: var(--tap); border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 36px; height: 36px; }
.link { background: none; border: 0; padding: 4px 2px; color: var(--accent-ink); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
.link:disabled { color: var(--muted); cursor: default; text-decoration: none; }

/* 輸入 */
.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; /* iOS 16px 以上不會自動放大 */
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.input[readonly] { background: var(--surface-2); }
textarea.input { resize: vertical; line-height: 1.6; min-height: 88px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A847A' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input.sm { min-height: 38px; padding: 6px 10px; font-size: 14px; border-radius: 8px; width: auto; }
select.input.sm { padding-right: 30px; background-position: right 10px center; }
.input.xs { min-height: 28px; width: 56px; padding: 2px 6px; font-size: 14px; display: inline-block; }
.input.lg { min-height: 52px; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* 標籤 */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; border: 0;
}
.chip.small { height: 20px; font-size: 11.5px; padding: 0 6px; }
.chip.pf { color: #fff; background: var(--pf-web); }
.chip.pf[data-pf=ig] { background: linear-gradient(135deg, #F58529, #DD2A7B 55%, #8134AF); }
.chip.pf[data-pf=reels] { background: var(--pf-reels); }
.chip.pf[data-pf=threads] { background: var(--pf-threads); color: var(--bg); }
.chip.pf[data-pf=fb] { background: var(--pf-fb); }
.chip.pf[data-pf=tiktok] { background: #111; box-shadow: inset 2px 0 0 #25F4EE, inset -2px 0 0 #FE2C55; }
.chip.pf[data-pf=yt] { background: var(--pf-yt); }
.chip.pf[data-pf=line] { background: var(--pf-line); }
.chip.st { background: color-mix(in srgb, var(--c, var(--muted)) 14%, transparent); color: var(--c, var(--ink-2)); }
[data-st=idea] { --c: var(--st-idea); } [data-st=draft] { --c: var(--st-draft); } [data-st=review] { --c: var(--st-review); }
[data-st=changes] { --c: var(--st-changes); } [data-st=approved] { --c: var(--st-approved); } [data-st=scheduled] { --c: var(--st-scheduled); }
[data-st=published] { --c: var(--st-published); } [data-st=archived] { --c: var(--st-archived); }
.st-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.chip.via[data-via=claude] { background: #F4E7DC; color: #9A4B1D; }
.chip.via[data-via=chatgpt] { background: #DFF3EC; color: #0F7055; }
.chip.via[data-via=gemini] { background: #E3EAFB; color: #3155B8; }
.chip.via[data-via=mcp] { background: var(--surface-3); }
@media (prefers-color-scheme: dark) {
  .chip.via[data-via=claude] { background: #3B2618; color: #F0A878; }
  .chip.via[data-via=chatgpt] { background: #133328; color: #6FD6B0; }
  .chip.via[data-via=gemini] { background: #1C2647; color: #9DB6F5; }
}
.chip.cur { background: var(--accent-soft); color: var(--accent-ink); }
.chip.final { background: #FFF3C4; color: #8A6400; }
@media (prefers-color-scheme: dark) { .chip.final { background: #3A3110; color: #F0CF5A; } }
.chip.kind { background: transparent; padding: 0; color: var(--muted); }
.chip.toggle { cursor: pointer; min-height: 32px; height: auto; padding: 4px 10px; border: 1px dashed var(--line-strong); background: transparent; }
.chip.toggle.on { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid transparent; }
.chip.toggle.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); } }
.chip.nomusic { background: var(--ok-soft); color: var(--ok); margin-left: 6px; }
.badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface);
}
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; letter-spacing: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--muted); }
.spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress.sm { height: 6px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.notice { background: var(--accent-soft); color: var(--ink); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { color: var(--accent); }
.empty p { color: var(--muted); max-width: 420px; }
.meter { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
