/*
 * styles.css — 口コミ下書き画面
 * テーマは CSS 変数。基本4色（--bg, --text, --primary, --accent）は config.theme から app.js が上書きし、
 * 派生色（--line, --muted, --primary-soft 等）も app.js が基本色から計算して上書きする。
 * ここに書いた値は既定テーマ「生成り×真鍮」の初期値。
 */
:root {
  --bg: #F6F1EA;
  --text: #2B2622;
  --primary: #8A6A4F;
  --accent: #B08D57;
  --surface: #FFFFFF;
  --line: #E0D9D1;
  --line-strong: #CFC5BA;
  --muted: #6F665F;
  --primary-soft: #F3EEE9;
  --primary-strong: #74583F;
  --accent-soft: #F5EEE2;
  --on-primary: #FFFFFF;
  --shadow: 0 1px 2px rgba(43, 38, 34, 0.05), 0 10px 28px rgba(43, 38, 34, 0.08);
  --radius: 12px;
  --radius-sheet: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  --actionbar-h: 96px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
  word-break: normal;
  line-break: strict;
}
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; }
img { max-width: 100%; display: block; }
p { margin: 0; }
h1, h2 { margin: 0; font-weight: 600; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}
.noscript { max-width: 480px; margin: 40px auto; padding: 0 16px; }

/* ---------- 上部: 進捗 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}
.progress {
  height: 3px;
  background: var(--line);
}
.progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 220ms ease;
}
.topbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 8px 0 4px;
}
.topbar__count {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  padding-right: 8px;
}

/* ---------- 画面本体 ---------- */
.screen {
  padding: 8px 16px 32px;
}
.topbar[hidden] + .screen { padding-top: 28px; }
.topbar[hidden] + .screen--status { padding-top: 56px; }
.screen--padded { padding-bottom: calc(var(--actionbar-h) + env(safe-area-inset-bottom, 0px) + 24px); }
.screen--status { padding-top: 56px; }
.screen--center { text-align: center; }

.title {
  font-size: 22px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.title:focus { outline: none; }
.sub {
  margin-top: 8px;
  font-size: 15px;
  color: var(--muted);
}
.lead { margin-top: 20px; font-size: 15px; line-height: 1.8; }
.block { margin-top: 24px; }

/* ---------- ようこそ ---------- */
.welcome { padding-top: 16px; text-align: center; }
.brand {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.3;
}
.brand img { margin: 0 auto; max-height: 64px; width: auto; }
.welcome__clinic {
  margin-top: 10px;
  font-size: 16px;
  color: var(--muted);
}
.welcome__rule {
  width: 40px;
  height: 2px;
  margin: 28px auto 0;
  background: var(--accent);
}
.welcome__lead {
  margin-top: 24px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
}
.welcome__lead .nowrap { display: inline-block; white-space: nowrap; }
.welcome__time { margin-top: 8px; font-size: 15px; color: var(--muted); }
.notice {
  margin-top: 32px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.8;
  text-align: left;
  color: var(--text);
}

/* ---------- 選択肢 ---------- */
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.opt:active { background: var(--primary-soft); }
.opt[aria-checked="true"] {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
  background: var(--primary-soft);
}
.opt__mark {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.opt--multi .opt__mark { border-radius: 6px; }
.opt__mark svg { width: 14px; height: 14px; opacity: 0; }
.opt[aria-checked="true"] .opt__mark { background: var(--primary); border-color: var(--primary); }
.opt[aria-checked="true"] .opt__mark svg { opacity: 1; }
.opt__label { flex: 1 1 auto; }
.opt:disabled { opacity: 1; }
.options__skip { margin-top: 20px; text-align: center; }

/* ---------- 入力欄 ---------- */
.field { margin-top: 28px; }
.field__label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}
.textarea {
  display: block;
  width: 100%;
  min-height: 112px;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.7;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}
.textarea:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); outline: none; }
.textarea::placeholder { color: var(--muted); opacity: 0.8; }
.counter {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- 仕上げ（星・セグメント） ---------- */
.stars { display: flex; gap: 2px; margin-top: 8px; }
.star {
  width: 48px;
  height: 48px;
  padding: 0;
  background: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.star svg { width: 34px; height: 34px; fill: none; stroke: var(--line-strong); stroke-width: 1.5; transition: fill 120ms ease, stroke 120ms ease; }
.star[aria-pressed="true"] svg { fill: var(--accent); stroke: var(--accent); }
.stars__value { margin-top: 4px; font-size: 13px; color: var(--muted); }
.segments {
  display: flex;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg {
  flex: 1 1 0;
  min-height: 48px;
  padding: 10px 6px;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.3;
  color: var(--text);
  transition: background-color 120ms ease, color 120ms ease;
}
.seg:first-child { border-left: 0; }
.seg[aria-checked="true"] { background: var(--primary); color: var(--on-primary); }

/* ---------- ボタン ---------- */
.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.actionbar__inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.actionbar__sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.actionbar__sub--center { justify-content: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  transition: background-color 120ms ease, opacity 120ms ease;
}
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:active { background: var(--primary-strong); }
.btn--primary:disabled { opacity: 0.4; }
.btn--outline { background: var(--surface); color: var(--primary); border-color: var(--line-strong); }
.linkbtn {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 8px 10px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
}
.linkbtn:disabled { opacity: 0.4; }
.linkbtn--quiet { color: var(--muted); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn--small { font-size: 14px; }

/* ---------- 生成中 ---------- */
.dots { display: flex; gap: 10px; justify-content: center; margin-top: 36px; }
.dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: kt-pulse 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes kt-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

/* ---------- 下書きの紙 ---------- */
.sheet {
  margin-top: 20px;
  padding: 18px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sheet);
  box-shadow: var(--shadow);
}
.sheet__text {
  display: block;
  width: 100%;
  min-height: 180px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.9;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
}
.sheet__text:focus { outline: none; }
.sheet__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.sheet__count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet__body {
  font-size: 17px;
  line-height: 2;
  white-space: pre-wrap;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.hint {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.msg { margin-top: 10px; font-size: 14px; color: var(--muted); min-height: 1.5em; }
.msg--ok { color: var(--primary); }

/* ---------- 手順 ---------- */
.steps {
  margin: 20px 0 0;
  padding-left: 1.5em;
  font-size: 15px;
  line-height: 1.7;
}
.steps li { margin-top: 6px; padding-left: 4px; }
.steps li::marker { color: var(--primary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 案内系 ---------- */
.howto {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.8;
}
.howto p + p { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .dots span { opacity: 0.8; }
}
