:root {
  --cream: #F6F1EC;
  --cream-2: #EFE6DA;
  --gold: #A8844F;
  --gold-ink: #6E5530;
  --gold-light: #C9A774;
  --gold-dim: #6B5A43;
  --ink: #141414;
  --ink-2: #2B2620;
  --muted: #4A4238;
  --rule: #E3D8C8;
  --field: #CDBFA9;
  --red: #A33A26;
  --rec: #E0674F;
  --dark-rule: #3A342C;
  --dark-muted: #BDB3A4;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Montserrat', -apple-system, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); color: var(--ink); }
body {
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { min-height: 100vh; min-height: 100dvh; }

.screen {
  min-height: 100vh; min-height: 100dvh;
  max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: calc(32px + var(--safe-top)) 24px calc(16px + var(--safe-bottom));
}
.screen.centered { align-items: center; text-align: center; }
.screen.dark { background: var(--ink); color: var(--cream); max-width: none; }
.screen.dark > * { width: 100%; max-width: 432px; }
body.is-dark, body.is-dark html { background: var(--ink); }

/* type */
.eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 3px; color: var(--gold-ink); text-transform: uppercase; line-height: 1.6; }
.eyebrow.ink { color: var(--ink); }
.label { display: block; margin: 0; font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--gold-ink); text-transform: uppercase; }
.display { margin: 0; font-family: var(--serif); font-weight: 400; line-height: 1.05; }
.h1 { font-size: 44px; }
.h2 { font-size: 40px; }
.big-num { margin: 0; font-family: var(--serif); font-size: 120px; line-height: .9; letter-spacing: -2px; font-weight: 400; }
.sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.sunburst { display: block; }

/* buttons */
.btn {
  height: 56px; border-radius: 12px; border: 1.5px solid var(--ink); background: transparent;
  font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px;
}
.btn-primary {
  height: 60px; border-radius: 14px; border: 0; background: var(--ink); color: var(--cream);
  font-size: 15px; font-weight: 700; letter-spacing: 1.5px; width: 100%;
}
.btn-dashed { height: 52px; border-radius: 12px; border: 1.5px dashed var(--ink); background: transparent; font-size: 13px; font-weight: 700; letter-spacing: 1px; width: 100%; }
.btn-text { min-height: 44px; padding: 0 12px; border: 0; background: transparent; font-size: 13px; font-weight: 600; color: var(--gold-ink); display: inline-flex; align-items: center; gap: 6px; }
.btn-small { height: 44px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--ink); color: var(--cream); font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.btn-small.outline { border: 1.5px solid var(--ink); background: transparent; color: var(--ink); font-weight: 600; letter-spacing: 0; }
.btn-small.danger { background: transparent; color: var(--red); font-weight: 600; letter-spacing: 0; padding: 0 10px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 10px; flex: none; }
.icon-btn.boxed { border: 1.5px solid var(--ink); }

/* home */
.record-btn {
  margin-top: 30px; width: 140px; height: 140px; border-radius: 50%; border: 3px solid var(--gold);
  background: var(--ink); padding: 0; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 10px var(--cream-2); transition: transform .12s ease;
}
.record-btn:active { transform: scale(.96); }
.home-actions { margin-top: auto; padding-top: 28px; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upload-link { margin-top: 6px; }

/* nav */
.tabbar { position: sticky; bottom: 0; z-index: 5; background: var(--cream); margin-top: 14px; margin-bottom: calc(-16px - var(--safe-bottom)); padding-bottom: calc(8px + var(--safe-bottom)); width: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--gold); padding-top: 6px; }
.tab { height: 52px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--gold-ink); font-size: 11px; font-weight: 600; letter-spacing: 1.5px; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* recording */
.rec-head { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--gold-light); }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); display: inline-block; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { margin: 18px 0 0; font-family: var(--serif); font-size: 88px; line-height: 1; letter-spacing: -1px; font-weight: 400; font-variant-numeric: tabular-nums; }
.bars { margin: 28px auto 0; height: 64px; display: flex; align-items: center; justify-content: center; gap: 5px; }
.bars span { width: 4px; height: 6px; background: var(--gold-light); border-radius: 2px; transition: height .08s linear; }
.rec-card { margin-top: 32px; border: 1px solid var(--dark-rule); border-radius: 14px; padding: 18px 18px 20px; text-align: left; }
.rec-card .label { color: var(--gold-light); }
.rec-card p.q { margin: 10px 0 0; font-family: var(--serif); font-size: 26px; line-height: 1.15; }
.rec-card p.tip { margin: 10px 0 0; font-size: 15px; line-height: 1.55; color: var(--cream); }
.stop-btn { margin: 28px auto 0; width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--gold-light); background: var(--cream); display: flex; align-items: center; justify-content: center; padding: 0; }
.stop-btn span { width: 30px; height: 30px; border-radius: 6px; background: var(--ink); display: block; }
.dark .btn-text { color: var(--gold-light); margin: 6px auto 0; }
.dark .sub { color: var(--dark-muted); }

/* tag */
.tags { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tag-btn { height: 56px; border-radius: 12px; border: 1.5px solid var(--ink); background: transparent; font-size: 14px; font-weight: 600; }
.tag-btn[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.preview { margin-top: 28px; border-top: 1px solid var(--gold); padding-top: 18px; }
.preview-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.play-btn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.preview img { margin-top: 12px; width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; background: var(--cream-2); display: block; }
.prompt-quote { margin: 10px 0 0; font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.field-label { margin-top: 22px; }
.input, .textarea, .select {
  margin-top: 8px; width: 100%; min-height: 48px; border-radius: 10px; border: 1.5px solid var(--field); background: #fff;
  padding: 0 14px; font-size: 16px; color: var(--ink);
}
.textarea { padding: 12px 14px; line-height: 1.5; resize: vertical; min-height: 140px; }
.textarea.short { min-height: 88px; }
.select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236E5530' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--ink); outline: none; }
.save-area { margin-top: auto; padding-top: 24px; }
.notice { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: #fff; border: 1.5px solid var(--gold); font-size: 14px; line-height: 1.45; text-align: left; }
.notice.error { border-color: var(--red); }
.notice strong { display: block; margin-bottom: 2px; }

/* saved */
.check-ring { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center; }
.hype { margin: 8px 0 0; font-family: var(--serif); font-size: 28px; line-height: 1.15; }
.latest { margin-top: 34px; width: 100%; border-top: 1px solid var(--gold); text-align: left; }
.latest-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.latest-row:last-child { border-bottom: 0; }
.chip { font-size: 10px; font-weight: 700; letter-spacing: 1px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--ink); white-space: nowrap; text-transform: uppercase; }
.chip.filled { background: var(--ink); color: var(--cream); }
.latest-title { flex: 1; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-date { font-size: 12px; color: var(--gold-ink); white-space: nowrap; }

/* prompts */
.q-card { margin-top: 20px; background: var(--ink); color: var(--cream); border-radius: 16px; padding: 22px 20px 18px; border: 1.5px solid var(--gold); }
.q-card .label { color: var(--gold-light); }
.q-card .q { margin: 10px 0 0; font-family: var(--serif); font-size: 27px; line-height: 1.15; }
.q-actions { margin-top: 18px; display: flex; gap: 10px; }
.q-answer { flex: 1; height: 48px; border-radius: 10px; border: 0; background: var(--cream); color: var(--ink); font-size: 13px; font-weight: 700; letter-spacing: 1px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.q-shuffle { width: 48px; height: 48px; border-radius: 10px; border: 1.5px solid var(--gold-dim); background: transparent; color: var(--cream); display: flex; align-items: center; justify-content: center; padding: 0; }
.q-type { margin-top: 6px; color: var(--gold-light); padding: 0; }
.chips-row { margin-top: 18px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips-row::-webkit-scrollbar { display: none; }
.filter { height: 44px; padding: 0 16px; border-radius: 22px; border: 1.5px solid var(--ink); background: transparent; font-size: 12px; font-weight: 600; white-space: nowrap; flex: none; }
.filter[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.count-line { margin: 12px 0 0; font-size: 12px; font-weight: 600; color: var(--gold-ink); letter-spacing: .5px; }
.plist { margin: 4px 0 0; padding: 0; list-style: none; }
.plist li { border-bottom: 1px solid var(--rule); }
.plist li:last-child { border-bottom: 0; }
.pitem { width: 100%; min-height: 52px; padding: 10px 0; border: 0; background: transparent; text-align: left; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.pitem .pq { flex: 1; }
.pitem.done .pq { color: var(--muted); }
.check { width: 22px; height: 22px; border-radius: 50%; background: var(--gold-ink); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.scroll-body { flex: 1; }

/* chapters */
.ch-head { margin-top: 6px; display: flex; align-items: baseline; justify-content: space-between; }
.ch-count { margin: 0; font-size: 12px; font-weight: 600; color: var(--gold-ink); }
.sug-card { margin-top: 18px; background: var(--ink); color: var(--cream); border-radius: 16px; padding: 16px 16px 6px; border: 1.5px solid var(--gold); }
.sug-card .label { color: var(--gold-light); margin-bottom: 4px; }
.sug-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--dark-rule); }
.sug-row:last-child { border-bottom: 0; }
.sug-title { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.1; }
.sug-src { margin: 3px 0 0; font-size: 11px; color: var(--dark-muted); }
.sug-x { width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--gold-dim); background: transparent; color: var(--dark-muted); display: flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.sug-add { height: 44px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--cream); color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: 1px; flex: none; }
.clist { margin: 14px 0 0; padding: 0; list-style: none; }
.clist li { border-bottom: 1px solid var(--rule); }
.clist li:last-child { border-bottom: 0; }
.crow { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.cnum { font-family: var(--serif); font-size: 22px; color: var(--gold-ink); width: 26px; flex: none; }
.cbody { flex: 1; min-width: 0; }
.ctitle { display: block; font-size: 15px; font-weight: 600; }
.cmeta { display: block; margin-top: 2px; font-size: 11px; color: var(--gold-ink); }
.cedit { padding: 12px 0; }
.cedit .input { margin-top: 0; flex: 1; border: 2px solid var(--ink); font-weight: 600; }
.cedit-actions { margin: 10px 0 0 36px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cedit-actions .spacer { flex: 1; }
.empty { margin: 18px 0 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.new-ch { margin-top: auto; padding-top: 18px; }

/* login */
.login-form { margin-top: 32px; width: 100%; text-align: left; }
.login-form .input { font-size: 18px; height: 56px; text-align: center; letter-spacing: 2px; }

/* sheet / overlay */
.overlay { position: fixed; inset: 0; background: rgba(20,20,20,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; padding: 16px 16px calc(16px + var(--safe-bottom)); }
.sheet { width: 100%; max-width: 440px; background: var(--cream); border-radius: 20px; padding: 24px 22px 18px; border: 1.5px solid var(--gold); }
.sheet ol { margin: 14px 0 0; padding-left: 22px; font-size: 15px; line-height: 1.55; }
.sheet ol li { margin-bottom: 8px; }
.sheet p { font-size: 14px; line-height: 1.5; color: var(--muted); }
.share-ico { display: inline-block; vertical-align: -3px; }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-bottom)); background: var(--ink); color: var(--cream); border-radius: 12px; padding: 10px 10px 10px 16px; display: flex; align-items: center; gap: 12px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast[hidden] { display: none; }
.toast button { height: 44px; padding: 0 14px; border-radius: 8px; border: 0; background: var(--cream); color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: 1px; }

.loading { margin: 40px auto; font-size: 13px; color: var(--gold-ink); letter-spacing: 1px; text-align: center; }
.busy { position: relative; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
