/* 瞑想寺 共通スタイル — timer.html のデザイントーン（#181310 の闇、#FF8B3E の火種）を踏襲 */
:root {
  --bg: #181310;
  --surface: #221B16;
  --line: #3A2F26;
  --ink: #F0E6D5;
  --muted: #9A8A75;
  --ember: #FF8B3E;
  --ember2: #FFC46B;
  --wood-hi: #B98A4F;
  --wood-lo: #7A5A38;
  --ash: #57504A;
  --foot: #6E6154;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}
[hidden] { display: none !important; }

.page {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

/* ---- header ---- */
.eyebrow {
  flex: none;
  font-size: 12px;
  letter-spacing: .35em;
  color: var(--muted);
  margin: 6px 0 2px;
}
.eyebrow strong { color: var(--ink); font-weight: 600; letter-spacing: .2em; }
.count {
  flex: none;
  margin: 14px 0 0;
  font-size: 15px;
  color: var(--ink);
  min-height: 1.5em;
}
.count .num { color: var(--ember2); font-weight: 700; }

section.view { display: flex; flex-direction: column; }
/* 瞑想中ビューは縦に伸ばし、.zen の flex:1 と .stick の height:100% を連動させる */
#view-run { flex: 1; min-height: 0; }

/* ---- divider（〜〜 見出し） ---- */
.divider {
  margin: 28px 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .15em;
}

/* ---- top page ---- */
.cta {
  margin-top: 28px;
  border: none;
  border-radius: 16px;
  padding: 18px 0;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(135deg, var(--ember), #E06A1F);
  color: #1C0F05;
  box-shadow: 0 4px 22px rgba(255, 139, 62, .28);
}
.cta-note { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.visitors { list-style: none; margin: 0; padding: 0; }
.visitors li {
  font-size: 14px;
  line-height: 2;
  color: var(--ink);
}
.visitors li .vtime {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.visitors li .vname { margin-left: .6em; }
.empty-note { color: var(--muted); font-size: 13px; }

/* ---- 名前確認ビュー ---- */
.name-view p { font-size: 14px; line-height: 1.8; color: var(--ink); }
.name-view .note { font-size: 12px; color: var(--muted); }
.text-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.text-input:focus { outline: none; border-color: var(--ember); }

/* ---- 設定ビュー ---- */
.profile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
.profile-row .pname { color: var(--ink); }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; font-family: inherit;
  padding: 12px 10px; margin: -10px -6px; /* 見た目を崩さずタップ領域を約44pxに */
}
.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.chip {
  flex: 1;
  min-width: 56px;
  padding: 12px 0;
  font-size: 15px;
  font-family: inherit; /* button 要素のUAデフォルトを打ち消す */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
}
.chip.active { border-color: var(--ember); color: var(--ember2); background: #2B1F14; }
.chip:active { transform: scale(.97); }

.btn {
  border: none;
  border-radius: 16px;
  padding: 18px 0;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
}
.btn.primary {
  background: linear-gradient(135deg, var(--ember), #E06A1F);
  color: #1C0F05;
  box-shadow: 0 4px 22px rgba(255, 139, 62, .28);
}
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.stop { background: var(--ember); color: #1C0F05; animation: blink 1.2s step-end infinite; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 12px 0; font-size: 15px; font-weight: 600; }
@keyframes blink { 50% { opacity: .35; } }

.start-row { margin-top: 12px; }
.start-note { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }

.notif { margin-top: 14px; text-align: center; }
.notif button {
  background: none; border: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-family: inherit;
}
.notif button:disabled { text-decoration: none; cursor: default; }
.notif-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
}

/* ---- バナー（投稿機会の復元） ---- */
.banner {
  margin-top: 18px;
  border: 1px solid var(--ember);
  border-radius: 12px;
  background: #2B1F14;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.banner button {
  flex: none;
  background: var(--ember);
  color: #1C0F05;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ---- 掲示板 ---- */
.board { list-style: none; margin: 0; padding: 0 0 8px; }
.board li { margin: 0 0 16px; }
.board .pbody { font-size: 14px; line-height: 1.9; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.board .pbody::before { content: '>> '; color: var(--muted); }
.board .pmeta { margin-top: 2px; text-align: right; font-size: 12.5px; color: var(--muted); }

/* ---- 再開ゲート ---- */
.gate { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.gate .gate-remain {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 700;
  text-align: center;
}
.gate .note { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.8; }

/* ---- 瞑想中ビュー（timer.html の .app 二段構造を再構築） ---- */
.zen { flex: 1; min-height: 0; display: flex; gap: 20px; padding-top: 8px; }
.stick-col { width: 26px; flex: none; display: flex; justify-content: center; padding: 8px 0; }
.stick {
  position: relative;
  width: 9px;
  border-radius: 5px;
  height: 100%;
  min-height: min(420px, 60dvh);
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-lo));
  overflow: visible;
}
.stick .ash-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0%;
  border-radius: 5px 5px 0 0;
  background: repeating-linear-gradient(180deg, var(--ash) 0 6px, #453F3A 6px 12px);
  opacity: .45;
  transition: height .25s linear;
}
.stick .ember-dot {
  position: absolute;
  left: 50%;
  top: 0%;
  width: 15px; height: 15px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--ember2), var(--ember) 60%, transparent 75%);
  box-shadow: 0 0 12px 3px rgba(255, 139, 62, .55), 0 0 34px 8px rgba(255, 139, 62, .22);
  opacity: 0;
  transition: top .25s linear, opacity .4s ease;
}
.view.running .ember-dot, .view.done .ember-dot { opacity: 1; }
.view.running .ember-dot { animation: flicker 1.1s ease-in-out infinite; }
@keyframes flicker {
  0%, 100% { box-shadow: 0 0 12px 3px rgba(255, 139, 62, .55), 0 0 34px 8px rgba(255, 139, 62, .22); }
  50% { box-shadow: 0 0 16px 5px rgba(255, 196, 107, .7), 0 0 44px 12px rgba(255, 139, 62, .3); }
}

.zen-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.clock { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.time {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: clamp(64px, 23vw, 108px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  user-select: none;
}
.view.done .time { color: var(--ember); }
.sub { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 1.4em; }

.end-row { flex: none; text-align: center; padding: 12px 0 4px; }
.end-link {
  background: none; border: none; cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-family: inherit;
}

/* ---- 終了確認オーバーレイ ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 7, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}
.overlay .panel {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px;
}
.overlay .panel p { margin: 0 0 18px; font-size: 14px; line-height: 1.9; white-space: pre-line; }
.overlay .confirm-end-row { margin-top: 26px; text-align: right; }

/* ---- 完了ビュー ---- */
.done-view { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.done-msg { font-size: 17px; line-height: 1.9; text-align: center; }
.done-note { font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.8; }
.save-status { font-size: 12.5px; color: var(--muted); text-align: center; min-height: 1.4em; }
.save-status.err { color: var(--ember); }
.post-form textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 12px 14px;
  font-size: 16px; /* 16px 未満だと iOS Safari がフォーカス時に自動ズームする */
  line-height: 1.8;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.post-form textarea:focus { outline: none; border-color: var(--ember); }
.form-row { display: flex; gap: 10px; margin-top: 10px; }
.form-row .btn { flex: 1; }
.form-err { font-size: 12.5px; color: var(--ember); min-height: 1.4em; }

/* 完了時の点滅は瞑想の余韻に合わせて弱める（周期3s・暗い暖色） */
.done-view.ringing { animation: donePulse 3s ease-in-out infinite; border-radius: 16px; }
@keyframes donePulse {
  0%, 100% { background: transparent; }
  50% { background: #2A1608; }
}

/* ---- footer ---- */
.foot {
  flex: none;
  margin-top: 18px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--foot);
}

.msg-line { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 1.4em; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .view.running .ember-dot { animation: none; }
  .done-view.ringing { animation: none; background: #2B180A; }
  .btn.stop { animation: none; }
}
