/* 工作室待辦。色彩、圓角、字型借用 HarperHarbor Console 的 tokens（console/src/theme/tokens.ts 的 --hh-* 對應值），
   版面照 UI/UX 原型（tasks/2026-11-19-studio-todo-dashboard/ui.md）。整頁捲動，不做固定高度的內層捲動框。 */
:root {
  --bg: #F2EFE8; --bg2: #F7F5F0; --surface: #FFFFFF; --surface2: #FAF8F4;
  --fg: #0B1220; --fg2: #4B5568; --fg3: #7C8698;
  --accent-text: #8A5A00; --accent-bg: #F2B84B; --accent-ink: #1A1204; --accent-soft: rgba(242, 184, 75, .22);
  --ok: #1F9D6A; --warn: #B4540A; --danger: #D6263A;
  --line: rgba(11, 18, 32, .12); --line-card: rgba(11, 18, 32, .16); --line-ctl: rgba(11, 18, 32, .38);
  --shadow: 0 12px 40px rgba(11, 18, 32, .18); --scrim: rgba(7, 11, 20, .5);
  --r-chip: 6px; --r-btn: 10px; --r-card: 16px; --r-panel: 24px;
  --sans: "Instrument Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1); --dur-fast: 160ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070B14; --bg2: #0B1220; --surface: #17243C; --surface2: #1E2E4A;
    --fg: #E8EDF5; --fg2: #A9B4C6; --fg3: #8592A8;
    --accent-text: #F2B84B; --accent-soft: rgba(242, 184, 75, .16);
    --ok: #2FBF82; --warn: #FF9F43; --danger: #FF5C6C;
    --line: rgba(232, 237, 245, .14); --line-card: rgba(232, 237, 245, .20); --line-ctl: rgba(232, 237, 245, .40);
    --shadow: 0 12px 40px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070B14; --bg2: #0B1220; --surface: #17243C; --surface2: #1E2E4A;
  --fg: #E8EDF5; --fg2: #A9B4C6; --fg3: #8592A8;
  --accent-text: #F2B84B; --accent-soft: rgba(242, 184, 75, .16);
  --ok: #2FBF82; --warn: #FF9F43; --danger: #FF5C6C;
  --line: rgba(232, 237, 245, .14); --line-card: rgba(232, 237, 245, .20); --line-ctl: rgba(232, 237, 245, .40);
  --shadow: 0 12px 40px rgba(0, 0, 0, .5); color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 14px; line-height: 1.5; display: flex; flex-direction: column; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
svg { display: block; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 頁首 */
.site-head { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 24px; padding-top: max(10px, env(safe-area-inset-top)); min-height: 60px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5); border-bottom: 1px solid var(--line); }
.brand { display: grid; line-height: 1.2; margin-right: auto; }
.brand small { font-size: 11px; letter-spacing: .08em; color: var(--fg3); text-transform: uppercase; font-weight: 600; }
.brand strong { font-size: 17px; font-weight: 700; }
.sync { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 12px; border: 1px solid var(--line-card); border-radius: 999px; font-size: 12.5px; color: var(--fg2); background: var(--surface); white-space: nowrap; }
.sync .t-short { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync.late .dot { background: var(--warn); } .sync.down .dot { background: var(--danger); }
.whowrap { position: relative; }
.who { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px 0 4px; border-radius: 999px; border: 1px solid var(--line-card); background: var(--surface); font-size: 13px; font-weight: 600; }
.av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 140px; padding: 6px; border: 1px solid var(--line-card); border-radius: var(--r-btn); background: var(--surface); box-shadow: var(--shadow); z-index: 40; }
.menu button { width: 100%; min-height: 36px; text-align: left; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; font-weight: 500; }
.menu button:hover { background: var(--surface2); }

.main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 20px 24px 40px; display: grid; gap: 14px; align-content: start; flex: 1; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r-btn); border: 1px solid var(--line-card); background: var(--surface); font-size: 13px; color: var(--fg); }
.banner svg { margin-top: 2px; }
.banner.late { border-color: var(--warn); } .banner.late svg { color: var(--warn); }
.banner.down { border-color: var(--danger); } .banner.down svg { color: var(--danger); }

.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface2); }
.tab { min-height: 48px; display: flex; align-items: baseline; justify-content: center; gap: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--fg2); font-size: 15px; font-weight: 600; padding: 6px; }
.tab .n { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--fg3); }
.tab:hover { background: var(--surface); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px var(--line-card), inset 0 -2px 0 var(--accent-bg); }
.tab[aria-selected="true"] .n { color: var(--accent-text); }

.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface2); }
.seg button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--fg2); font-size: 13.5px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px var(--line-card); }
.search { flex: 1; min-width: 180px; max-width: 360px; position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--fg3); }
.input { width: 100%; min-height: 38px; padding: 7px 12px; border: 1px solid var(--line-ctl); border-radius: var(--r-btn); background: var(--surface); font-size: 14px; }
.search .input { padding-left: 36px; }
.input:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 84px; resize: vertical; line-height: 1.55; }
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 16px; border: 1px solid var(--line-ctl); border-radius: var(--r-btn); background: var(--surface); font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--fg2); }
.btn.lg { min-height: 44px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.bar .grow { margin-left: auto; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg3); margin: -4px 0 14px; }

.pri { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-height: 30px; min-width: 48px; padding: 0 8px; border-radius: var(--r-chip); border: 1.5px solid var(--line-ctl); background: transparent; font-family: var(--mono); font-size: 13px; font-weight: 500; }
button.pri:hover { background: var(--surface2); }
.pri.p0 { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 700; }
.pri.p1 { border-color: var(--fg); font-weight: 700; }
.pri.p3 { border-color: var(--line-card); color: var(--fg2); }

.stage { display: grid; gap: 4px; }
.stage b { font-weight: 600; font-size: 13.5px; }
.steps { display: flex; gap: 3px; } .steps i { width: 14px; height: 4px; border-radius: 2px; background: var(--line-card); } .steps i.on { background: var(--fg2); }
.stage.done .steps i.on { background: var(--ok); }

.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 8px; border-radius: var(--r-chip); background: var(--surface2); border: 1px solid var(--line); font-size: 12.5px; color: var(--fg2); white-space: nowrap; }
.pend { border-style: dashed; border-color: var(--line-ctl); }
.diffchip { display: inline-flex; align-items: flex-start; gap: 6px; max-width: 100%; padding: 3px 8px; border-radius: var(--r-chip); border: 1.5px solid var(--line-ctl); background: var(--surface); text-align: left; font-size: 12.5px; line-height: 1.4; }
.diffchip span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.diffchip svg { margin-top: 2px; }
.addbtn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px dashed var(--line-card); border-radius: var(--r-chip); background: transparent; color: var(--fg3); opacity: .55; }
tr:hover .addbtn, .addbtn:focus-visible { opacity: 1; color: var(--fg); border-color: var(--line-ctl); }
@media (hover: none) { .addbtn { opacity: 1; } }
.mono { font-family: var(--mono); font-size: 12px; color: var(--fg3); }
.muted { color: var(--fg3); }

/* 桌機表格：只在寬度不夠時橫向捲動；直向跟整頁一起捲 */
.tablewrap { overflow-x: auto; border: 1px solid var(--line-card); border-radius: var(--r-card); background: var(--surface); }
/* 固定欄寬：切分頁時欄位不跳；「提出者」放得下「作戰指揮部」一行 */
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1144px; table-layout: fixed; }
col.w-pri { width: 88px; } col.w-item { width: 256px; } col.w-scope { width: 92px; } col.w-stage { width: 116px; } col.w-owner { width: 100px; }
col.w-wait { width: 160px; } col.w-upd { width: 100px; } col.w-prop { width: 108px; } col.w-diff { width: 172px; }
td { overflow-wrap: anywhere; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--fg3); padding: 10px 12px; background: var(--surface2); border-bottom: 1px solid var(--line-card); white-space: nowrap; }
th .ed { display: inline-flex; align-items: center; gap: 5px; color: var(--fg2); }
td { padding: 11px 12px; vertical-align: top; border-bottom: 1px solid var(--line); font-size: 13.5px; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--surface2); }
td.c-pri, th.c-pri { position: sticky; left: 0; z-index: 1; background: var(--surface); }
td.c-item, th.c-item { position: sticky; left: 88px; z-index: 1; min-width: 250px; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
th.c-pri, th.c-item { background: var(--surface2); z-index: 3; }
tr.row:hover td.c-pri, tr.row:hover td.c-item { background: var(--surface2); }
.t-title { font-weight: 600; font-size: 14.5px; line-height: 1.4; display: block; }
.t-sub { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
tr.gh td { background: var(--bg2); padding: 8px 12px; font-size: 12.5px; color: var(--fg2); font-weight: 600; border-bottom: 1px solid var(--line-card); }
tr.gh .g { position: sticky; left: 12px; display: inline-flex; gap: 10px; align-items: center; }
.g .pri, .gh-m .pri { min-height: 24px; min-width: 40px; font-size: 12px; }
tr.flash td { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }
.c-wait { min-width: 130px; } .c-upd { white-space: nowrap; } .c-diff { min-width: 170px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--fg3); padding: 2px 2px 0; }
.pager div { display: flex; gap: 8px; }

/* 手機卡片 */
.cards { display: none; gap: 10px; }
.card { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line-card); border-radius: var(--r-card); background: var(--surface); text-align: left; width: 100%; cursor: pointer; }
.card .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .top .sp { margin-left: auto; }
.card .ttl { font-weight: 600; font-size: 15px; line-height: 1.45; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--fg2); }
.card .meta .stg { display: inline-flex; align-items: center; gap: 8px; }
.card .wait { font-size: 13px; color: var(--fg2); }
.card.flash { animation: flashc 1.6s var(--ease); }
@keyframes flashc { 0%, 40% { background: var(--accent-soft); } 100% { background: var(--surface); } }
.gh-m { display: none; font-size: 12.5px; font-weight: 600; color: var(--fg2); align-items: center; gap: 8px; padding: 8px 2px 0; }

.panel { border: 1px solid var(--line-card); border-radius: var(--r-card); background: var(--surface); padding: 28px 24px; display: grid; gap: 10px; justify-items: center; text-align: center; }
.panel h2 { margin: 0; font-size: 17px; } .panel p { margin: 0; color: var(--fg2); max-width: 46ch; }
.panel .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ghost { height: 56px; border-radius: var(--r-btn); background: linear-gradient(90deg, var(--surface2), var(--surface), var(--surface2)); background-size: 200% 100%; animation: sh 1.4s linear infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.sk { display: grid; gap: 8px; }

/* 登入與無權限 */
.center { flex: 1; display: grid; place-items: center; padding: 32px 24px; }
.gate { width: min(440px, 100%); border: 1px solid var(--line-card); border-radius: var(--r-panel); background: var(--surface); padding: 32px 28px; display: grid; gap: 14px; justify-items: start; }
.gate h2 { margin: 0; font-size: 22px; line-height: 1.3; }
.gate p { margin: 0; color: var(--fg2); }
.gate .btn { width: 100%; }
.gate .err { color: var(--danger); font-size: 13px; }
.idbox { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface2); }
.idbox b { font-family: var(--mono); font-weight: 500; }

/* 詳情：桌機右側欄、手機底部 sheet */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; justify-content: flex-end; }
.drawer { width: min(460px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--line-card); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.dh { display: flex; align-items: flex-start; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dh h2 { margin: 0; font-size: 17px; line-height: 1.4; flex: 1; }
.ib { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--r-btn); background: transparent; color: var(--fg2); margin: -6px -8px -6px 0; }
.ib:hover { background: var(--surface2); }
.db { flex: 1; overflow: auto; padding: 16px 18px 20px; display: grid; gap: 22px; align-content: start; }
.sec { display: grid; gap: 12px; }
.sec > h3 { margin: 0; font-size: 12px; letter-spacing: .06em; color: var(--fg3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
dl.kv { display: grid; grid-template-columns: 96px 1fr; gap: 9px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--fg3); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.f { display: grid; gap: 6px; } .f label, .f .l { font-size: 13px; font-weight: 600; }
.f .h { font-size: 12.5px; color: var(--fg3); display: flex; justify-content: space-between; gap: 8px; }
.f label.h { color: var(--fg2); font-weight: 500; }
.prisel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.prisel button { min-height: 44px; border: 1.5px solid var(--line-ctl); border-radius: var(--r-btn); background: var(--surface); font-family: var(--mono); font-size: 15px; display: grid; place-items: center; line-height: 1.2; padding: 4px; }
.prisel button small { font-family: var(--sans); font-size: 11.5px; color: var(--fg3); }
.prisel button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 700; }
.prisel button[aria-pressed="true"] small { color: inherit; opacity: .8; }
.segfull { display: flex; width: 100%; } .segfull button { flex: 1; }
.df { padding: 14px 18px; padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg); }
.df .btn.primary { min-width: 110px; }
.status { font-size: 13px; display: flex; gap: 8px; align-items: flex-start; color: var(--fg2); }
.status.ok { color: var(--ok); }
.linkbtn { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; min-height: 30px; padding: 0 6px; margin: -6px 0; white-space: nowrap; }
.err-box { padding: 10px 12px; border: 1px solid var(--danger); border-radius: var(--r-btn); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.err-box svg { color: var(--danger); margin-top: 2px; }
.err-box .btn { margin-top: 8px; min-height: 32px; }
.toast { width: max-content; position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 10px 12px 10px 16px; border-radius: 999px; background: var(--fg); color: var(--bg); font-size: 13.5px; box-shadow: var(--shadow); }
.toast button { white-space: nowrap; flex: none; border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; min-height: 30px; padding: 0 6px; }
.bottombar { display: none; }

@media (prefers-reduced-motion: reduce) {
  tr.flash td, .card.flash { animation: none; background: var(--accent-soft); }
  .ghost { animation: none; }
}

/* 手機：卡片列表、底部 sheet、底部動作列（內容底部留出動作列的高度，最後一張卡片不會被蓋住） */
@media (max-width: 760px) {
  .site-head { padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); min-height: 52px; gap: 8px; }
  .sync .t { display: none; } .sync .t-short { display: inline; } .sync { padding: 0 10px; }
  .who .nm { display: none; } .who { padding: 0 4px; }
  .main { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); gap: 12px; }
  .tablewrap, .pager .pg-desktop { display: none; }
  .cards { display: grid; }
  .gh-m { display: flex; }
  .tab { flex-direction: column; align-items: center; gap: 0; min-height: 52px; font-size: 14px; }
  .bar .search { order: 3; flex-basis: 100%; max-width: none; }
  .bar .newd { display: none; }
  .legend { display: none; }
  .bottombar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); border-top: 1px solid var(--line); z-index: 15; }
  .bottombar .btn { width: 100%; }
  .overlay { align-items: flex-end; }
  .drawer { width: 100%; height: calc(100% - 28px); border-left: 0; border-top: 1px solid var(--line-card); border-radius: 24px 24px 0 0; }
  .gate { padding: 24px 20px; }
  .df .btn { flex: 1; min-height: 44px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  /* 底部 sheet 開著時 toast 移到上方，不蓋住表單 */
  .modal-open .toast { bottom: auto; top: calc(6px + env(safe-area-inset-top)); }
}
