:root {
  --bg: #fff7ed;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #ffedd5;
  --good: #15803d;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --surface: #292524;
    --ink: #f5f5f4;
    --muted: #a8a29e;
    --line: #44403c;
    --accent: #fb923c;
    --accent-ink: #1c1917;
    --accent-soft: #431407;
    --good: #4ade80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

a { color: var(--accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 15px;
}
.bar-links { display: flex; gap: 14px; }
.bar-link { font-size: 14px; text-decoration: none; }

.wrap { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; }

.ask { display: flex; gap: 8px; align-items: stretch; view-transition-name: ask; }
.ask textarea {
  flex: 1; min-width: 0; height: 46px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 12px; resize: none; overflow: hidden;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.4;
  white-space: nowrap; text-overflow: ellipsis;
}
.ask textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ask button {
  flex: 0 0 auto; min-height: 46px; padding: 0 18px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 700;
}

/* ---------- 首屏：輸入框是主角 ---------- */
.hero-intro, .hero-extra { display: none; }

.hero .wrap {
  min-height: calc(100svh - 50px);
  display: flex; flex-direction: column; justify-content: center;
  padding-bottom: 12svh;
}
.hero .hero-intro, .hero .hero-extra { display: block; }
.hero .picker, .hero .results, .hero .related, .hero .foot, .hero .understood { display: none; }

.hero-intro h1 { margin: 0 0 8px; font-size: clamp(30px, 9vw, 44px); line-height: 1.15; letter-spacing: -0.02em; }
.hero-intro p { margin: 0 0 20px; color: var(--muted); font-size: 15px; }

.hero .ask { flex-direction: column; }
.hero .ask textarea {
  height: auto; min-height: 112px; padding: 14px 16px; border-radius: 16px;
  font-size: 18px; white-space: pre-wrap; overflow: auto;
  box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 14%, transparent);
}
.hero .ask button { min-height: 52px; border-radius: 14px; font-size: 17px; }

.examples-label { margin: 22px 0 8px; font-size: 13px; color: var(--muted); }
.examples { display: grid; gap: 8px; }
.example {
  text-align: left; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 12px;
  background: transparent; color: var(--ink); font: inherit; font-size: 15px; cursor: pointer;
}
.example::before { content: "「"; color: var(--muted); }
.example::after { content: "」"; color: var(--muted); }
.example:active { background: var(--accent-soft); }
.browse {
  margin-top: 16px; padding: 8px 0; border: 0; background: none;
  color: var(--accent); font: inherit; font-size: 14px; cursor: pointer;
}
.browse-links { display: flex; flex-wrap: wrap; column-gap: 18px; margin-top: 10px; }
.browse-links .browse { margin-top: 0; text-decoration: none; }
.row[hidden] { display: none; }
.chip.thin:not([aria-pressed="true"]) { color: var(--muted); border-style: dashed; }

.combo .part { margin-top: 10px; padding: 10px 0 0; border-top: 1px dashed var(--line); }
.part-top { display: flex; align-items: baseline; gap: 8px; }
.part-store { font-weight: 700; }
.part-price { margin-left: auto; font-weight: 700; }
.part-title { margin: 2px 0 0; font-size: 15px; }
.detail-store { margin-top: 12px !important; color: var(--ink) !important; font-size: 14px !important; }

.page-title { margin: 4px 0 2px; font-size: 24px; }
.browse-bar {
  position: sticky; top: 49px; z-index: 1; margin: 8px -16px 0; padding: 6px 16px;
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.browse-bar .chips { padding: 2px; }
.browse-bar .sort .chip { min-height: 30px; padding: 3px 11px; font-size: 13px; }
.store-section { margin-top: 18px; }
.store-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.store-head h2 { margin: 0; font-size: 20px; }
.store-count { font-size: 13px; color: var(--muted); }
.deal-list { display: grid; gap: 8px; }
.deal-row { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.deal-row summary {
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 2px;
  padding: 10px 12px; cursor: pointer; list-style: none;
}
.deal-row summary::-webkit-details-marker { display: none; }
.row-title { font-weight: 600; line-height: 1.35; }
.row-price { font-weight: 800; font-size: 18px; }
.row-sub { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.deal-row[open] summary { border-bottom: 1px dashed var(--line); }
.row-body { padding: 4px 12px 12px; }
.find-link { display: inline-block; margin-top: 10px; font-size: 14px; text-decoration: none; }
.muted-note { margin: 0; font-size: 14px; color: var(--muted); }
.sub-head { margin: 14px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.program-list { padding: 4px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }

.card-body { display: flex; gap: 12px; align-items: flex-start; }
.card-text { flex: 1; min-width: 0; }
.thumb {
  flex: 0 0 88px; width: 88px; height: 88px; border-radius: 10px; object-fit: cover;
  background: var(--accent-soft); border: 1px solid var(--line);
}
.thumb.small { flex-basis: 64px; width: 64px; height: 64px; }
.full-image { display: block; width: 100%; height: auto; margin: 8px 0; border-radius: 10px; border: 1px solid var(--line); }
img.broken { display: none; }
.row-photo {
  font-size: 11px; padding: 0 5px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
}

.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.badge { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); }
.badge.media { background: var(--line); color: var(--ink); }
.badge.urgent { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.program-thumb { float: right; margin: 0 0 6px 10px; }
.related-item::after { content: ""; display: block; clear: both; }

.tip-form { display: grid; gap: 14px; margin-top: 14px; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.submit { min-height: 50px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 700; }
.tip-link { display: inline-block; margin-top: 10px; font-size: 14px; }

.privacy { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

.understood {
  margin: 8px 2px 0; font-size: 13px; color: var(--muted);
}
.understood strong { color: var(--ink); }

.picker { margin-top: 12px; display: grid; gap: 6px; }

.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.label {
  flex: 0 0 56px; font-size: 13px; color: var(--muted); line-height: 1.2;
}
.label small { display: block; font-size: 11px; }

.chips {
  display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0;
  padding: 4px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto; position: relative;
  min-height: 36px; padding: 6px 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font-size: 14px; white-space: nowrap;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip .order {
  display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 4px;
  border-radius: 50%; background: var(--accent-ink); color: var(--accent); font-size: 11px; font-weight: 700;
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.results { margin-top: 14px; display: grid; gap: 10px; }
.results-head { margin: 0; font-size: 14px; color: var(--muted); }
.loading, .empty { margin: 0; padding: 16px; border-radius: var(--radius); background: var(--surface); color: var(--muted); }
.empty p { margin: 0 0 10px; }
.relax { display: flex; flex-wrap: wrap; gap: 6px; }

.card {
  padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line);
}
.card-top { display: flex; align-items: baseline; gap: 8px; }
.rank {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.store { font-size: 14px; color: var(--muted); }
.price { margin-left: auto; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.title { margin: 4px 0 2px; font-size: 17px; line-height: 1.35; }
.meta { margin: 0; font-size: 13px; color: var(--muted); }
.meta .save { color: var(--good); font-weight: 600; }
.items { margin: 6px 0 0; font-size: 14px; }

.code-row {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 10px;
  border-radius: 10px; background: var(--accent-soft); font-size: 14px;
}
.code-row strong { font-size: 18px; letter-spacing: 0.06em; }
.code-row button {
  margin-left: auto; min-height: 32px; padding: 4px 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 600;
}
.how-note { margin: 10px 0 0; font-size: 13px; }

.validity { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.card details, .related { margin-top: 8px; }
.card summary, .related summary {
  cursor: pointer; font-size: 14px; color: var(--accent); padding: 6px 0; list-style: none;
}
.card summary::-webkit-details-marker, .related summary::-webkit-details-marker { display: none; }
.card summary::after { content: " ▾"; }
.card details[open] summary::after { content: " ▴"; }
.detail-block { font-size: 14px; }
.detail-block h4 { margin: 8px 0 2px; font-size: 13px; color: var(--muted); }
.detail-block ol, .detail-block ul { margin: 0; padding-left: 20px; }

.related { padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.related-item { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.related-item:first-child { border-top: 0; }
.related-item p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.foot { max-width: 640px; margin: 0 auto; padding: 8px 16px 32px; font-size: 12px; color: var(--muted); }
.foot p { margin: 4px 0; }

@media (min-width: 720px) {
  .wrap { padding-top: 24px; }
  .label { flex-basis: 72px; }
  .chips { flex-wrap: wrap; overflow: visible; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise 160ms ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

  /* 按下 Enter：輸入框從畫面中央滑到頂端，選項一排排浮出，被讀到的選項亮起來 */
  ::view-transition-group(ask) { animation-duration: 380ms; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
  ::view-transition-old(root) { animation: 180ms ease-in both fade-out; }
  ::view-transition-new(root) { animation: 260ms 120ms ease-out both fade-in; }
  @keyframes fade-out { to { opacity: 0; } }
  @keyframes fade-in { from { opacity: 0; } }

  .reveal .understood { animation: rise 240ms 120ms ease-out both; }
  .reveal .picker .row { animation: slide-in 280ms cubic-bezier(.2, .8, .2, 1) both; }
  .reveal .picker .row:nth-child(1) { animation-delay: 140ms; }
  .reveal .picker .row:nth-child(2) { animation-delay: 175ms; }
  .reveal .picker .row:nth-child(3) { animation-delay: 210ms; }
  .reveal .picker .row:nth-child(4) { animation-delay: 245ms; }
  .reveal .picker .row:nth-child(5) { animation-delay: 280ms; }
  .reveal .chip[aria-pressed="true"] { animation: pop 380ms 360ms cubic-bezier(.3, 1.6, .5, 1) both; }
  .reveal .results .card:nth-of-type(2) { animation-delay: 470ms; }
  .reveal .results .card:nth-of-type(3) { animation-delay: 530ms; }
  .reveal .card { animation: rise 300ms 410ms ease-out both; }
  @keyframes slide-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
  @keyframes pop {
    0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
    45% { transform: scale(1.12); }
    100% { transform: scale(1); box-shadow: 0 0 0 10px transparent; }
  }
}
