/* ============================================================
   Yoining — a listening room that tunes itself to your moment.
   One committed dark theme: ink ground, warm paper text,
   and an accent that changes with the mode (set from JS).
   ============================================================ */
:root {
  --bg: #0a0c13;
  --bg-2: #10131c;
  --bg-3: #171b27;
  --surface: rgba(236, 231, 219, 0.04);
  --surface-2: rgba(236, 231, 219, 0.08);
  --line: rgba(236, 231, 219, 0.10);
  --line-2: rgba(236, 231, 219, 0.20);
  --ink: #ece7db;
  --ink-2: #b1aca1;
  --ink-3: #7c8193;
  --accent: #e3b566;
  --accent-ink: #1b1508;
  --glow: rgba(227, 181, 102, 0.22);
  --chart-grid: rgba(236, 231, 219, 0.08);
  --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --font-jp: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif JP', serif;
  --font-body: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
svg { display: block; }
h1, h2, p { margin: 0; }

/* ---------- atmosphere ---------- */
#atmosphere { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; }
.vignette {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 30% 35%, rgba(10,12,19,0) 30%, rgba(10,12,19,.55) 75%, rgba(10,12,19,.92) 100%);
}

/* ---------- app frame ---------- */
.app {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
}
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 19, .7);
}
.wordmark { display: flex; align-items: baseline; flex: none; white-space: nowrap; text-decoration: none; color: inherit; }
.wordmark .name { font-family: var(--font-display); font-style: italic; font-weight: 300; font-size: 25px; letter-spacing: .01em; line-height: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }

.circadian {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 8px;
  border: 1px solid var(--line); border-radius: 999px;
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); letter-spacing: .04em; font-variant-numeric: tabular-nums;
}
.circadian svg { width: 18px; height: 18px; }
.circadian .ring { fill: none; stroke: var(--line-2); stroke-width: 1.2; }
.circadian .horizon { stroke: var(--line-2); stroke-width: 1; }
.circadian .dot { fill: var(--accent); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-2);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em;
  transition: border-color .2s, color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); background: var(--surface); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---------- stage ---------- */
.stage {
  position: relative; min-height: 0; overflow: auto;
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: clamp(24px, 4vw, 52px) clamp(24px, 5vw, 72px) clamp(24px, 4vw, 44px);
}
.stage-top { display: flex; flex-direction: column; gap: 22px; }
.eyebrow {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; color: var(--ink-3);
}
.eyebrow::before { content: ''; width: 22px; height: 1px; background: var(--line-2); flex: none; }
.mode-title { display: flex; flex-direction: column; gap: 6px; }
.mode-title .primary { font-size: clamp(64px, 9.5vw, 132px); line-height: .98; font-weight: 500; text-wrap: balance; }
.mode-title .primary.jp { font-family: var(--font-jp); letter-spacing: .06em; }
.mode-title .primary.en { font-family: var(--font-display); font-weight: 300; letter-spacing: -.01em; }
.mode-title .secondary { font-size: clamp(18px, 2.2vw, 28px); color: var(--ink-2); }
.mode-title .secondary.en { font-family: var(--font-display); font-style: italic; font-weight: 300; }
.mode-title .secondary.jp { font-family: var(--font-jp); letter-spacing: .12em; }
.mode-desc { color: var(--ink-2); max-width: 44ch; font-size: 15px; }
.scene {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .04em; color: var(--ink-2);
  font-variant-numeric: tabular-nums; min-height: 1.6em;
}
.scene b { color: var(--ink); font-weight: 500; }
.scene .dot { color: var(--ink-3); padding: 0 .55em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-2); letter-spacing: .02em; font-variant-numeric: tabular-nums;
}
.chip.live { border-color: var(--accent); color: var(--ink); }
.chip.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.modes { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-btn {
  position: relative; display: inline-flex; align-items: baseline; gap: 8px; padding: 9px 16px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(10,12,19,.35); color: var(--ink-2);
  transition: border-color .25s, color .25s, background .25s, box-shadow .25s;
}
.mode-btn .jp { font-family: var(--font-jp); font-size: 16px; letter-spacing: .08em; }
.mode-btn .en { font-family: var(--font-display); font-style: italic; font-size: 13px; opacity: .8; }
.mode-btn .hint { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; color: var(--accent); margin-left: 2px; }
.mode-btn:hover { border-color: var(--line-2); color: var(--ink); }
.mode-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); background: var(--glow); box-shadow: 0 0 24px var(--glow); }

/* ---------- transport ---------- */
.stage-bottom { display: flex; flex-direction: column; gap: 20px; }
.transport { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.play {
  width: 80px; height: 80px; border-radius: 50%; border: 0; flex: none;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset, 0 10px 50px var(--glow);
  transition: transform .2s var(--ease), box-shadow .3s, background .3s;
}
.play:hover { transform: scale(1.04); }
.play:active { transform: scale(.98); }
.play svg { width: 30px; height: 30px; }
.play .ic-pause { display: none; }
.play[aria-pressed="true"] .ic-play { display: none; }
.play[aria-pressed="true"] .ic-pause { display: block; }
.transport-meta { display: flex; flex-direction: column; gap: 4px; }
.elapsed { font-family: var(--font-mono); font-size: 30px; letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.elapsed .remaining { color: var(--ink-3); font-size: 15px; margin-left: 12px; }
.status-line { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); letter-spacing: .04em; }
.meter { width: 168px; height: 30px; margin-left: auto; }

/* ---------- breath ---------- */
.breath { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; padding-top: 8px; }
.breath-ring-wrap { width: 210px; height: 210px; display: grid; place-items: center; }
.breath-ring {
  width: 190px; height: 190px; border-radius: 50%; border: 1px solid var(--accent);
  box-shadow: inset 0 0 40px var(--glow), 0 0 60px var(--glow);
  transform: scale(var(--breath, .6));
  transition-property: transform; transition-duration: 4s; transition-timing-function: cubic-bezier(.45, .05, .55, .95);
  display: grid; place-items: center;
}
.breath-ring .phase { font-family: var(--font-jp); font-size: 24px; letter-spacing: .14em; }
.breath-ring .phase.en { font-family: var(--font-display); font-style: italic; font-size: 22px; letter-spacing: 0; }
.breath-meta { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.breath-count { font-family: var(--font-mono); font-size: 44px; font-variant-numeric: tabular-nums; line-height: 1; }
.breath-desc { color: var(--ink-2); max-width: 36ch; font-size: 14px; }

/* ---------- console ---------- */
.console {
  position: relative; min-height: 0; overflow-y: auto;
  border-left: 1px solid var(--line); background: rgba(10, 12, 19, .82);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.section { padding: 22px 26px 24px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; }
.section-label {
  display: flex; align-items: baseline; justify-content: space-between;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3);
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 32px; }
.row .label { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row .label .name { font-size: 14px; font-weight: 500; }
.row .label .hint { font-size: 12px; color: var(--ink-3); line-height: 1.45; }
.readout { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink); letter-spacing: .02em; }
.readout.muted { color: var(--ink-3); }
.field { display: flex; flex-direction: column; gap: 10px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.field-head .readout { font-size: 12px; }
.note { font-size: 12px; color: var(--ink-3); line-height: 1.5; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 13px;
  transition: background .2s, color .2s, border-color .2s;
}
.seg button:hover { border-color: var(--line-2); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg button.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }

.text-btn {
  border: 1px solid var(--line-2); background: transparent; color: var(--ink); padding: 7px 14px; border-radius: 999px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; white-space: nowrap;
  transition: background .2s, border-color .2s, opacity .2s;
}
.text-btn:hover { background: var(--surface-2); }
.text-btn:disabled { opacity: .5; cursor: default; }
.text-btn svg { width: 14px; height: 14px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
input[type="range"]:focus { outline: none; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0 var(--fill, 50%), var(--line-2) var(--fill, 50%) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 0; margin-top: -6px;
  box-shadow: 0 0 0 4px rgba(10,12,19,.85); transition: transform .15s;
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-2); border-radius: 2px; }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 0; }

.switch {
  position: relative; width: 40px; height: 22px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; flex: none; padding: 0;
  transition: background .2s, border-color .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2);
  transition: transform .2s var(--ease), background .2s;
}
.switch[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-pressed="true"]::after { transform: translateX(18px); background: var(--accent-ink); }

.hr-value { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.hr-value .num { font-size: 26px; line-height: 1; }
.hr-value .unit { font-size: 11px; color: var(--ink-3); letter-spacing: .1em; }
.hr-value .beat { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); align-self: center; opacity: .35; }
.hr-value.live .beat { opacity: 1; box-shadow: 0 0 8px var(--accent); } /* static: a live sensor is shown by a lit dot, not a looping pulse */

/* ---------- sheets ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(6, 8, 12, .8);
}
.sheet-card {
  width: min(760px, 100%); max-height: min(88dvh, 900px); overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 28px 30px 30px;
  display: flex; flex-direction: column; gap: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sheet-head h2 { font-family: var(--font-jp); font-weight: 500; font-size: 24px; letter-spacing: .1em; }
.sheet-head h2.en { font-family: var(--font-display); font-weight: 300; letter-spacing: 0; font-size: 28px; }
.close-btn { border: 1px solid var(--line); background: transparent; color: var(--ink-2); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.close-btn:hover { color: var(--ink); border-color: var(--line-2); }
.close-btn svg { width: 14px; height: 14px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.tile { background: var(--bg-2); padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 6px; }
.tile .num { font-family: var(--font-display); font-weight: 300; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .num small { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); margin-left: 4px; letter-spacing: .08em; }
.tile .lbl { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

.chart-block { display: flex; flex-direction: column; gap: 10px; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--ink-2); }
.chart-title .readout { font-size: 12px; color: var(--ink-3); }
.chart { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .base { stroke: var(--line-2); stroke-width: 1; }
.chart .bar { fill: var(--accent); opacity: .8; transition: opacity .15s; }
.chart .bar.empty { fill: var(--line-2); opacity: 1; }
.chart .bar.today { opacity: 1; }
.chart .lbl { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-3); letter-spacing: .06em; }
.chart .lbl.today { fill: var(--ink); }
.chart .val { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-2); }
.chart .hit { fill: transparent; }
.tooltip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 6px 10px; font-family: var(--font-mono); font-size: 12px; color: var(--ink); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px)); box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; }
.stack span { display: block; height: 100%; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--ink-2); padding: 0; margin: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.legend .readout { font-size: 12px; }
.empty { color: var(--ink-3); font-size: 14px; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.about p { color: var(--ink-2); max-width: 62ch; }
.about .lead { color: var(--ink); font-size: 17px; }
.about ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.about li { display: grid; grid-template-columns: 96px 1fr; gap: 14px; font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.about li b { font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); padding-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 40;
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 999px; padding: 10px 18px;
  font-size: 13px; color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; max-width: min(92vw, 560px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto auto; height: auto; min-height: 100dvh; }
  .stage { min-height: calc(100dvh - 68px); overflow: visible; }
  .console { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .breath { grid-template-columns: 1fr; justify-items: start; }
  .meter { margin-left: 0; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .circadian .txt { display: none; }
}
@media (max-width: 600px) {
  .circadian { display: none; }
  .icon-btn { width: 36px; padding: 0; gap: 0; }
  .icon-btn span { display: none; }
  .icon-btn.lang { width: auto; padding: 0 12px; }
  .icon-btn.lang span, .icon-btn.lang { display: inline-flex; }
  .wordmark .name { font-size: 22px; }
}
@media (max-width: 520px) {
  .mode-title .primary { font-size: 64px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .transport { gap: 16px; }
  .elapsed { font-size: 24px; }
  .about li { grid-template-columns: 1fr; gap: 4px; }
  .sheet-card { padding: 22px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
