/* 設計需求精靈。臉：被選中的項目像用螢光筆劃過重點。手機 390 優先，主要動作在底部拇指範圍。 */
:root {
  color-scheme: light dark;
  --paper: oklch(98.2% .003 262);
  --paper-2: oklch(100% 0 0);
  --paper-3: oklch(94.5% .006 262);
  --ink: oklch(24% .02 262);
  --ink-2: oklch(36% .018 262);
  --muted: oklch(47% .015 262);
  --rule: oklch(91% .006 262);
  --border: oklch(86% .008 262);
  --control: oklch(62% .012 262);
  --accent: oklch(45% .13 262);
  --on-accent: oklch(99% 0 0);
  --focus: oklch(52% .16 262);
  --marker: oklch(91% .13 100);      /* 螢光筆：選取的底 */
  --marker-edge: oklch(72% .14 95);
  --bad: oklch(50% .17 27);
  --ok: oklch(48% .12 150);

  --r-card: 8px; --r-ctl: 6px; --r-tag: 4px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur-press: 120ms; --dur-short: 180ms;
  --bar-h: 76px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-synthesis: none;
  line-break: strict;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: oklch(17% .008 262);
    --paper-2: oklch(21% .009 262);
    --paper-3: oklch(24% .01 262);
    --ink: oklch(95% .005 262);
    --ink-2: oklch(85% .008 262);
    --muted: oklch(72% .01 262);
    --rule: oklch(28% .01 262);
    --border: oklch(33% .012 262);
    --control: oklch(52% .012 262);
    --accent: oklch(80% .1 262);
    --on-accent: oklch(18% .02 262);
    --focus: oklch(80% .12 262);
    --marker: oklch(38% .08 100);
    --marker-edge: oklch(62% .12 98);
    --bad: oklch(72% .15 27);
    --ok: oklch(76% .13 150);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body {
  background: var(--paper); color: var(--ink);
  font-size: 16px; line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1 { font-size: 22px; line-height: 1.35; font-weight: 700; margin: 0; text-wrap: balance; }
.nw { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline-offset: 0; }

/* ── 登入、完成 ── */
.gate {
  min-height: 100dvh; display: grid; align-content: center; gap: 16px;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 28em; margin: 0 auto;
}
.lede { margin: 0; color: var(--ink-2); }
.folder { margin: 0; font: 14px/1.4 ui-monospace, "SF Mono", "Noto Sans Mono CJK TC", monospace; color: var(--muted); overflow-wrap: anywhere; white-space: normal; }

/* ── 頂列 ── */
.top {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--paper);
}
.count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--rule); }
.progress i { display: block; height: 100%; width: 20%; background: var(--accent); transition: width var(--dur-short) var(--ease-out); }

/* ── 步驟內容 ── */
.step {
  display: grid; gap: 28px;
  padding: 20px max(16px, env(safe-area-inset-right)) calc(var(--bar-h) + env(safe-area-inset-bottom) + 32px) max(16px, env(safe-area-inset-left));
  max-width: 40em; margin: 0 auto;
}
.field { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > legend, .lab { font-size: 15px; font-weight: 600; color: var(--ink); padding: 0; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
label.field > .lab { margin-bottom: 0; }
.req { font-size: 13px; font-weight: 400; color: var(--muted); }
.hint { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); min-height: 1.5em; }
.hint.is-err, .err { color: var(--bad); }
fieldset .hint:empty { display: none; } /* 選項群組的錯誤只在出錯時佔位 */
.err { margin: 0; font-size: 14px; }
.err:empty { display: none; }

input:not([type]), input[inputmode], textarea {
  width: 100%; min-inline-size: 0; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--control); border-radius: var(--r-ctl);
  padding: 10px 12px; block-size: 44px;
}
textarea { block-size: auto; min-height: 96px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
[aria-invalid="true"] { border-color: var(--bad); }

/* ── 選項：被選中＝螢光筆劃過 ── */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { position: relative; display: block; min-width: 0; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 16px 8px 10px; /* 左邊留給勾，視覺上置中 */
  border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--paper-2);
  font-size: 15px; line-height: 1.35; color: var(--ink);
  transition: background-color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
}
.grid2 .choice span { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; min-height: 60px; padding: 8px 32px 8px 14px; }
.choice small { font-size: 13px; color: var(--muted); }
.choice span::before { /* 勾：選取不只靠顏色 */
  content: ""; flex: none; inline-size: 5px; block-size: 10px; border: solid var(--ink); border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -2px); opacity: 0; transition: opacity var(--dur-short);
}
.grid2 .choice span::before { position: absolute; top: 12px; right: 14px; }
.choice input:checked + span { background: var(--marker); border-color: var(--marker-edge); }
.choice input:checked + span::before { opacity: 1; }
.choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice input:active + span { transform: scale(.98); }
.choice small { font-weight: 400; }

/* 語氣：兩端的字＋五格 */
.tone { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) 4.5em; align-items: center; gap: 8px; margin-bottom: 12px; }
.tone .end { font-size: 14px; color: var(--ink-2); }
.tone .end:last-child { text-align: right; }
.tone .scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.tone .choice span { min-height: 44px; padding: 0; justify-content: center; font-variant-numeric: tabular-nums; }
.tone .choice span::before { display: none; }
.tone-clear { font-size: 14px; }

/* 風格範例 */
.samples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
.sample { display: grid; grid-template-rows: auto auto auto 1fr; gap: 8px; min-width: 0; }
.sample img { inline-size: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: top; border-radius: var(--r-card); border: 1px solid var(--border); background: var(--paper-3); display: block; }
.sample.like img { outline: 3px solid var(--marker-edge); outline-offset: 2px; }
.sample.dislike img { opacity: .45; }
.sample h3 { margin: 0; font-size: 14px; line-height: 1.4; font-weight: 600; }
.sample .group { font-weight: 400; color: var(--muted); }
.vote { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.vote .choice span { justify-content: center; padding: 0 8px; }
.vote .choice span::before { display: none; }
.vote .dislike input:checked + span { background: var(--paper-3); border-color: var(--control); text-decoration: line-through; }
.sample input.note { block-size: 40px; font-size: 16px; padding: 8px 10px; }
.empty { padding: 20px 16px; border: 1px dashed var(--border); border-radius: var(--r-card); color: var(--ink-2); font-size: 15px; }
.empty p { margin: 0; }

/* 參考圖 */
.refs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.refs li { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 4px 12px; align-items: start; }
.refs img { inline-size: 72px; block-size: 96px; object-fit: cover; object-position: top; border-radius: var(--r-tag); border: 1px solid var(--border); grid-row: span 2; background: var(--paper-3); }
.refs .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-height: 32px; }
.refs .meta .btn { min-height: 44px; margin: -6px 0; }
.refs li.uploading img { opacity: .5; }
.file-btn { position: relative; justify-self: start; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; inline-size: 100%; }
.file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-btn.is-full { opacity: .5; pointer-events: none; }

/* 確認頁 */
.summary { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--rule); }
.summary > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.summary dt { font-size: 13px; color: var(--muted); grid-column: 1; }
.summary dd { margin: 0; grid-column: 1; font-size: 15px; overflow-wrap: anywhere; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.summary dd.none { color: var(--muted); font-size: 14px; }
.summary .edit { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

/* ── 按鈕 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--r-ctl);
  font: inherit; font-size: 16px; font-weight: 600; white-space: nowrap; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--ink);
  touch-action: manipulation; transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-short) var(--ease-out);
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.secondary { border-color: var(--control); background: var(--paper-2); }
.btn.text { color: var(--accent); padding: 0 12px; }
.btn.small { min-height: 44px; padding: 0 8px; font-size: 14px; font-weight: 500; }
.btn.wide { inline-size: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after { content: ""; inline-size: 16px; block-size: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover { background: color-mix(in oklch, var(--accent) 88%, var(--ink)); }
  .btn.secondary:hover, .choice input:not(:checked):hover + span { background: var(--paper-3); }
}

/* 底部列：主要動作在拇指範圍 */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--paper); border-top: 1px solid var(--rule);
}
.bar .primary { flex: 1; max-width: 20em; margin-left: auto; }
.bar #prev[hidden] { display: inline-flex !important; visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 1.5s !important; }
  .btn:active, .choice input:active + span { transform: none; }
}
@media (min-width: 720px) {
  .samples { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .top { padding-left: max(24px, calc((100vw - 40em) / 2 + 16px)); padding-right: max(24px, calc((100vw - 40em) / 2 + 16px)); }
}

/* ── 需求單列表與單張頁 ── */
.page .wrap { max-width: 40em; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--bar-h) + env(safe-area-inset-bottom) + 32px) max(16px, env(safe-area-inset-left)); }
.page .top { align-items: center; }
.back { padding: 0; margin-left: -4px; min-height: 44px; }
a.btn { text-decoration: none; }
.tlist-sec + .tlist-sec { margin-top: 24px; }
.tlist-sec h2 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.tlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.tlist a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); color: inherit; text-decoration: none; min-height: 56px; }
.tlist .t { font-size: 16px; font-weight: 600; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tlist .w { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tlist .s { grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-tag); font-size: 13px; font-weight: 500; white-space: nowrap; background: var(--paper-3); color: var(--ink-2); margin-right: 6px; }
.tag.wait { background: var(--marker); color: var(--ink); }
.tid { margin: 0; font: 13px/1.4 ui-monospace, "SF Mono", "Noto Sans Mono CJK TC", monospace; color: var(--muted); overflow-wrap: anywhere; }
#ticket h1 { margin: 4px 0 2px; }
.vtabs { display: flex; gap: 4px; margin: 12px 0 8px; flex-wrap: wrap; }
.vtabs button { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--paper-2); font: 600 14px/1 inherit; color: var(--ink-2); }
.vtabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.vnote { margin: 0 0 12px; white-space: pre-line; color: var(--ink-2); }
.shots { display: grid; gap: 16px; }
.shot { display: grid; gap: 6px; }
.shot a { display: block; border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; background: var(--paper-3); }
.shot img { display: block; inline-size: 100%; block-size: auto; }
.shot .cap { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.shot .cap .seen { color: var(--ok); }
#t-choose { margin-top: 24px; }
.log { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 10px; }
.log li { font-size: 15px; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.log .who { display: block; font-size: 13px; color: var(--muted); }
.log .ever { padding-left: 12px; border-left: 3px solid var(--marker-edge); }
.log .approve { padding: 8px 12px; background: var(--paper-3); border-radius: var(--r-ctl); }
.log:empty::before { content: "還沒有意見。"; color: var(--muted); font-size: 14px; }
.page section.field { margin-top: 28px; }
.sheet { border: 0; border-radius: 14px; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 30em; width: calc(100% - 24px); background: var(--paper-2); color: var(--ink); }
.sheet::backdrop { background: oklch(10% 0 0 / .45); }
.sheet h2 { margin: 0 0 8px; font-size: 18px; }
.sheet p { margin: 0 0 16px; color: var(--ink-2); white-space: pre-line; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
#t-bar .primary[disabled] { opacity: 1; background: var(--paper-3); color: var(--muted); }

.pair-code { margin: 0; font: 700 34px/1.2 ui-monospace, "SF Mono", "Noto Sans Mono CJK TC", monospace; letter-spacing: .04em; font-variant-numeric: tabular-nums; color: var(--ink); }
