/* 瞑想村 — spirit.manabu-letter.com
   夜の村。藍鼠の地に、元気玉の金。見出しは明朝、UIは角ゴシック。
   CSPで inline style を許していないので、装飾はすべてここに置く。
   （JS から触るのは el.style.<prop> だけ。style属性の文字列代入はCSPに弾かれる） */

:root {
  --ground:      #0e1220;
  --surface:     #161c2e;
  --surface-alt: #1e2537;
  --ink:         #e8ecf5;
  --ink-soft:    #aeb8cc;
  --muted:       #737f99;
  --line:        #28304a;
  --line-soft:   #1d2437;
  --ai:          #8fb0d4;
  --sun:         #e0b45f;
  --sun-deep:    #b8862f;
  --ok:          #6aa886;
  --err:         #d98f86;

  --mincho: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, serif;
  --gothic: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --mono:   ui-monospace, "SF Mono", Menlo, monospace;

  --t-xs: 0.6875rem;
  --t-s:  0.8125rem;
  --t-m:  0.9375rem;
  --t-l:  1.0625rem;
  --t-xl: 1.375rem;
  --r: 4px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--gothic);
  font-size: var(--t-m);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: 24px 20px calc(48px + env(safe-area-inset-bottom));
}

.loading { color: var(--muted); text-align: center; padding: 64px 0; }

/* ── ヘッダー ─────────────────────────── */
.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 20px;
}
.head h1 {
  font-family: var(--mincho);
  font-size: var(--t-xl);
  font-weight: 400;
  letter-spacing: .18em;
  margin: 0;
}
.head .who { font-size: var(--t-xs); color: var(--muted); letter-spacing: .06em; }

/* ── ライブの帯 ───────────────────────── */
.live {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  margin-bottom: 18px;
  font-size: var(--t-s);
}
.live .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); flex: none;
}
.live.on { border-color: var(--sun-deep); }
.live.on .dot { background: var(--sun); animation: pulse 1.8s ease-in-out infinite; }
.live .txt { flex: 1; color: var(--ink-soft); }
.live .txt b { color: var(--ink); font-weight: 600; }
.live a {
  color: var(--ground);
  background: var(--sun);
  text-decoration: none;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .06em;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ── 元気玉 ───────────────────────────── */
.orb { text-align: center; margin: 6px 0 22px; }
.orb canvas { width: 240px; height: 240px; display: block; margin: 0 auto; }
.orb .stage {
  font-family: var(--mincho);
  font-size: var(--t-l);
  letter-spacing: .2em;
  color: var(--sun);
  margin-top: -6px;
}
.orb .today { font-size: var(--t-s); color: var(--ink-soft); letter-spacing: .06em; }
.orb .today b { color: var(--ink); font-weight: 600; font-size: var(--t-l); font-family: var(--mono); }
.orb .sub { font-size: var(--t-xs); color: var(--muted); letter-spacing: .06em; margin-top: 2px; }

.bar {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin: 12px auto 6px;
  max-width: 240px;
}
.bar i { display: block; height: 100%; background: var(--sun-deep); border-radius: 2px; }

.now {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--t-xs); color: var(--sun);
  letter-spacing: .06em; margin-top: 4px;
}
.now .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sun); animation: pulse 2.4s ease-in-out infinite; }

/* ── カード ───────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 16px 16px 18px;
  margin-bottom: 16px;
}
.card h2 {
  font-family: var(--mincho);
  font-size: var(--t-m);
  font-weight: 400;
  letter-spacing: .16em;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

/* ── 時間の選択 ───────────────────────── */
.times { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.times button {
  flex: 1 1 0;
  min-width: 58px;
  font-family: var(--mono);
  font-size: var(--t-m);
  color: var(--ink-soft);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 0;
  cursor: pointer;
}
.times button[aria-pressed="true"] {
  color: var(--ground);
  background: var(--sun);
  border-color: var(--sun);
  font-weight: 700;
}

.go {
  display: block; width: 100%;
  font-family: var(--mincho);
  font-size: var(--t-l);
  letter-spacing: .3em;
  text-indent: .3em;
  color: var(--ground);
  background: var(--sun);
  border: none;
  border-radius: var(--r);
  padding: 14px 0;
  cursor: pointer;
}
.go:disabled { opacity: .5; cursor: default; }

/* ── 自分の記録 ───────────────────────── */
.stats { display: flex; gap: 8px; }
.stats div { flex: 1; text-align: center; }
.stats .n {
  font-family: var(--mono);
  font-size: var(--t-l);
  color: var(--ink);
}
.stats .k { font-size: var(--t-xs); color: var(--muted); letter-spacing: .06em; }

/* ── 今日の村 ─────────────────────────── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--t-s);
}
.feed li:last-child { border-bottom: none; }
.feed .name { font-weight: 600; color: var(--ink); white-space: nowrap; }
.feed .name.owner { color: var(--sun); }
.feed .name.me::after { content: "（自分）"; font-weight: 400; font-size: var(--t-xs); color: var(--muted); }
.feed .min { margin-left: auto; font-family: var(--mono); color: var(--ink-soft); white-space: nowrap; }
.feed .tag { font-size: var(--t-xs); color: var(--sun-deep); letter-spacing: .06em; }
.locked { color: var(--muted); font-size: var(--t-s); margin: 0; }

/* ── 瞑想中の画面 ─────────────────────── */
.sitting {
  position: fixed; inset: 0;
  background: var(--ground);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
  z-index: 10;
}
.sitting .ring { position: relative; width: 260px; height: 260px; }
.sitting canvas { position: absolute; inset: 0; width: 260px; height: 260px; }
.sitting .clock {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 2.6rem;
  letter-spacing: .04em;
  color: var(--ink);
}
.sitting .clock small {
  font-family: var(--gothic);
  font-size: var(--t-xs);
  letter-spacing: .2em;
  color: var(--muted);
}
.sitting .note {
  font-family: var(--mincho);
  letter-spacing: .2em;
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
}
.sitting .quit {
  font-size: var(--t-s);
  letter-spacing: .12em;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 22px;
  cursor: pointer;
}

/* ── 終わったあと ─────────────────────── */
.done { text-align: center; padding: 8px 0 4px; }
.done .big {
  font-family: var(--mincho);
  font-size: var(--t-xl);
  letter-spacing: .16em;
  color: var(--sun);
  margin: 0 0 4px;
}
.done p { color: var(--ink-soft); font-size: var(--t-s); margin: 0; }

/* ── 入村 ─────────────────────────────── */
.join label { display: block; font-size: var(--t-xs); color: var(--muted); letter-spacing: .1em; margin-bottom: 5px; }
.join input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;            /* iOSの自動ズーム回避 */
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 11px 12px;
  margin-bottom: 14px;
}
.join input:focus { outline: 2px solid var(--sun-deep); outline-offset: -1px; }
.lead { color: var(--ink-soft); font-size: var(--t-s); margin: 0 0 18px; }

.err {
  color: var(--err);
  font-size: var(--t-s);
  margin: 0 0 12px;
  min-height: 1.2em;
}
.foot {
  text-align: center;
  font-size: var(--t-xs);
  color: var(--muted);
  letter-spacing: .06em;
  margin-top: 26px;
}
.foot button {
  font: inherit; color: var(--muted);
  background: none; border: none; text-decoration: underline; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .live .dot, .now .dot { animation: none; }
}

/* 通知まわりのひとこと。うるさくならないよう小さく1行だけ。 */
.hint {
  font-size: var(--t-xs);
  color: var(--muted);
  line-height: 1.6;
  margin: -4px 0 12px;
}
