:root {
  --bg: #FCF084;
  --accent: #6CD8E4;
  --ink: #3C3C3C;
  --surface: #FCFCFC;
  --chick: #F0E478;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.7;
}
.nav {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 12px 16px;
}
.nav a {
  color: var(--ink); text-decoration: none; padding: 6px 14px;
  background: var(--surface); border: 3px solid var(--ink); border-radius: 999px;
  font-weight: 600;
}
.nav a:hover { background: var(--accent); }
.page { max-width: 720px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--surface); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 20px;
  padding: 20px; margin-bottom: 16px; box-shadow: 0 4px 0 rgba(60, 60, 60, 0.25);
}
.login { max-width: 360px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin: 0; text-align: center; }
input[type=password], input[type=text] {
  font: inherit; padding: 10px 14px; color: var(--ink); background: var(--surface);
  border: 3px solid var(--ink); border-radius: 14px;
}
button {
  font: inherit; font-weight: 700; color: var(--ink); background: var(--accent);
  border: 3px solid var(--ink); border-radius: 14px; padding: 10px 16px; cursor: pointer;
}
button:hover { background: var(--chick); }
.error { color: #b3261e; margin: 0; }

/* feed + day */
.card.moment { display: block; color: var(--ink); text-decoration: none; margin-bottom: 16px; }
.moment-meta { display: flex; gap: 10px; align-items: baseline; font-weight: 700; }
.moment-ago { background: var(--chick); border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; font-size: 0.85em; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; font-size: 0.9em; font-weight: 600; }
.chip-person { background: var(--accent); }
.chip-place { background: var(--chick); }
.moment-photo { display: block; max-width: 100%; max-height: 360px; border: 3px solid var(--ink); border-radius: 14px; margin: 8px 0; }
.moment-text { margin: 8px 0 0; white-space: pre-wrap; }
.empty { text-align: center; }
.empty-art { max-width: 160px; }
.day-title { margin: 8px 0 16px; text-align: center; }
.entry { margin-bottom: 16px; }
.entry-body { white-space: pre-wrap; }
.moment-block { border-left: 6px solid var(--accent); padding: 4px 12px; margin: 12px 0; }
.moment-block.mood-dark { opacity: 0.6; border-left-color: var(--ink); background: rgba(60, 60, 60, 0.06); }
.edit-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.edit-form textarea { font: inherit; color: var(--ink); background: var(--surface); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; width: 100%; }
.moment-link { color: inherit; text-decoration: none; display: block; }
a.chip { text-decoration: none; }
.search-form input { width: 100%; box-sizing: border-box; padding: 10px 14px; font-size: 1em; border: 2px solid var(--ink); border-radius: 12px; background: var(--surface); color: var(--ink); }
.last-seen { font-weight: 600; }
.card.moment.mood-dark { opacity: 0.6; background: rgba(60, 60, 60, 0.06); }

/* names review */
.name-list { list-style: none; padding: 0; margin: 0; }
.name-row { margin: 0 0 .75rem; }
.name-head { display: flex; gap: .5rem; align-items: center; }
.name-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.name-row form.inline, .name-row details.inline { display: inline-flex; gap: .25rem; }
.name-row .error { color: #b3261e; }
.name-row mark { background: var(--chick); color: var(--ink); }
.pager { display: flex; gap: 1rem; justify-content: center; }
.never-list li, .token-list li { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .25rem 0; }
.token-issued code { display: block; word-break: break-all; user-select: all; padding: .5rem; background: var(--surface); border: 2px solid var(--ink); border-radius: 8px; }
.hint { font-size: .85em; opacity: .75; }
#enable-push[disabled] { opacity: .5; cursor: not-allowed; }

/* write (interviewer chat) */
.write-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.write-head h1 { margin: 0; }
.write-head input[type=date], .draft-card input[type=date] { font: inherit; color: var(--ink); background: var(--surface); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; }
.messages { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; min-height: 40vh; }
.bubble { max-width: 85%; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 18px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-user { align-self: flex-end; background: var(--accent); }
.bubble-bot { align-self: flex-start; background: var(--surface); }
.draft-past { align-self: flex-start; max-width: 85%; background: var(--surface); border: 2px dashed var(--ink); border-radius: 14px; padding: 6px 12px; }
.draft-past p { white-space: pre-wrap; margin: 6px 0 0; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.composer textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; resize: vertical; }
.composer-row { display: flex; gap: 8px; margin-top: 8px; }
.composer-row .send { margin-left: auto; }
.composer button[disabled] { opacity: .5; cursor: not-allowed; }
#mic.recording { background: #b3261e; color: #fff; }
.draft-card { align-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.draft-card textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; }
.saved-card { align-self: stretch; }
.q-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.q-row .q-done { font-weight: 700; }

/* highlights list */
.card.highlight-card {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; color: var(--ink); text-decoration: none;
}
.highlight-card strong { font-size: 1.1em; }
.highlight-period { background: var(--chick); border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; font-size: 0.85em; font-weight: 700; white-space: nowrap; }

/* diary index heatmap */
:root { --hm0: #ffffff; --hm1: #ffe7d1; --hm2: #ffc49b; --hm3: #ff9466; --hm4: #ec5a45; --hm5: #b8283a; }
.hm-legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 0 0 16px; font-size: 0.85em; font-weight: 600; }
.hm-legend span { margin: 0 4px; }
.hm-year h2 { margin: 0 0 10px; }
.hm-grid { display: grid; grid-template-columns: 2.6em repeat(31, minmax(0, 1fr)); gap: 3px; align-items: center; }
.hm-tick { font-size: 0.65em; text-align: center; color: var(--ink); opacity: 0.7; }
.hm-month { font-size: 0.75em; font-weight: 700; white-space: nowrap; }
.hm-cell, .hm-none { display: block; aspect-ratio: 1; min-width: 0; border-radius: 3px; }
.hm-legend .hm-cell { width: 14px; }
.hm-cell { padding: 0; border: 1px solid rgba(60, 60, 60, 0.28); background: var(--hm0); font: inherit; }
.hm-cell.l1 { background: var(--hm1); } .hm-cell.l2 { background: var(--hm2); } .hm-cell.l3 { background: var(--hm3); }
.hm-cell.l4 { background: var(--hm4); } .hm-cell.l5 { background: var(--hm5); }
button.hm-cell { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; position: relative; }
button.hm-cell:hover, button.hm-cell:focus-visible, button.hm-cell.active {
  transform: translateY(-2px) scale(1.35); z-index: 2;
  box-shadow: 0 3px 6px rgba(60, 60, 60, 0.35); border-color: var(--ink); outline: none;
}
.hm-pop {
  position: absolute; z-index: 20; width: min(420px, calc(100vw - 16px)); max-height: 60vh; overflow: auto;
  background: var(--surface); color: var(--ink); border: 3px solid var(--ink); border-radius: 18px;
  padding: 16px 18px; box-shadow: 0 6px 0 rgba(60, 60, 60, 0.25); box-sizing: border-box;
}
.hm-pop[hidden] { display: none; }
.hm-pop:not(.sheet)::before {
  content: ''; position: absolute; top: -10px; left: calc(var(--arrow-x, 50%) - 9px);
  border: 9px solid transparent; border-top: 0; border-bottom-color: var(--ink);
}
.hm-pop.above:not(.sheet)::before { top: auto; bottom: -10px; border-bottom: 0; border-top: 9px solid var(--ink); }
.hm-pop.sheet { position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; width: auto; max-height: 70vh; }
.hm-close { position: sticky; top: 0; float: right; border: 2px solid var(--ink); border-radius: 999px; background: var(--chick); cursor: pointer; font: inherit; line-height: 1; padding: 4px 8px; }
.hm-pop-date { margin: 0 0 8px; }
.hm-pop-entry .entry-body { white-space: pre-wrap; margin: 6px 0 12px; }
.hm-pop-more { display: inline-block; font-weight: 700; color: var(--ink); background: var(--accent); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 12px; text-decoration: none; }
@media (max-width: 600px) {
  .card.hm-year { padding: 14px 10px; }
  .hm-grid { grid-template-columns: 2.2em repeat(31, minmax(0, 1fr)); gap: 1.5px; }
  .hm-cell, .hm-none { border-radius: 2px; }
  .hm-cell { border-width: 0.5px; }
  .hm-month { font-size: 0.7em; }
  .hm-tick { font-size: 0.55em; }
}

/* index tabs + name index */
.index-tabs { display: flex; gap: 8px; margin: 0 0 16px; }
.index-tabs a { color: var(--ink); text-decoration: none; font-weight: 700; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 14px; background: var(--surface); }
.index-tabs a.active { background: var(--accent); }
.name-index { list-style: none; padding: 8px 16px; margin: 0 0 16px; }
.ni-row a {
  display: grid; grid-template-columns: minmax(5em, max-content) auto 1fr 3.5em; align-items: center; gap: 10px;
  padding: 7px 4px; color: var(--ink); text-decoration: none; border-bottom: 1px solid rgba(60, 60, 60, 0.12);
}
.ni-row:last-child a { border-bottom: 0; }
.ni-row a:hover { background: rgba(108, 216, 228, 0.18); border-radius: 8px; }
.ni-name { font-weight: 700; }
.ni-tag { font-size: 0.7em; border: 1px solid rgba(60, 60, 60, 0.4); border-radius: 999px; padding: 0 6px; opacity: 0.75; }
.ni-row:not(.ni-candidate) .ni-tag { visibility: hidden; }
.ni-bar { height: 10px; background: var(--accent); border: 1.5px solid var(--ink); border-radius: 999px; justify-self: start; }
.ni-candidate .ni-name { font-weight: 500; }
.ni-candidate .ni-bar { background: var(--chick); }
.ni-count { text-align: right; font-size: 0.85em; font-weight: 600; white-space: nowrap; }
.voice-queue { margin: 6px 0; }
.voice-queue .btn { margin-left: 4px; }
