:root {
  --bg: #faf8fd; --surface: #ffffff; --ink: #231c33; --muted: #6d6580;
  --line: #e4def0; --accent: #6b4fa0; --accent-ink: #ffffff; --accent-soft: #efe9fa;
  --danger: #b3261e; --ok: #1e7a46; --warn-bg: #fff6e0; --warn-ink: #6a4a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15111d; --surface: #201a2d; --ink: #f0ebf8; --muted: #a79fba;
    --line: #342c47; --accent: #a98be0; --accent-ink: #1a1226; --accent-soft: #2c2340;
    --danger: #ff8a80; --ok: #7fd6a2; --warn-bg: #3a2f10; --warn-ink: #ffdc8a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}
.boot { text-align: center; margin-top: 30vh; color: var(--muted); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); font-size: .9rem; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }
.narrow { max-width: 440px; margin: 0 auto; padding: 32px 16px 64px; }
.brand { font-weight: 700; color: var(--accent); letter-spacing: .05em; }
header.top {
  position: sticky; top: 0; z-index: 5; background: var(--surface);
  border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; background: var(--surface);
  border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav.tabs a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  padding: 8px 2px; border-radius: 10px; font-size: .85rem; position: relative;
}
nav.tabs a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 12px;
}
.card.click { cursor: pointer; }
.card.click:hover { border-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 10px 0; }
.check input { margin-top: 5px; }
button, .btn {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 9px 16px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button.ghost { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.small { padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.full { width: 100%; }
.tag {
  display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .8rem;
  background: var(--accent-soft); color: var(--accent); margin: 0 4px 4px 0;
}
.tag.red { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 10px; font-size: .9rem; margin-bottom: 12px; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.3em; }
.tabsw { display: flex; gap: 6px; margin-bottom: 14px; }
.tabsw button { flex: 1; background: transparent; color: var(--muted); border-color: var(--line); }
.tabsw button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 14px; }
.filters .span2 { grid-column: 1 / -1; }
.filters label { margin: 0 0 2px; font-size: .85rem; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--accent-soft); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos img.blur { filter: blur(9px); transform: scale(1.25); }
.photos .del { position: absolute; top: 4px; right: 4px; }
.overlay {
  position: fixed; inset: 0; background: rgba(10, 6, 20, .55); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.chat { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; min-height: 40vh; }
.bub { max-width: 80%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bub.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bub.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bub small { display: block; opacity: .7; font-size: .7rem; margin-top: 2px; }
.sendbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface);
  border-top: 1px solid var(--line); padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
.sendbar input { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px;
  max-width: 90vw; font-size: .9rem; text-align: center;
}
.quiz .q { margin-bottom: 18px; }
.quiz .opt { display: flex; gap: 8px; margin: 6px 0; font-weight: 400; align-items: flex-start; }
.quiz .opt input { margin-top: 5px; }
.quiz .bad { border-left: 3px solid var(--danger); padding-left: 10px; }
.quiz .explain { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.legal h2 { margin-top: 1.4em; }
.legal ul { padding-left: 1.2em; }
.legal li { margin-bottom: .3em; }
code.codebox {
  display: inline-block; font: 600 1.05rem ui-monospace, monospace; letter-spacing: .1em;
  background: var(--accent-soft); color: var(--accent); padding: 2px 10px; border-radius: 8px; user-select: all;
}
pre.ctx { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: .85rem; max-height: 200px; overflow: auto; }
