/* 色票＝Sandglass 品牌色，唯一來源是 brand/build_brand.py 的 PALETTE（改色先改那裡）。 */
:root {
  --bg: #f7f3ec;
  --card: #ffffff;
  --ink: #1d1b2c;
  --muted: #6b6676;
  --line: #e6e0d6;
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #e8e6fb;
  --sand: #e8b36a;
  --mine: #4338ca;
  --mine-ink: #ffffff;
  --theirs: #ffffff;
  --danger: #c2410c;
  --warn: #b45309;
  --ok: #16a34a;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14131f;
    --card: #1e1c2c;
    --ink: #edebf5;
    --muted: #a39fb3;
    --line: #2e2b40;
    --accent: #8b85ff;
    --accent-ink: #0f0e17;
    --accent-soft: #2a2752;
    --sand: #f0c27f;
    --mine: #5b54e8;
    --mine-ink: #ffffff;
    --theirs: #262338;
    --danger: #fb923c;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.3);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

/* ---------- 頂部 ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* 品牌：對話框沙漏圖示＋自繪字標（深色模式由 <picture> 換淺色字標） */
.logo {
  width: 28px;
  height: 28px;
  flex: none;
}

.wordmark {
  display: block;
  height: 22px;
  width: auto;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 按鈕 ---------- */

.primary,
.secondary,
.ghost,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.05s ease, background 0.15s ease;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.primary:active,
.secondary:active,
.danger:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.big {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.05rem;
}

.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.lang {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* ---------- 開房頁 ---------- */

.create {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.create h1 {
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 16px 0 8px;
}

.sub {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 1.05rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 12px;
}

.field-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.step {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 1.3rem;
  cursor: pointer;
}

.count {
  min-width: 80px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 14px;
  cursor: pointer;
}

.chip.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.chip.paid {
  color: var(--muted);
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.result .link {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row .primary {
  flex: 1;
}

.result .ghost.small {
  justify-self: start;
  border: none;
  padding-left: 0;
}

.error {
  color: var(--danger);
  margin: 0;
}

.promise {
  margin-top: 28px;
  padding: 0 4px;
}

.promise h2 {
  font-size: 0.95rem;
  margin: 0 0 8px;
}

.promise ul {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.promise .honest {
  color: var(--warn);
}

/* ---------- 聊天頁 ---------- */

.room {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.bar:empty {
  display: none;
}

.people {
  display: flex;
  align-items: center;
  gap: 4px;
}

.seats {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.avatar {
  --c: #64748b;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  flex: none;
}

.people .avatar {
  opacity: 0.45;
}

.people .avatar.online {
  opacity: 1;
}

.people .avatar.online::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--bg);
}

.a-A { --c: #4f46e5; }
.a-B { --c: #db2777; }
.a-C { --c: #0891b2; }
.a-D { --c: #ca8a04; }
.a-E { --c: #16a34a; }
.a-F { --c: #9333ea; }
.a-G { --c: #ea580c; }
.a-H { --c: #0d9488; }
.a-I { --c: #e11d48; }
.a-J { --c: #2563eb; }

.timer {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.timer .label {
  color: var(--muted);
  font-size: 0.8rem;
}

.timer .clock {
  font-weight: 700;
}

.timer.warn .clock {
  color: var(--warn);
}

.actions {
  display: flex;
  gap: 6px;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.notice {
  align-self: center;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 0 16px;
}

.lock-icon::before {
  content: "🔒 ";
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
}

.msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bubble {
  background: var(--theirs);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  padding: 8px 12px;
  min-width: 0;
}

.msg.mine .bubble {
  background: var(--mine);
  color: var(--mine-ink);
  border-color: transparent;
  border-radius: 18px 18px 6px 18px;
}

.text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.text.broken {
  font-style: italic;
  opacity: 0.7;
}

.bubble time {
  display: block;
  font-size: 0.7rem;
  opacity: 0.6;
  text-align: right;
  margin-top: 2px;
}

.status {
  align-self: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  padding: 10px 14px;
  max-height: 160px;
  overflow-y: hidden; /* 超過 160px 才由 autoGrow 打開捲軸 */
  /* 16px 以上，iPhone 點輸入框才不會自動放大 */
  font-size: 16px;
  line-height: 1.4;
}

.composer textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 0;
}

.viral {
  display: block;
  text-align: center;
  padding: 6px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.viral:hover {
  color: var(--accent);
}

/* ---------- 結束畫面（滿員／消失／連結不完整） ---------- */

.end {
  max-width: 440px;
  margin: 0 auto;
  padding: 56px 20px;
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.end h1 {
  margin: 8px 0 0;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.end p {
  margin: 0 0 12px;
  color: var(--muted);
}

.end-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: var(--accent-soft);
}

.end-icon::before {
  content: "🔗";
}

.end.lock .end-icon::before {
  content: "🔒";
}

.end.gone .end-icon {
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 25%, transparent), transparent 70%);
  animation: fade 2.4s ease-out both;
}

.end.gone .end-icon::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  animation: vanish 2.4s ease-out both;
}

@keyframes vanish {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.2); opacity: 0; }
}

@keyframes fade {
  from { opacity: 1; }
  to { opacity: 0.35; }
}

/* ---------- 假付費視窗 ---------- */

dialog.door {
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 24px;
  width: min(400px, calc(100vw - 32px));
}

dialog.door::backdrop {
  background: rgb(0 0 0 / 0.4);
}

dialog.door h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.pass-body {
  display: grid;
  gap: 10px;
}

.pass-body p {
  margin: 0;
  color: var(--muted);
}

.perks {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 4px;
}

.perks .soon {
  color: var(--muted);
}

.pass-body .price {
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
}

.pass-body .trace {
  font-size: 0.85rem;
}

.pass-body .test-banner {
  color: var(--warn);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px dashed color-mix(in srgb, var(--warn) 60%, transparent);
  border-radius: 10px;
  padding: 8px 10px;
}

.pass-body .email {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px;
}

.pass-body .waiting,
.pass-body .done {
  color: var(--ink);
  text-align: center;
  padding: 16px 0;
  font-weight: 600;
}

.pass-body .error {
  color: var(--danger);
}

dialog.door .close {
  width: 100%;
}

/* ---------- Pass 標記與系統提示 ---------- */

.pass-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.sys {
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 2px 10px;
}

/* ---------- 18 歲聲明、頁尾、問卷 ---------- */

.adult {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
}

.adult input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  flex: none;
}

.adult a,
.foot a {
  color: var(--accent);
}

.foot {
  margin-top: 32px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.survey {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin: 8px 0 12px;
}

.survey .field-label {
  margin: 0;
  color: var(--ink);
}

.chips.center {
  justify-content: center;
}

.survey .thanks {
  color: var(--ok);
  font-weight: 600;
}

/* ---------- 彈出視窗：邀請（QR）、更多、檢舉 ---------- */

.dlg-body {
  display: grid;
  gap: 10px;
}

.dlg-body p {
  margin: 0;
}

.dlg-body .hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.dlg-body .done {
  color: var(--ink);
  font-weight: 600;
  padding: 8px 0;
}

.dlg-body .error:empty {
  display: none;
}

.dlg-body .link {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.qr {
  justify-self: center;
  padding: 8px;
  background: #ffffff;
  border-radius: 12px;
  line-height: 0;
}

.reasons {
  display: grid;
  gap: 6px;
}

.reason {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.reason:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.end .error:empty {
  display: none;
}

/* ---------- 條款／隱私權政策頁 ---------- */

.doc {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 20px 64px;
}

.doc h1 {
  font-size: 1.8rem;
  letter-spacing: -0.01em;
  margin: 24px 0 4px;
}

.doc h2 {
  font-size: 1.1rem;
  margin: 28px 0 6px;
}

.doc p,
.doc li {
  color: var(--ink);
}

.doc .meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0;
}

.doc .lead {
  font-size: 1.1rem;
  font-weight: 600;
}

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

.doc code {
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.doc th,
.doc td {
  text-align: left;
  vertical-align: top;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.doc th {
  color: var(--muted);
  font-weight: 600;
}

.doc hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 48px 0 8px;
}

/* ---------- 自訂名稱 ---------- */

.name-input {
  width: 100%;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 16px; /* iPhone 不自動放大 */
  text-align: center;
}

.dlg-body .name-input {
  max-width: none;
  text-align: left;
}

.end.join .field-label {
  margin-top: 4px;
}

.bubble .who {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}

/* 語言下拉選單 */
select.lang {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  max-width: 9.5em;
}

select.lang:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
}

/* ---------- SEO 說明頁（/en/、/zh-tw/…，seo/build_seo.mjs 產生） ---------- */

.doc.seo h1 {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.doc.seo .cta {
  width: auto;
  display: inline-flex;
  padding: 14px 24px;
}

.doc.seo .steps {
  padding-left: 1.4em;
  display: grid;
  gap: 6px;
}

.doc.seo .faq h3 {
  font-size: 1rem;
  margin: 18px 0 4px;
}

.doc.seo .faq p {
  margin: 0;
  color: var(--muted);
}

.doc.seo .cta-end {
  margin-top: 36px;
}

.foot .langs {
  margin-bottom: 8px;
  line-height: 1.9;
}

.foot .langs span[aria-current] {
  color: var(--ink);
  font-weight: 600;
}

.top .primary.small {
  padding: 8px 14px;
}

/* 內文連結樣式（.doc a）不能蓋掉按鈕的文字色 */
.doc a.primary {
  color: var(--accent-ink);
  text-decoration: none;
}
