/* HABIT DESIGN 2.0 — EXECUTIVE BLACK & GOLD */
:root {
  --bg: #0b0b0c;
  --surface: #131314;
  --surface-2: #1a1a1b;
  --line: #262420;
  --line-soft: #1e1d1a;
  --text: #ece8df;
  --sub: #c2b9aa;
  --faint: #a29a8b;
  --gold: #c2a56a;
  --gold-soft: #a68b55;
  --gold-deep: #6e5b36;
  --gold-wash: rgba(194, 165, 106, .1);
  --danger: #c48272;
  --radius: 18px;
  --radius-control: 12px;
  --motion-fast: 180ms;
  --motion: 220ms;
  --motion-line: 260ms;
  --mechanism-draw: 520ms;
  --ease: ease-out;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Hiragino Sans", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 16px/1.6 var(--sans); letter-spacing: .01em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 1.5px solid var(--gold); outline-offset: 3px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + 8px) 22px calc(96px + var(--safe-b)); }
#main { outline: none; }

/* ---------- Top ---------- */
#top { display: flex; align-items: center; justify-content: space-between; min-height: 56px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-text { display: flex; flex-direction: column; gap: 4px; }
.logo-mark { flex: none; border-radius: 9px; background: radial-gradient(circle at 30% 20%, #252321, #0c0c0c); box-shadow: inset 0 0 0 1px #2a2722; padding: 0; }
.brand-tag { margin-left: 10px; font: 500 9.5px/1 var(--display); letter-spacing: .22em; color: var(--gold-soft); }
.brand-name { font: 500 13px/1 var(--display); letter-spacing: .34em; color: var(--gold); }
.brand-line { font-size: 12px; color: var(--faint); letter-spacing: .12em; }
.top-title { font-size: 15px; color: var(--sub); }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--sub); transition: color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease); }
.icon-btn:hover, .icon-btn:active { color: var(--gold); background: var(--gold-wash); }
.icon-btn-space { width: 44px; }

/* ---------- Bottom nav ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; gap: 0;
  padding: 8px 0 calc(8px + var(--safe-b));
  background: #10100f;
  border-top: 1px solid var(--line-soft);
}
#nav:empty { display: none; }
#nav a { position: relative; flex: 0 1 140px; display: grid; justify-items: center; align-content: center; gap: 4px;
  min-height: 44px; padding: 4px 0; color: var(--faint); font-size: 12px; letter-spacing: .08em;
  transition: color var(--motion-fast) var(--ease); }
#nav a.active { color: var(--gold); }
#nav a.active::before { content: ""; position: absolute; top: -9px; width: 27px; height: 1px; background: var(--gold); }

/* ---------- Type ---------- */
.page-title { font: 500 29px/1.35 var(--mincho); letter-spacing: .04em; overflow-wrap: anywhere; margin: 0 0 6px; }
.page-intro { margin-bottom: 17px; }
.page-intro .page-title { font-size: 34px; }
.page-intro strong { color: var(--text); font-weight: 600; }
.section { margin-top: 34px; }
.section-title { font-size: 15px; font-weight: 600; letter-spacing: .10em; color: var(--text); margin: 0 0 13px; }
.sub-title { font-size: 13px; font-weight: 500; color: var(--sub); margin: 22px 0 10px; letter-spacing: .06em; display: flex; gap: 10px; align-items: baseline; }
.sub-title .count { color: var(--faint); font-weight: 400; }
.sub { color: var(--sub); font-size: 14px; margin: 0; }
.fine { color: var(--faint); font-size: 12.5px; line-height: 1.7; margin: 8px 0 0; }
.fine.warn { color: var(--gold-soft); }
.center { text-align: center; justify-content: center; }
.eyebrow { font-size: 12px; color: var(--gold-soft); letter-spacing: .18em; margin: 0 0 8px; }
.empty { padding: 48px 0; text-align: center; line-height: 2; }

/* ---------- Streak numbers ---------- */
.streak { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 4px; }
.num { font: 400 60px/.98 var(--serif); letter-spacing: -.027em; font-variant-numeric: lining-nums tabular-nums; color: var(--text); }
.streak.big .num { font-size: clamp(64px, 16vw, 80px); }
.streak.mid .num { font-size: 48px; }
.unit { font-size: 14px; color: var(--sub); letter-spacing: .1em; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0; font-size: 13.5px; color: var(--sub); margin: 6px 0 0; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--gold-deep); margin: 0 10px; }

/* ---------- Home ---------- */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); margin: -4px 0 26px; padding: 14px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.summary div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.summary div + div { border-left: 1px solid var(--line-soft); }
.s-num { font: 400 29px/1.1 var(--serif); font-variant-numeric: lining-nums tabular-nums; color: var(--text); }
.s-num small { font-size: 13px; color: var(--faint); margin-left: 2px; }
.s-num.gold { color: var(--gold); }
.s-label { font-size: 12px; color: var(--sub); letter-spacing: .07em; }
.home-section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head .section-title { margin: 0; }
.section-note { font-size: 11.5px; color: var(--faint); letter-spacing: .04em; }
.empty-line { font-size: 13.5px; line-height: 1.8; padding: 6px 0; color: var(--faint); }

/* ---------- Habit cards ---------- */
.cards { display: grid; gap: 12px; }
.habit-card {
  display: block; position: relative; border-radius: var(--radius);
  background: linear-gradient(155deg, #1b1916, var(--surface) 48%);
  border: 1px solid #393126;
  box-shadow: 0 12px 28px -19px #000;
}
.habit-card::before {
  content: ""; position: absolute; top: -1px; left: 19px; width: 56px; height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent); pointer-events: none;
}
.habit-card.is-paused .num { color: var(--sub); }
.habit-main { display: block; padding: 17px 18px 13px; border-radius: var(--radius) var(--radius) 0 0; }
.card-head, .hall-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head > svg { flex: none; color: var(--gold-soft); }
.habit-name { font-size: 18px; font-weight: 620; margin: 0; line-height: 1.5; letter-spacing: .025em; overflow-wrap: anywhere; }
.card-head .habit-name { flex: 1; }
.pill { flex: none; font-size: 11px; color: var(--sub); padding: 2px 7px; border-radius: 10px; background: var(--surface-2); }
.card-body { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 5px 12px; margin-top: 7px; }
.card-body .streak { margin: 0; }
.card-body .num { font-size: 62px; color: var(--gold); }
.card-record { color: var(--sub); font-size: 12px; }
.card-support { padding: 12px 18px 9px; border-top: 1px solid var(--line-soft); }
.card-support-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 5px; }
.card-support-head h3 { margin: 0; font-size: 13px; font-weight: 550; }
.card-support-head > span, .card-hint { color: var(--faint); font-size: 12px; }
.card-hint { margin: 0; }
.card-mechs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.card-mech-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; }
.mini-type { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.mini-type.t-action { background: var(--gold-soft); }
.mini-type.t-automation { background: transparent; box-shadow: inset 0 0 0 1px var(--gold-soft); }
.cm-name { color: var(--sub); line-height: 1.6; overflow-wrap: anywhere; }
.cm-state { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cm-state.streak { color: var(--sub); margin: 0; }
.card-more { display: inline-flex; width: fit-content; gap: 3px; align-items: center; min-height: 44px; margin-left: 13px; color: var(--gold); }
.card-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 3px 14px 7px 18px; color: var(--faint); font-size: 11.5px;
}
.card-fail {
  min-height: 44px; padding: 4px 12px; border-radius: var(--radius-control);
  color: var(--sub); font-size: 13px; font-weight: 560; transition: background var(--motion-fast) var(--ease);
}
.card-fail:active { background: var(--surface-2); }
.hall-card { padding: 17px 18px 18px; }
.hall-card .num { color: var(--gold); font-size: 55px; }
.hall-card .eyebrow { margin-bottom: 4px; color: var(--gold); font-size: 11.5px; letter-spacing: .07em; }
.hall-symbol {
  position: relative; display: grid; place-items: center; flex: none; width: 46px; height: 46px;
  border-radius: 50%; color: var(--gold); border: 1px solid var(--gold-deep); background: var(--gold-wash);
}
.hall-foil {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  color: #fff0c7; filter: drop-shadow(0 0 3px var(--gold)); animation: hall-foil var(--motion-line) var(--ease) both;
}
.just-inducted .hall-date { display: inline-block; animation: hall-stamp var(--motion-line) var(--ease) both; }
@keyframes hall-foil {
  from { clip-path: inset(0 100% 0 0); opacity: 0; }
  24% { opacity: 1; }
  to { clip-path: inset(0 0 0 100%); opacity: 0; }
}
@keyframes hall-stamp {
  from { opacity: .35; transform: translateY(-3px) scale(1.06); }
  70% { text-shadow: 0 0 7px var(--gold); }
  to { opacity: 1; transform: none; text-shadow: none; }
}

/* Regular habits */
.regular-list { list-style: none; margin: 0; padding: 0 16px; border-radius: 16px; background: #111111; box-shadow: inset 0 0 0 1px var(--line-soft); }
.regular-list li + li { border-top: 1px solid var(--line-soft); }
.regular-row { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.rr-name { flex: 1; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-streak { font-size: 12px; color: var(--sub); white-space: nowrap; }
.rr-streak b { font: 300 18px/1 var(--display); color: var(--text); margin-right: 3px; font-variant-numeric: tabular-nums; }

/* Add area */
.add-area { display: grid; gap: 4px; margin-top: 6px; }
.add-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 16px 12px; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--gold-deep); background: linear-gradient(180deg, rgba(194, 165, 106, .07), rgba(194, 165, 106, .02)); transition: background var(--motion-fast) var(--ease); }
.add-btn:active { background: rgba(194, 165, 106, .12); }
.add-title { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; color: var(--gold); letter-spacing: .08em; }
.add-note { display: inline-flex; align-items: center; font-size: 12px; color: var(--sub); }
.add-note b { color: var(--text); font-weight: 500; margin: 0 2px; }

/* Choice (new habit) */
.choice { display: grid; gap: 8px; }
.choice-item { position: relative; display: block; cursor: pointer; }
.choice-item input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.choice-item > span { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); transition: background var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease); }
.choice-item b { font-weight: 500; font-size: 15px; }
.choice-item small { font-size: 12px; color: var(--faint); }
.choice-item input:checked + span { box-shadow: inset 0 0 0 1.5px var(--gold); background: var(--gold-wash); }
.choice-item input:checked + span b { color: var(--gold); }
.choice-item.disabled { opacity: .45; cursor: default; }

.link-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--gold); font-size: 14px; letter-spacing: .04em; }
.link-btn.quiet { color: var(--sub); }
.link-btn.danger { color: var(--danger); }
.link-btn.center { width: 100%; }

.home-foot { margin-top: 22px; display: grid; gap: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 22px; border-radius: 14px;
  background: linear-gradient(180deg, #cdb178, #b0924f); color: #15120b;
  font-weight: 600; font-size: 15px; letter-spacing: .08em;
  transition: transform var(--motion-fast) var(--ease), filter var(--motion-fast) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn:disabled { filter: grayscale(.6) brightness(.7); }
.btn.ghost { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-deep); }
.btn.outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); width: 100%; font-weight: 500; }
.btn.outline .slot { color: var(--faint); font-size: 12px; font-weight: 400; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px #4d3029; }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 14px; border-radius: 12px; }

/* ---------- Welcome ---------- */
.welcome { padding: 8px 4px 0; display: grid; gap: 18px; text-align: center; }
.welcome-lead { color: var(--gold-soft); letter-spacing: .2em; font-size: 13px; margin: 0; }
.welcome-title { font: 400 17px/1.8 var(--sans); margin: 0 0 6px; letter-spacing: .06em; color: var(--text); }

/* ---------- Habit page ---------- */
.habit-head { padding-top: 4px; }
.head-actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.head-actions .icon-btn { margin-left: auto; }

/* ---------- Logic tree ---------- */
.tree { position: relative; }
.tree-trunk { position: relative; padding-left: 14px; border-left: 1px solid var(--gold-deep); margin-left: 6px; }
.tree-trunk::before { content: ""; position: absolute; left: -4px; top: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.tree-empty { padding: 4px 0 6px 8px; line-height: 1.9; }
.branch { list-style: none; margin: 0; padding: 0; }
.group { position: relative; margin: 14px 0 4px; }
.group-name { position: relative; margin: 0 0 4px; font-size: 12.5px; color: var(--gold-soft); letter-spacing: .16em; padding-left: 8px; }
.group-name::before { content: ""; position: absolute; left: -14px; top: 50%; width: 14px; height: 1px; background: var(--gold-deep); }
.nested { margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--line); }
.node { position: relative; }
.node::before { content: ""; position: absolute; left: -14px; top: 50%; width: 12px; height: 1px; background: var(--line); }
.branch:not(.nested) > .node::before { background: var(--gold-deep); }
.node-btn { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 52px; padding: 8px 6px 8px 8px; text-align: left; border-radius: 12px; transition: background var(--motion-fast) var(--ease); }
.node-btn:hover, .node-btn:active { background: var(--surface); }
.node-type { width: 7px; height: 7px; }
.node-name { font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.node-state { font-size: 12.5px; color: var(--sub); white-space: nowrap; font-variant-numeric: tabular-nums; }
.node-state.streak { color: var(--gold-soft); }
.node-state.muted, .node.muted .node-name { color: var(--faint); }
.swipe-row {
  --swipe-width: 76px; --swipe-offset: 0px;
  position: relative; overflow: hidden; border-radius: 12px; touch-action: pan-y pinch-zoom;
}
.swipe-row.swipe-open { --swipe-offset: calc(-1 * var(--swipe-width)); }
.swipe-row :focus-visible { outline-offset: -3px; }
.swipe-content { transform: translateX(var(--swipe-offset)); transition: transform var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease); }
.swipe-delete {
  position: absolute; inset: 0 0 0 auto; width: var(--swipe-width); min-height: 44px;
  background: #823a32; color: #fff2e9; font-size: 14px; font-weight: 650;
  pointer-events: none; transform: translateX(calc(100% + var(--swipe-offset))); transition: transform var(--motion-fast) var(--ease);
}
.swipe-open:not(.swipe-dragging) .swipe-delete { pointer-events: auto; }
.swipe-delete:active { background: #6e312a; }
.swipe-dragging :is(.swipe-content, .swipe-delete) { transition: none; }
.tree-add { display: inline-flex; align-items: center; gap: 6px; margin: 10px 0 0 22px; min-height: 44px; color: var(--gold); font-size: 14px; }
.retired { margin-top: 18px; }
.retired summary, .more summary { cursor: pointer; color: var(--faint); font-size: 13px; list-style: none; min-height: 36px; display: flex; align-items: center; gap: 6px; }
.retired summary::before, .more summary::before { content: "＋"; font-size: 11px; color: var(--gold-deep); }
.retired[open] summary::before, .more[open] summary::before { content: "－"; }
summary::-webkit-details-marker { display: none; }
.flat { padding-left: 8px; }
.flat .node::before { display: none; }

/* ---------- Calendar ---------- */
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head span { text-align: center; font-size: 11px; color: var(--faint); padding-bottom: 6px; }
.cal-cell { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.cal-cell.s-auto { background: #17160f; color: var(--sub); box-shadow: inset 0 0 0 1px #2a261b; }
.cal-cell.s-confirmed { background: var(--gold-deep); color: #f2e8d2; }
.cal-cell.s-failure { color: var(--danger); box-shadow: inset 0 0 0 1px #4d3029; }
.cal-cell.s-pending { box-shadow: inset 0 0 0 1px var(--line); color: var(--sub); }
.cal-cell.today { outline: 1px solid var(--gold); outline-offset: 2px; }
.cal-cell.s-off { opacity: .45; }
.cal-legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); margin: 12px 0 0; }
.lg { width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.lg:first-child { margin-left: 0; }
.lg.s-auto { background: #17160f; box-shadow: inset 0 0 0 1px #3a3424; }
.lg.s-confirmed { background: var(--gold-deep); }
.lg.s-failure { box-shadow: inset 0 0 0 1px var(--danger); }

/* ---------- Timeline & lists ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li, .timeline-entry { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; padding: 12px 0; }
.timeline li { border-bottom: 1px solid var(--line-soft); }
.timeline-deletable > li { display: block; padding: 0; }
.timeline-entry { width: 100%; min-height: 44px; text-align: left; overflow-wrap: anywhere; }
.timeline-entry:active { background: var(--surface); }
.hall-history .timeline li { grid-template-columns: 110px minmax(0, 1fr); gap: 12px; }
.timeline time { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tl-text { display: block; margin: 0; font-size: 14.5px; }
.tl-kind { display: block; margin: 2px 0 0; font-size: 12px; color: var(--faint); letter-spacing: .04em; }
.idea-list, .fail-list, .plain { list-style: none; margin: 0 0 8px; padding: 0; }
.idea-list li { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line-soft); }
.idea-list li > span { flex: 1; font-size: 14.5px; }
.plain li { padding: 6px 0; font-size: 14.5px; }
.row-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 0 4px; border-bottom: 1px solid var(--line-soft); text-align: left; font-size: 15px; }
.row-btn .sub { font-size: 12.5px; color: var(--faint); }
.row-btn.danger { color: var(--danger); }
.fail-list .row-btn { justify-content: flex-start; gap: 18px; font-size: 14px; }
.fail-list time { color: var(--faint); min-width: 64px; font-size: 12.5px; }
.link-list { display: grid; }
.effect { margin: 4px 0; font-size: 14px; }
.effect b { font-weight: 500; color: var(--gold); }
.state-line { font-size: 15px; color: var(--sub); margin: 6px 0 14px; }
.state-line.active { color: var(--gold); }

/* ---------- Growth ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 13px 0; margin: 8px 0 0; border-block: 1px solid var(--line); }
.stats div { display: flex; flex-direction: column; gap: 5px; padding: 1px 9px; }
.stats div:first-child { padding-left: 0; }
.stats div + div { border-left: 1px solid var(--line-soft); }
.stats .num { color: var(--gold); font-size: 36px; }
.stats .label { color: #c5c2bb; font-size: 13px; }
.chart { margin: 0 0 10px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linejoin: round; }
.chart .end { fill: var(--gold); }
.chart .ref-line { fill: none; stroke: #aaa8a3; stroke-width: 1.8; stroke-dasharray: 5 4; }
.chart figcaption { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: 6px; }
.reference { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.reference-grid line { stroke: #312e29; stroke-width: 1; }
.reference-grid text { fill: #c5c2bb; font: 11.5px var(--sans); font-variant-numeric: tabular-nums; }
.reference-axis { fill: none; stroke: #635d51; stroke-width: 1; }
.chart-legend { list-style: none; padding: 0; margin: 0 0 9px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.chart-legend li { display: flex; align-items: center; gap: 7px; color: #d2cec5; font-size: 12px; }
.chart-legend li > span { position: relative; display: inline-block; flex: none; width: 22px; border-top: 2px solid var(--gold); }
.chart-legend .legend-actual::after { content: ""; position: absolute; left: 8px; top: -4px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.chart-legend .legend-reference { border-color: #aaa8a3; border-top-style: dashed; }

/* ---------- Settings ---------- */
.settings .section-title { margin-top: 36px; }
.settings .section-title:first-child { margin-top: 0; }
.setting-group { display: grid; }
.kv { margin: 0; display: grid; gap: 0; }
.kv div { display: grid; grid-template-columns: 9em 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; }
.version { margin-top: 40px; text-align: center; }
.notice-block { padding-top: 10vh; display: grid; gap: 14px; }
.stack { display: grid; gap: 10px; margin-top: 18px; }

/* ---------- Sheet ---------- */
#sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh;
  background: #121213; color: var(--text); border-radius: 24px 24px 0 0;
  box-shadow: 0 -1px 0 var(--line), 0 -30px 80px rgba(0, 0, 0, .55);
}
#sheet::backdrop { background: rgba(0, 0, 0, .62); backdrop-filter: blur(2px); }
#sheet[open] { animation: rise var(--motion-line) var(--ease); }
@keyframes rise { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-body { padding: 10px 22px calc(26px + var(--safe-b)); }
.sheet-body::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: #2c2a26; margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.sheet-head h2 { font-size: 18px; font-weight: 500; margin: 0; letter-spacing: .03em; }
.sheet-context { color: var(--gold-soft); font-size: 13px; margin: 0 0 16px; letter-spacing: .04em; }
.sheet-actions { display: grid; gap: 10px; margin-top: 22px; }
.sheet-actions.wrap { display: flex; flex-wrap: wrap; }
.sheet-actions.end { justify-content: flex-end; margin-top: 18px; }
.form-error { color: var(--danger); font-size: 14px; margin: 14px 0 0; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 8px; margin-top: 18px; }
.field > span { font-size: 12.5px; color: var(--sub); letter-spacing: .06em; }
.field input[type=text], .field input:not([type]), .field input[type=date], .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); outline: none; font-size: 16px;
}
.field input[type=date] { -webkit-appearance: none; appearance: none; color-scheme: dark; }
.field input:focus, .field textarea:focus { border-color: var(--gold-deep); }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 15px; border-radius: 20px; font-size: 14px; color: var(--sub); box-shadow: inset 0 0 0 1px var(--line); transition: background var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease); }
.chip input:checked + span { color: #15120b; background: var(--gold); box-shadow: none; }
.chip input:focus-visible + span { outline: 1.5px solid var(--gold); outline-offset: 2px; }
.weekday-pick .chip span { min-width: 40px; justify-content: center; padding: 0; }
.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; font-size: 14.5px; line-height: 1.6; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); margin: 2px 0 0; flex: none; }
.check.row { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.check .sub { font-size: 12.5px; color: var(--faint); }
.more { margin-top: 16px; }

/* Conditional fields */
.when-pick, .when-new, .weekday-pick { display: none !important; }
.field:has(input[value=pick]:checked) .when-pick { display: block !important; }
.field:has(input[value=__new]:checked) .when-new { display: block !important; }
.field:has(input[name=scheduleType][value=weekdays]:checked) .weekday-pick { display: block !important; }
.action-only { display: none; }
form:has(input[name=trackStreak]:checked) .action-only { display: block; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); z-index: 20; transform: translate(-50%, 14px);
  display: flex; align-items: center; gap: 16px; max-width: calc(100% - 32px); width: max-content;
  padding: 12px 18px; border-radius: 14px; background: #1f1e1b; color: var(--text); font-size: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px var(--line);
  opacity: 0; pointer-events: none; transition: opacity var(--motion) var(--ease), transform var(--motion) var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.error { box-shadow: 0 10px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px #5a352c; }
#toast button { color: var(--gold); font-size: 14px; min-height: 32px; white-space: nowrap; }

/* ---------- Larger screens ---------- */
@media (min-width: 900px) {
  #app { max-width: 720px; padding-top: 32px; }
  #sheet { margin: auto; border-radius: 24px; max-height: 86dvh; }
  #sheet .sheet-body::before { display: none; }
  .sheet-body { padding-top: 22px; }
  .timeline li, .timeline-entry { grid-template-columns: 90px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .tree-details::details-content { transition: none !important; }
  .hall-foil, .mechanism-thread { display: none; }
}

.boot { color: var(--sub); text-align: center; padding-top: 30vh; line-height: 2; }

/* ---------- Brand hero (home) ---------- */
:root { --serif: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif; --mincho: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; }
body { --text: #f3efe6; }
#top:has(> .icon-btn-space:first-child) { position: absolute; top: calc(var(--safe-t) + 8px); right: 16px; left: 16px; z-index: 2; margin: 0; }
#app { position: relative; }
.hero {
  position: relative; text-align: center; margin: 0 -22px 12px; padding: 6px 22px 14px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(194, 165, 106, .13), transparent 62%),
    linear-gradient(180deg, #121110 0%, #0b0b0c 100%);
  border-bottom: 1px solid #1f1d19;
}
.hero::after { content: ""; position: absolute; left: 50%; bottom: -1px; width: 96px; height: 1px; transform: translateX(-50%); background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.hero-art { display: block; width: min(56%, 214px); height: auto; margin: 0 auto 4px; overflow: visible; }
.h-base { stroke: #3a3325; stroke-width: 1; }
.h-ticks line { stroke: #4a4030; stroke-width: 1; }
.h-curve { stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 6px rgba(226, 196, 130, .35)); }
.h-dot { fill: #fbf0cf; }
.hb { transform-box: fill-box; transform-origin: 50% 100%; }
.hero-name { margin: 0; font: 400 28px/1.1 var(--serif); letter-spacing: .26em; padding-left: .26em; color: #f6f1e6; }
.hero-tag { margin: 8px 0 0; font: 500 11px/1 var(--display); letter-spacing: .42em; padding-left: .42em; color: var(--gold); }
.hero-rule { width: 28px; height: 1px; margin: 11px auto 10px; background: var(--gold-deep); }
.hero-copy { margin: 0; font: 500 16px/1.6 var(--mincho); letter-spacing: .14em; color: #efe9dc; }
.hero-sub { margin: 4px 0 0; font: 400 12.5px/1.7 var(--sans); letter-spacing: .1em; color: var(--sub); }

/* Launch animation: once per app start, short, never blocks touches. */
.hero.play .h-curve { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hero-draw 1.5s cubic-bezier(.55, 0, .2, 1) .25s forwards; }
.hero.play .hb { transform: scaleY(0); animation: hero-rise .7s cubic-bezier(.2, .8, .2, 1) forwards; animation-delay: calc(.12s + var(--i) * .11s); }
.hero.play .h-dot, .hero.play .h-glow { opacity: 0; animation: hero-fade .5s ease-out 1.6s forwards; }
.hero.play .hero-name, .hero.play .hero-tag, .hero.play .hero-rule, .hero.play .hero-copy, .hero.play .hero-sub { opacity: 0; transform: translateY(6px); animation: hero-in .8s cubic-bezier(.2, .8, .2, 1) forwards; }
.hero.play .hero-name { animation-delay: .35s; }
.hero.play .hero-tag { animation-delay: .5s; }
.hero.play .hero-rule { animation-delay: .6s; }
.hero.play .hero-copy { animation-delay: .7s; }
.hero.play .hero-sub { animation-delay: .8s; }
.hero, .hero * { pointer-events: none; }
@keyframes hero-draw { to { stroke-dashoffset: 0; } }
@keyframes hero-rise { to { transform: scaleY(1); } }
@keyframes hero-fade { to { opacity: 1; } }
@keyframes hero-in { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .hero.play .h-curve { stroke-dashoffset: 0; }
  .hero.play .hb { transform: none; }
  .hero.play * { opacity: 1 !important; transform: none !important; }
}
@media (min-width: 900px) { .hero { margin-left: 0; margin-right: 0; border-radius: 0 0 24px 24px; } }
.hero + .summary { border-top: 0; margin-top: 0; padding-top: 6px; }

/* Hall road */
.road { margin: 0 18px; padding: 11px 0 12px; border-top: 1px solid var(--line-soft); }
.road-head, .road-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.road-title { font-size: 11.5px; letter-spacing: .16em; color: var(--sub); }
.road-count { font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; }
.road-count b { font: 400 15px/1 var(--display); color: var(--text); }
.road-bar { position: relative; height: 5px; margin: 8px 0 7px; border-radius: 2px; background: #24211b; overflow: hidden; }
.road-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: linear-gradient(90deg, #6e5530, #c9a865 70%, #f1dca6); box-shadow: 0 0 8px rgba(226, 196, 130, .35); }
.road-foot span { font-size: 12px; color: var(--faint); }
.road.ready .road-foot span { color: var(--gold-soft); }
.road-btn { flex: none; min-height: 44px; padding: 0 12px; border-radius: 16px; font-size: 12.5px; color: #15120b; background: linear-gradient(180deg, #cdb178, #b0924f); }
/* Rating */
.rating { display: flex; gap: 8px; }
.rate-btn { flex: 1; min-height: 40px; border-radius: 12px; font-size: 13.5px; color: var(--sub); box-shadow: inset 0 0 0 1px var(--line); }
.rate-btn.on { color: #15120b; background: var(--gold); box-shadow: none; }
.rate-btn.on.r-ineffective { color: #f3e1db; background: #6a3a30; }
.rate-btn.on.r-testing { color: var(--text); background: #2a2721; box-shadow: inset 0 0 0 1px var(--gold-deep); }
.tag-bad { font-size: 10.5px; color: var(--danger); margin-right: 8px; }
.snap-count { display: block; font-size: 11.5px; color: var(--faint); }

/* Premium Experience */
.tree-section { margin-top: 26px; }
.tree-details { border-top: 1px solid var(--line); }
.tree-details > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 52px; cursor: pointer; list-style: none; color: var(--text); font-weight: 600; font-size: 15px;
}
.tree-details > summary svg { color: var(--gold); transition: transform var(--motion) var(--ease); }
.tree-details[open] > summary svg { transform: rotate(90deg); }
.tree-details > .tree { margin: 5px 0 1px; }
.tree-details[open] > .tree { animation: page-reveal var(--motion) var(--ease) both; }
.card-support { position: relative; }
.mechanism-thread { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.mechanism-thread path {
  fill: none; stroke: #e9ce92; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; filter: drop-shadow(0 0 3px var(--gold));
  animation: mechanism-thread var(--mechanism-draw) var(--ease) both,
    mechanism-thread-fade var(--motion-fast) var(--ease) var(--mechanism-draw) forwards;
}
.mechanism-added .mini-type, .mechanism-added .node-type { animation: mechanism-highlight var(--motion-fast) var(--ease) var(--mechanism-draw) both; }
@keyframes mechanism-thread {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes mechanism-thread-fade { to { opacity: 0; } }
@keyframes mechanism-highlight {
  55% { box-shadow: 0 0 10px var(--gold); color: var(--text); }
}
@supports (interpolate-size: allow-keywords) and selector(details::details-content) {
  .tree-details::details-content {
    interpolate-size: allow-keywords; block-size: 0; overflow: clip;
    transition: block-size var(--motion) var(--ease), content-visibility var(--motion) allow-discrete;
  }
  .tree-details[open]::details-content { block-size: auto; }
}

.growth-panel {
  background: #141312; border-radius: var(--radius); border: 1px solid #393126;
  padding: 12px 14px 13px;
}
.metric-select {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px;
  border-radius: var(--radius-control); padding: 2px; background: var(--bg);
}
.metric-select button {
  min-height: 44px; border-radius: 10px; padding: 3px 1px; color: #e4e0d7; font-size: 14px;
  font-weight: 600; transition: color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}
.metric-select [aria-pressed="true"] {
  color: var(--gold); background: var(--gold-wash);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.chart-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 13px 0 4px; }
.chart-heading h3 { margin: 0; font-size: 13px; font-weight: 550; }
.chart-value { margin: 0; color: var(--gold); font: 400 36px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.chart-value small { margin-left: 4px; font: 400 12px/1.4 var(--sans); color: var(--sub); }
.actual-chart { margin-bottom: 0; }
.actual-chart .axis { stroke: #332e27; stroke-dasharray: 2 4; }
.actual-chart .line {
  stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0;
  animation: actual-draw var(--motion-line) var(--ease) both;
}
.actual-chart .chart-fill, .actual-chart .end { animation: chart-appear var(--motion-line) var(--ease) both; }
.growth-track { position: relative; touch-action: pan-y pinch-zoom; }
.growth-track:focus-within { outline: 1px solid var(--gold-soft); outline-offset: 4px; border-radius: 6px; }
.growth-track svg { cursor: crosshair; }
.growth-cursor { pointer-events: none; }
.growth-cursor line { stroke: var(--gold-soft); stroke-width: 1; stroke-dasharray: 2 3; }
.cursor-halo { fill: #c2a56a44; }
.cursor-dot { fill: #f7dfaf; stroke: #17130d; stroke-width: 1; }
.growth-readout {
  position: absolute; pointer-events: none; left: clamp(75px, var(--cursor-x), calc(100% - 75px));
  top: var(--cursor-y); transform: translate(-50%, calc(-100% - 9px)); white-space: nowrap;
  border-radius: 9px; background: #1b1812; border: 1px solid var(--gold-deep); padding: 4px 8px;
  color: #ded4c4; font-size: 11.5px; font-variant-numeric: tabular-nums;
  animation: chart-appear var(--motion-fast) var(--ease) both;
}
.growth-readout.below { transform: translate(-50%, 9px); }
.growth-readout strong { margin-left: 8px; color: #efce8b; font-size: 13px; }
.chart-note { margin: 9px 0 0; font-size: 12px; }
.chart-empty { display: grid; gap: 13px; padding: 14px 4px 7px; justify-items: start; }
.hall-empty { padding: 17px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hall-empty .section-title { margin-bottom: 6px; }
.hall-targets { display: flex; flex-wrap: wrap; gap: 9px 23px; margin: 16px 0 10px; }
.hall-targets dt { color: var(--sub); font-size: 13px; }
.hall-targets dd { margin: 2px 0 0; color: var(--gold); font-size: 17px; font-weight: 600; }
.hall-confirmation, .hall-candidate .sub { font-size: 13px; }
.hall-confirmation strong { color: var(--text); }
.hall-candidate { border-top: 1px solid var(--line); margin-top: 17px; padding-top: 13px; }
.hall-candidate h3 { font-size: 13px; margin: 0; }
.hall-candidate a { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 6px; color: var(--gold); }
.hall-candidate a svg { flex: none; }
.chart-empty .btn { min-height: 44px; }
.chart-select { display: flex; align-items: center; gap: 10px; color: var(--sub); font-size: 13px; }
.chart-select select {
  flex: 1; min-width: 0; min-height: 44px; padding: 5px 7px; border-radius: var(--radius-control);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font-size: 16px;
}
.link-btn.reference-toggle {
  min-height: 44px; margin-top: 10px; padding: 5px 12px; border: 1px solid var(--gold);
  border-radius: var(--radius-control); color: var(--gold); font-size: 14px; font-weight: 600;
}

#toast.success, #toast.milestone { box-shadow: 0 10px 32px #0008, inset 0 0 0 1px var(--gold-deep); }
#toast.calm { box-shadow: 0 10px 32px #0008, inset 0 0 0 1px #4b4439; }
.toast-mark {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
  color: var(--gold); background: var(--gold-wash);
}
#toast.show .toast-mark { animation: feedback-mark var(--motion) var(--ease) both; }
#toast button { min-height: 44px; }
.view-enter[data-view="habits"] .habit-card,
.view-enter:not([data-view="habits"]) > :is(.page-intro, .habit-head, .cards, .section, .stats) {
  animation: page-reveal var(--motion) var(--ease) both;
}
.view-enter .road-bar > span { transform-origin: left; animation: progress-in var(--motion-line) var(--ease) both; }
.streak-increase { display: inline-block; animation: streak-lift var(--motion) var(--ease) both; }
@keyframes page-reveal { from { opacity: .8; transform: translateY(5px); } }
@keyframes progress-in { from { transform: scaleX(.8); } }
@keyframes actual-draw { from { stroke-dashoffset: 1; } }
@keyframes chart-appear { from { opacity: 0; } }
@keyframes feedback-mark { from { opacity: .5; transform: scale(.82); } }
@keyframes streak-lift { from { opacity: .55; transform: translateY(4px); } }
