/* Daily Text — app styles. Tokens first, then components (ported from planning/mockups). */
:root {
  --primary: #5b3f99;
  --primary-dark: #3e2a6e;
  --primary-tint: #eee8f7;
  --surface: #ffffff;
  --surface-alt: #f5f3f8;
  --ink: #1e1b2e;
  --ink-muted: #5f5b70;
  --gold: #d9a441;
  --gold-tint: #fbf1dc;
  --success: #2e7d5b;
  --success-tint: #e3f2ea;
  --warning: #b4541e;
  --warning-tint: #fbe9df;
  --danger: #b3261e;
  --line: #d9d4e3;
  --grey-fill: #e6e3ec;
  --chart-mid: #9b82d1;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
html[data-text-size="normal"] { font-size: 18px; }
html[data-text-size="xl"] { font-size: 24px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-alt); color: var(--ink); font-family: var(--font); font-size: 1rem; line-height: 1.45; }
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
  .appbar { background: var(--primary); color: #fff; padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 60px; }
  .appbar .title { font-size: 1.1rem; font-weight: 600; }
  .appbar .sub { font-size: 0.75rem; opacity: 0.85; font-weight: 400; display: block; }
  .appbar .ic { width: 28px; height: 28px; flex: none; }
  .appbar .back { display: flex; align-items: center; gap: 4px; font-size: 0.9rem; font-weight: 500; }
  .appbar .back .ic { width: 24px; height: 24px; }
  .appbar .back + .title { flex: 1; min-width: 0; text-align: center; font-size: 1rem; line-height: 1.2; padding: 0 6px; }
  .content { flex: 1; padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0px)); width: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
  .content.center { align-items: center; text-align: center; }
  .spacer { flex: 1; }
  .app-date { font-size: 0.9rem; color: var(--ink-muted); text-align: center; }
  .h { font-size: 1.3rem; font-weight: 600; line-height: 1.25; margin: 0; text-wrap: balance; }
  .h.big { font-size: 1.5rem; }
  .p { margin: 0; }
  .small { font-size: 0.8rem; color: var(--ink-muted); }

  /* streak hero */
  .hero { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 4px 0 0; }
  .hero .num { font-size: 4.6rem; font-weight: 700; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
  .hero .num .flame { font-size: 3rem; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
  .flame.big { font-size: 2.5rem; line-height: 1; }
  .hero .num.done { color: var(--success); }
  .hero .lbl { font-size: 1.1rem; font-weight: 500; margin-top: 4px; }
  .hero .num.mid { font-size: 2.2rem; }

  /* cards and buttons */
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 6px; width: 100%; }
  .card.tint { background: var(--primary-tint); border-color: transparent; }
  .card.warn { background: var(--warning-tint); border-color: transparent; }
  .card.warn .h { color: var(--warning); }
  .card.ok { background: var(--success-tint); border-color: transparent; }
  .card.ok .h { color: var(--success); }
  .card.gold { background: var(--gold-tint); border-color: transparent; }
  .card .row { display: flex; align-items: center; gap: 10px; }
  .card .ic { width: 30px; height: 30px; flex: none; }
  .btn { width: 100%; min-height: 60px; border-radius: 14px; font-size: 1.05rem; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 18px; text-align: center; }
  .btn .ic { width: 24px; height: 24px; flex: none; }
  .btn.primary { background: var(--primary); color: #fff; }
  .btn.secondary { background: var(--surface); color: var(--primary); border: 2px solid var(--primary); }
  .btn.plain { background: transparent; color: var(--primary); min-height: 52px; font-weight: 500; }
  .btn.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
  .btnrow { display: flex; gap: 12px; width: 100%; }
  .btnrow .btn { flex: 1; }
  .btnrow .btn.secondary { flex: 0 0 38%; }

  /* form */
  .field { display: flex; flex-direction: column; gap: 6px; width: 100%; }
  .field label { font-size: 0.9rem; font-weight: 500; }
  .input { background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 1rem; min-height: 56px; }
  .textarea { min-height: 200px; line-height: 1.45; }
  .input.focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
  .input .ph { color: var(--ink-muted); }
  .verse { background: var(--surface); border-left: 5px solid var(--primary); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; width: 100%; }
  .verse .ref { font-size: 0.85rem; font-weight: 600; color: var(--primary); }
  .verse .txt { font-size: 1rem; line-height: 1.4; margin: 0; }
  .verse.compact { padding: 10px 12px; gap: 2px; }
  .verse.compact .ref { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.8rem; }
  .verse.compact .txt { font-size: 0.85rem; line-height: 1.35; }
  .progress { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; font-size: 0.8rem; color: var(--ink-muted); }
  .progress > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dots { flex: none; }
  .dots { display: flex; gap: 8px; }
  .dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); display: block; }
  .dots i.on { background: var(--primary); }
  .dots i.done { background: var(--success); }
  .question { font-size: 1.35rem; font-weight: 600; line-height: 1.3; margin: 0; }
  .question em { font-style: normal; color: var(--primary); }

  /* history */
  .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
  .tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
  .tile .n { font-size: 1.5rem; font-weight: 700; color: var(--primary); line-height: 1.1; font-variant-numeric: tabular-nums; }
  .tile .l { font-size: 0.7rem; color: var(--ink-muted); }
  .cal { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
  .cal .head { display: flex; justify-content: space-between; align-items: center; font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
  .cal .head span { font-size: 1.3rem; color: var(--primary); padding: 0 10px; }
  .cal .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 0.8rem; }
  .cal .dow { color: var(--ink-muted); font-size: 0.65rem; font-weight: 600; padding-bottom: 4px; }
  .cal .d { width: 100%; max-width: 44px; aspect-ratio: 1; margin: 0 auto; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-variant-numeric: tabular-nums; }
  .cal .d.on { background: var(--success-tint); color: var(--success); font-weight: 600; }
  .cal .d.today { outline: 2px solid var(--primary); outline-offset: -2px; font-weight: 700; color: var(--primary); }
  .badges { display: flex; gap: 10px; width: 100%; }
  .badge { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.7rem; }
  .badge .medal { width: 40px; height: 40px; border-radius: 50%; background: var(--gold); color: #3a2a05; font-weight: 700; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; }
  .badge.locked { opacity: 0.55; }
  .badge.locked .medal { background: var(--line); color: var(--ink-muted); }
  .qa { display: flex; flex-direction: column; gap: 4px; width: 100%; }
  .qa .q { font-size: 0.8rem; font-weight: 600; color: var(--primary); }
  .qa .a { font-size: 0.95rem; margin: 0; }

  /* settings */
  .list { width: 100%; display: flex; flex-direction: column; gap: 10px; }
  .item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; font-size: 1rem; font-weight: 500; }
  .item .ic { width: 24px; height: 24px; color: var(--ink-muted); flex: none; }
  .item.red { color: var(--danger); }
  .seg { display: flex; width: 100%; border: 2px solid var(--primary); border-radius: 12px; overflow: hidden; }
  .seg > * { flex: 1; text-align: center; padding: 12px 4px; font-size: 0.85rem; font-weight: 600; color: var(--primary); }
  .seg > .on { background: var(--primary); color: #fff; }
  .steps { display: flex; flex-direction: column; gap: 12px; width: 100%; }
  .step { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 0.9rem; }
  .step .n { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
  .step .ic { width: 22px; height: 22px; vertical-align: -4px; }
  .celebrate { width: 128px; height: 128px; border-radius: 50%; background: var(--gold-tint); display: flex; align-items: center; justify-content: center; margin-top: 8px; }
  .celebrate .ic { width: 76px; height: 76px; color: var(--success); }
  .milestone { background: var(--gold); color: #3a2a05; border-radius: 999px; padding: 8px 18px; font-weight: 700; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 8px; }
  .milestone .ic { width: 22px; height: 22px; }
  .banner { background: var(--primary-tint); color: var(--primary-dark); font-size: 0.8rem; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; }
  .banner b { font-weight: 600; }

  /* late days, legend, reminder controls, notification */
  .cal .d.late { background: var(--grey-fill); color: var(--ink); font-weight: 600; }
  .cal .d.miss { color: var(--ink-muted); }
  .legend { display: flex; gap: 14px; font-size: 0.7rem; color: var(--ink-muted); margin-top: 8px; flex-wrap: wrap; }
  .legend span { display: inline-flex; align-items: center; gap: 6px; }
  .legend i { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }
  .legend i.on { background: var(--success-tint); border: 2px solid var(--success); border-color: transparent; box-shadow: none; }
  .legend i.on { background: var(--success-tint); }
  .legend i.late { background: var(--grey-fill); }
  .note { background: var(--primary-tint); color: var(--primary-dark); border-radius: 10px; padding: 10px 14px; font-size: 0.8rem; width: 100%; }
  .timepick { background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 14px; font-size: 2rem; font-weight: 600; text-align: center; color: var(--primary); font-variant-numeric: tabular-nums; }
  .switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; width: 100%; }
  .switchrow b { font-size: 0.95rem; font-weight: 600; display: block; }
  .switchrow .small { font-size: 0.75rem; }
  .switch { flex: none; width: 56px; height: 32px; border-radius: 999px; background: var(--primary); position: relative; }
  .switch::after { content: ""; position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; }
  .switch.off { background: var(--line); }
  .switch.off::after { right: auto; left: 4px; }

  /* reading-time stats */
  .hero-time { text-align: left; }
  .hero-time .big { font-size: 2.4rem; font-weight: 600; line-height: 1.05; color: var(--ink); }
  .hero-time .l { font-size: 0.85rem; color: var(--ink-muted); }
  .chartcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px 8px; width: 100%; }
  .chartcard h4 { margin: 0 0 6px 4px; font-size: 0.8rem; font-weight: 600; }
  .chartcard svg { display: block; }
  .periods { display: flex; flex-direction: column; gap: 6px; width: 100%; }
  .periods > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.9rem; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
  .periods > div > span { min-width: 0; display: flex; align-items: center; }
  .periods small { display: block; font-size: 0.7rem; color: var(--ink-muted); }
  .periods b { flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .periods i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #9b82d1; margin-right: 8px; }
  .periods i.peak { background: #5b3f99; }
  .meter { height: 14px; border-radius: 999px; background: var(--primary-tint); overflow: hidden; width: 100%; }
  .meter i { display: block; height: 100%; width: 36%; background: var(--primary); border-radius: 999px; }
  .card.stat { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
  .card.stat .h { font-size: 1rem; }

  /* install card and native sheet */
  .card.install { border: 2px solid var(--primary); gap: 10px; }
  .card.install .row { align-items: flex-start; }
  .card.install .h { font-size: 1.1rem; }
  .card.install .btn { min-height: 52px; font-size: 0.95rem; }
  .card.install .btnrow .btn { padding: 8px 10px; font-size: 0.9rem; }
  .card.install .btnrow .btn.secondary { flex: 0 0 34%; }
  .address { background: var(--surface); border: 2px dashed var(--primary); border-radius: 12px; padding: 12px 10px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  .address > span:first-child { font-size: 0.75rem; font-weight: 600; color: var(--primary); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
  .address .copy { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--primary); color: #fff; border-radius: 10px; padding: 10px 14px; font-size: 0.9rem; font-weight: 600; min-height: 48px; }
  .address .copy svg { width: 18px; height: 18px; }

  /* icon panel */
  .iconpanel { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; margin-top: 12px; }
  .iconbox { text-align: center; font-size: 0.85rem; color: var(--fg-muted); }
  .iconbox svg { display: block; margin: 0 auto 6px; max-width: 100%; }

/* app-only additions */
.appbar .back, .appbar .gearbtn { display: flex; align-items: center; gap: 4px; min-height: 44px; min-width: 44px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; }
.btn.primary.link, .btn.secondary.link { text-decoration: none; }
.input.textarea { width: 100%; resize: vertical; font-family: inherit; color: inherit; }
.input.textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); outline: none; }
input[type="time"].input { width: 100%; font-size: clamp(1.4rem, 8vw, 2rem); font-weight: 600; color: var(--primary); text-align: center; font-family: inherit; min-height: 64px; }
.confirm { background: var(--warning-tint); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; width: 100%; }
.confirm .h { color: var(--warning); }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: #fff; padding: 14px 18px; border-radius: 12px; font-size: 0.9rem; text-align: center; z-index: 10; }
.milestone-line { color: var(--ink-muted); }
.cal .d.btn-day { cursor: pointer; }
.address > span:first-child { font-size: clamp(13px, 4.2vw, 15px); }
.chartcard svg text { font-family: var(--font); }
.list .item .value { margin-left: auto; color: var(--ink-muted); font-weight: 400; font-size: 0.9rem; }
.chart-tip { font-size: 0.85rem; color: var(--ink-muted); margin: 6px 4px 0; min-height: 1.2em; }
