/* Layout: one notebook column — 12-week goal page, road with 3 checkpoints, today's habits, inner check, week, review, measurements, feedback, promise. Owner gets a viewing banner and an edit panel. */
:root {
  --paper: #f6f7f4; --sheet: #ffffff; --ink: #1d3340; --ink-soft: #52656f; --line: #d9dfdc;
  --sea: #2f6f73; --sea-soft: #e3efee; --gold: #c08a1e; --gold-soft: #fbf1dc;
  --cover-bg: #1f4a4d; --cover-ink: #f3efe2; --cover-gold: #d8b25c;
  --font-book: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-ui: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131b20; --sheet: #1b252b; --ink: #eef2f1; --ink-soft: #a9b8bc; --line: #2e3c43;
    --sea: #7cc3c4; --sea-soft: #20363a; --gold: #e7b65a; --gold-soft: #3a2f1a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #131b20; --sheet: #1b252b; --ink: #eef2f1; --ink-soft: #a9b8bc; --line: #2e3c43;
  --sea: #7cc3c4; --sea-soft: #20363a; --gold: #e7b65a; --gold-soft: #3a2f1a; color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-ui); font-size: 18px; line-height: 1.7; }
.wrap { max-width: 480px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 20px calc(120px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 26px; }
section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
h2 { margin: 0; font-size: 22px; }
h3 { margin: 0; font-size: 17px; }
p { margin: 0; }
button { font: inherit; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--sheet); border: 2px solid var(--line); border-radius: 10px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.hint { font-size: 14px; color: var(--ink-soft); line-height: 1.6; }

/* Status + owner banner */
.save-status { font-size: 14px; line-height: 1.5; padding: 8px 12px; border-radius: 10px; background: var(--sea-soft); color: var(--sea); font-weight: 700; }
.save-status.wait { background: var(--sheet); color: var(--ink-soft); border: 1px dashed var(--line); }
.save-status.warn { background: var(--gold-soft); color: var(--ink); border: 1px solid var(--gold); }

/* Goal */
.goal { background: var(--cover-bg); color: var(--cover-ink); border-radius: 16px; padding: 22px 20px 18px; gap: 0; }
.goal .book-label { color: var(--cover-gold); }
.goal .chapter { color: var(--cover-gold); }
.goal .name { color: color-mix(in srgb, var(--cover-ink) 75%, transparent); }
.goal .why { color: color-mix(in srgb, var(--cover-ink) 80%, transparent); border-top: 1px solid color-mix(in srgb, var(--cover-gold) 40%, transparent); padding-top: 12px; }
.goal .stat { background: color-mix(in srgb, var(--cover-ink) 10%, transparent); }
.goal .stat span { color: color-mix(in srgb, var(--cover-ink) 75%, transparent); }
.goal .weekbar i { background: color-mix(in srgb, var(--cover-ink) 18%, transparent); }
.goal .weekbar i.past { background: var(--cover-ink); }
.goal .weekbar i.now { background: var(--cover-gold); }
.goal .weekbar i.cp { box-shadow: 0 0 0 2px var(--cover-bg), 0 0 0 3px var(--cover-gold); }
.aff-label { margin-top: 6px; font-size: 13px; letter-spacing: .2em; color: var(--cover-gold); font-weight: 700; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.book-label { font-size: 12px; letter-spacing: .18em; color: var(--sea); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.book-label img { width: 22px; height: 22px; border-radius: 5px; }
.chapter { font-family: var(--font-book); font-weight: 800; font-size: 18px; color: var(--gold); white-space: nowrap; }
.name { margin: 4px 0 12px; font-size: 16px; color: var(--ink-soft); }
.goal h1 { margin: 6px 0 0; font-family: var(--font-book); font-weight: 800; font-size: 28px; line-height: 1.6; text-wrap: balance; }
.goal h1.placeholder { font-size: 19px; color: color-mix(in srgb, var(--cover-ink) 70%, transparent); }
.why { margin-top: 14px; font-size: 16px; color: var(--ink-soft); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat { background: var(--sea-soft); border-radius: 10px; padding: 8px 12px; }
.stat span { display: block; font-size: 13px; color: var(--ink-soft); }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.weekbar { margin-top: 14px; display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.weekbar i { height: 8px; border-radius: 3px; background: var(--line); }
.weekbar i.past { background: var(--sea); }
.weekbar i.now { background: var(--gold); }
.weekbar i.cp { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 3px var(--gold); }

/* Road */
.road { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.stations { list-style: none; margin: 0; padding: 0; position: relative; display: flex; flex-direction: column; gap: 14px; }
.stations::before { content: ""; position: absolute; left: 11px; top: 12px; bottom: 12px; width: 3px; background: var(--line); border-radius: 2px; }
.st { position: relative; padding-left: 38px; }
.st::before { content: ""; position: absolute; left: 3px; top: 6px; width: 19px; height: 19px; border-radius: 50%; background: var(--sheet); border: 3px solid var(--line); }
.st.done::before { background: var(--sea); border-color: var(--sea); }
.st.now::before { background: var(--gold); border-color: var(--gold); }
.st .when { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.st .what { font-size: 17px; font-weight: 700; }

/* Today */
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.date { font-size: 15px; color: var(--ink-soft); }
.progress { font-size: 15px; color: var(--sea); font-weight: 700; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.item { width: 100%; display: flex; align-items: center; gap: 16px; text-align: left; background: var(--sheet); color: var(--ink); border: 2px solid var(--line); border-radius: 14px; padding: 14px 18px; cursor: pointer; min-height: 72px; transition: background .2s, border-color .2s; }
.item:disabled { cursor: default; }
.box { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--sea); display: grid; place-items: center; font-size: 22px; color: transparent; transition: background .2s; }
.item .t { display: block; font-size: 20px; font-weight: 700; }
.item .s { display: block; font-size: 14px; color: var(--ink-soft); }
.item[aria-pressed="true"] { background: var(--sea-soft); border-color: var(--sea); }
.item[aria-pressed="true"] .box { background: var(--sea); color: var(--sheet); }
.sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 8px; padding-left: 4px; }
.sub label { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--ink-soft); }
.sub input { width: 6em; font-size: 20px; padding: 6px 10px; font-variant-numeric: tabular-nums; }
.chip { font-size: 14px; font-weight: 700; color: var(--sea); background: var(--sea-soft); border-radius: 999px; padding: 3px 12px; font-variant-numeric: tabular-nums; }
.chip.hit { background: var(--sea); color: var(--sheet); }
.when-head { font-size: 13px; letter-spacing: .14em; font-weight: 700; color: var(--gold); margin: 6px 0 -6px; }
.minus { border: 2px solid var(--line); background: var(--sheet); color: var(--ink-soft); border-radius: 999px; padding: 3px 12px; font-size: 14px; font-weight: 700; cursor: pointer; }
.item[aria-pressed="true"] .box.n { font-size: 18px; font-weight: 700; }
.med .seg { font-size: 15px; letter-spacing: .14em; font-weight: 700; color: var(--cover-gold); min-height: 1.6em; }
.timer-btn { border: 2px solid var(--sea); background: var(--sheet); color: var(--sea); border-radius: 999px; padding: 6px 16px; font-size: 16px; font-weight: 700; cursor: pointer; }
.cheer { background: var(--gold-soft); border: 2px solid var(--gold); border-radius: 14px; padding: 16px 18px; text-align: center; }
.cheer p { font-size: 22px; font-weight: 700; }
.cheer small { display: block; margin-top: 4px; font-size: 15px; color: var(--ink-soft); }

/* Inner check */
.inner { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; gap: 14px; }
.scale { display: flex; flex-direction: column; gap: 6px; }
.scale-head { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; }
.scale-head span { font-weight: 500; color: var(--ink-soft); font-size: 13px; }
.dots5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.dots5 button { height: 46px; border-radius: 12px; border: 2px solid var(--line); background: var(--sheet); color: var(--ink); font-size: 18px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.dots5 button[aria-pressed="true"] { background: var(--sea); border-color: var(--sea); color: var(--sheet); }
.inner textarea { width: 100%; min-height: 64px; padding: 10px 12px; font-size: 17px; resize: vertical; }

/* Week */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { text-align: center; font-size: 13px; color: var(--ink-soft); }
.dot { margin: 4px auto 0; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; position: relative; }
.dot.full { background: var(--sea); border-color: var(--sea); color: var(--sheet); }
.dot.part { background: var(--sea-soft); border-color: var(--sea); }
.dot.today { outline: 2px solid var(--gold); outline-offset: 2px; }
.dot .tr { position: absolute; right: -4px; top: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 2px solid var(--paper); }
.legend { font-size: 13px; color: var(--ink-soft); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); margin-right: 4px; vertical-align: 0; }

/* Review */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--sea-soft); padding: 4px; border-radius: 12px; }
.tab { font-size: 17px; font-weight: 700; padding: 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--sheet); color: var(--sea); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chart-card { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 10px; }
.chart-card h4 { margin: 0; font-size: 16px; }
.sum { margin: 2px 0 8px; font-size: 15px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.sum b { color: var(--sea); font-size: 18px; }
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-card svg text { fill: var(--ink-soft); font-family: var(--font-ui); font-size: 11px; }
.empty { margin: 8px 0 6px; padding: 18px 12px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; font-size: 15px; color: var(--ink-soft); }
.key { display: flex; gap: 14px; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.key i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: 4px; margin-right: 5px; }

/* Feedback */
.fb { background: var(--sheet); border: 1px solid var(--line); border-left: 6px solid var(--gold); border-radius: 4px 14px 14px 4px; padding: 16px 18px; }
.fb textarea { width: 100%; min-height: 88px; padding: 10px 12px; font-size: 17px; resize: vertical; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-size: 18px; font-weight: 700; cursor: pointer; background: var(--sea); color: var(--sheet); }
.btn.ghost { background: transparent; color: var(--sea); border: 2px solid var(--sea); }
.btn.small { font-size: 15px; padding: 6px 12px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.fb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fb-list li { border-top: 1px solid var(--line); padding-top: 10px; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-list time { display: block; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Promise */
.promise { border-top: 1px solid var(--line); padding-top: 18px; }
.promise blockquote { margin: 0; font-family: var(--font-book); font-size: 19px; line-height: 1.8; }
.next b { color: var(--sea); }

/* Cover */
.cover { position: fixed; inset: 0; z-index: 50; background: var(--cover-bg); color: var(--cover-ink); display: flex; flex-direction: column; justify-content: space-between; padding-top: calc(28px + env(safe-area-inset-top, 0px)); padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); transition: opacity .45s, transform .45s; }
.cover.open { opacity: 0; transform: translateX(-24px); pointer-events: none; }
.cover-inner { max-width: 420px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; border: 1px solid color-mix(in srgb, var(--cover-gold) 55%, transparent); border-radius: 4px; padding: 28px 22px; }
.cv-label { font-size: 12px; letter-spacing: .32em; color: var(--cover-gold); font-weight: 700; }
.cv-title { margin-top: 10px; font-family: var(--font-book); font-weight: 800; font-size: 40px; line-height: 1.15; }
.cv-mid { display: flex; flex-direction: column; gap: 10px; }
.cv-mark { width: 120px; height: 120px; border-radius: 26px; box-shadow: 0 6px 20px rgba(0,0,0,.25); margin-bottom: 8px; }
.cv-chapter { font-family: var(--font-book); font-size: 22px; color: var(--cover-gold); }
.cv-goal { font-family: var(--font-book); font-size: 19px; line-height: 1.7; }
.cv-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.cv-name { font-size: 22px; font-weight: 700; }
.cv-shop { font-size: 12px; letter-spacing: .24em; opacity: .75; }
.cv-open { margin: 20px auto 0; max-width: 420px; width: 100%; font-size: 20px; font-weight: 700; padding: 16px; border-radius: 14px; border: 0; cursor: pointer; background: var(--cover-gold); color: var(--cover-bg); }

/* Meditation timer */
.med { position: fixed; inset: 0; z-index: 60; background: var(--cover-bg); color: var(--cover-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; text-align: center; padding-top: calc(24px + env(safe-area-inset-top, 0px)); padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.med svg { width: min(68vw, 260px); height: auto; }
.med .ring-bg { fill: none; stroke: color-mix(in srgb, var(--cover-ink) 18%, transparent); stroke-width: 6; }
.med .ring { fill: none; stroke: var(--cover-gold); stroke-width: 6; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s linear; }
.med .left { fill: var(--cover-ink); font-family: var(--font-ui); font-size: 30px; font-weight: 700; }
.med .cue { font-family: var(--font-book); font-size: 22px; line-height: 1.7; min-height: 3.4em; max-width: 22em; transition: opacity .6s; }
.med .ops { display: flex; gap: 12px; }
.med button { border-radius: 999px; padding: 12px 24px; font-size: 18px; font-weight: 700; cursor: pointer; border: 2px solid var(--cover-gold); background: transparent; color: var(--cover-ink); }
.med button.main { background: var(--cover-gold); color: var(--cover-bg); }

/* Save bar + toast */
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: color-mix(in srgb, var(--paper) 92%, transparent); border-top: 1px solid var(--line); padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); backdrop-filter: blur(6px); }
.savebtn { display: block; width: 100%; max-width: 448px; margin: 0 auto; font-size: 20px; font-weight: 700; padding: 14px; border-radius: 14px; cursor: pointer; border: 2px solid var(--sea); background: var(--sheet); color: var(--sea); transition: background .2s, color .2s; }
.savebtn.dirty { background: var(--gold); border-color: var(--gold); color: var(--sheet); }
.savebtn.busy { opacity: .7; cursor: progress; }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--paper); padding: 12px 22px; border-radius: 999px; font-size: 18px; font-weight: 700; transition: opacity .25s, transform .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; z-index: 70; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Gate screens: login, consent, waiting */
.gate { max-width: 440px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 40px 40px; display: flex; flex-direction: column; gap: 18px; }
.gate .mark { width: 88px; height: 88px; border-radius: 20px; }
.gate h1 { margin: 0; font-family: var(--font-book); font-weight: 800; font-size: 28px; line-height: 1.4; }
.gate p { font-size: 16px; color: var(--ink-soft); }
.gate input[type=email], .gate input[type=text] { width: 100%; padding: 12px 14px; font-size: 18px; }
.gate .btn { width: 100%; }
.gate .err { color: var(--ink); background: var(--gold-soft); border: 1px solid var(--gold); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
.consent { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; font-size: 15px; line-height: 1.8; }
.consent h2 { font-size: 17px; margin: 0 0 6px; }
.consent ul { margin: 0; padding-left: 1.2em; }
.goal90 { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--cover-ink) 10%, transparent); font-size: 16px; line-height: 1.6; }
.goal90 span { display: block; font-size: 12px; letter-spacing: .14em; color: var(--cover-gold); font-weight: 700; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-soft); }
.linkbtn { background: none; border: 0; color: var(--sea); font-weight: 700; cursor: pointer; padding: 4px 0; font-size: 14px; }

/* Form fields (shared by login, app and admin) */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-soft); font-weight: 700; min-width: 0; }
.field input, .field textarea, .field select { padding: 8px 10px; font-size: 16px; font-weight: 500; width: 100%; }
.field textarea { min-height: 70px; resize: vertical; }
.hrow { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.hrow .row > .field { flex: 1 1 8em; }
