/* らぽーる整体院 頭痛診断アプリ — 共通スタイル */
:root {
  --brand: #1f7a8c;
  --brand-dark: #155663;
  --brand-light: #e8f4f6;
  --ink: #25323a;
  --ink-soft: #5b6b74;
  --line: #e3e9ec;
  --bg: #f4f7f8;
  --card: #ffffff;
  --danger: #d9534f;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(31, 122, 140, 0.10);
  --t-tension: #2BAE9D;
  --t-migraine: #F2994A;
  --t-hybrid: #9B6BD8;
  --t-moh: #4A90D9;
  --t-cluster: #34495E;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.app-shell { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---- ヘッダー ---- */
.app-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 10;
}
.app-header .logo-mark {
  width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.18);
  display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: 0 0 auto;
}
.app-header .logo-img {
  height: 40px; width: auto; flex: 0 0 auto; object-fit: contain;
}
.app-header .clinic { font-size: 12px; opacity: .88; letter-spacing: .04em; }
.app-header .title { font-size: 16px; font-weight: 700; line-height: 1.2; }

/* ---- ビュー切替 ---- */
.view { display: none; padding: 20px; flex: 1; animation: fade .35s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 16px; }

h1,h2,h3 { margin: 0 0 12px; line-height: 1.35; }
.lead { color: var(--ink-soft); font-size: 14.5px; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }

/* ---- フロント ---- */
.hero { text-align: center; padding: 8px 0 4px; }
.hero h1 { font-size: 23px; font-weight: 800; }
.hero .sub { color: var(--ink-soft); font-size: 14.5px; }
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 4px; }
.type-chip {
  font-size: 12.5px; font-weight: 700; color: #fff; padding: 6px 12px; border-radius: 999px;
}
.steps-note { display: flex; gap: 10px; justify-content: center; color: var(--ink-soft); font-size: 12.5px; margin-top: 14px; flex-wrap: wrap; }

/* ---- フォーム ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 7px; }
.field .hint { font-weight: 400; color: var(--ink-soft); font-size: 12px; margin-left: 6px; }
.field input[type="text"] {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus { outline: none; border-color: var(--brand); }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-select {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: .15s; font-weight: 600;
}
.chip-select.selected { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }
.chip-select:active { transform: scale(.97); }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border-radius: 14px; border: none;
  font-size: 16px; font-weight: 700; font-family: inherit; cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(31,122,140,.28); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #b9c7cc; box-shadow: none; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--brand-dark); border: 1.5px solid var(--line); }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { width: auto; flex: 1; }
.btn-sm { padding: 11px 14px; font-size: 14px; }

/* ---- 質問 ---- */
.progress-wrap { margin-bottom: 18px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.progress-bar { height: 8px; background: #e6edef; border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg,var(--brand),#3fb0c4); border-radius: 999px; transition: width .35s ease; }
.q-cat { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--brand-dark); background: var(--brand-light); padding: 3px 10px; border-radius: 999px; margin-bottom: 10px; }
.q-title { font-size: 18.5px; font-weight: 800; margin-bottom: 4px; }
.q-help { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 16px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 15px 16px; border: 2px solid var(--line); border-radius: 14px; background: #fff;
  font-size: 15.5px; font-weight: 600; color: var(--ink); cursor: pointer; font-family: inherit; transition: .15s;
}
.option .tick {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line);
  flex: 0 0 auto; display: grid; place-items: center; color: #fff; font-size: 13px;
}
.option.multi .tick { border-radius: 7px; }
.option.selected { border-color: var(--brand); background: var(--brand-light); }
.option.selected .tick { background: var(--brand); border-color: var(--brand); }
.option:active { transform: scale(.99); }

/* ---- レポート ---- */
.report-hero { text-align: center; padding: 6px 0 2px; }
.report-hero .eyebrow { font-size: 12.5px; color: var(--ink-soft); letter-spacing: .05em; }
.report-hero .top-type { font-size: 27px; font-weight: 900; margin: 4px 0 2px; }
.report-hero .top-tagline { font-size: 13.5px; color: var(--ink-soft); }
.confidence-pill { display:inline-block; margin-top:10px; font-size:12px; font-weight:700; padding:5px 13px; border-radius:999px; }

.bars { margin: 6px 0 4px; }
.bar-item { margin-bottom: 13px; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.bar-name { font-size: 14px; font-weight: 700; }
.bar-name .rank { color: var(--ink-soft); font-weight: 700; margin-right: 6px; }
.bar-pct { font-size: 14px; font-weight: 800; }
.bar-track { height: 16px; background: #eef2f4; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; width: 0; transition: width .9s cubic-bezier(.22,1,.36,1); }

.note {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: #fff8ed; border: 1px solid #f3dcb6; font-size: 13.5px; color: #6b4e1f; margin-top: 10px;
}
.note.alert { background: #fdecec; border-color: #f3c0bf; color: #8a322f; }
.note .ic { font-weight: 900; flex: 0 0 auto; }

.type-detail { margin-top: 4px; }
.type-detail h3 { font-size: 16px; }
.feature-list { margin: 8px 0 0; padding-left: 0; list-style: none; }
.feature-list li { position: relative; padding-left: 20px; margin-bottom: 6px; font-size: 13.8px; color: var(--ink); }
.feature-list li::before { content: "✓"; position: absolute; left: 0; color: var(--brand); font-weight: 900; }
.care-box { margin-top: 12px; background: var(--brand-light); border-radius: 12px; padding: 13px 15px; font-size: 13.8px; color: var(--brand-dark); }

.disclaimer { font-size: 11.5px; color: var(--ink-soft); margin-top: 16px; line-height: 1.55; }
.clinic-foot { margin-top: 14px; text-align: center; font-size: 12.5px; color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #25323a; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.hidden { display: none !important; }

.line-banner-link { display: block; margin-top: 16px; border-radius: 12px; overflow: hidden; }
.line-banner-img { width: 100%; height: auto; display: block; }

/* ====== 院用管理画面 ====== */
.admin-shell { max-width: 960px; margin: 0 auto; padding: 0 0 60px; }
.admin-header {
  background: linear-gradient(135deg, #2c3e50, #1a2733); color: #fff;
  padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.admin-header .title { font-size: 18px; font-weight: 800; }
.admin-header .sub { font-size: 12px; opacity: .8; }
.admin-main { padding: 22px; }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 760px) { .admin-grid { grid-template-columns: 1fr 1fr; } }
.panel { background: #fff; border-radius: 14px; box-shadow: 0 4px 18px rgba(40,60,75,.08); padding: 20px; }
.panel h2 { font-size: 15px; font-weight: 800; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.panel h2 .count-badge { background: var(--brand); color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 999px; }

.stat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stat-row .lbl { width: 120px; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.stat-row .track { flex: 1; height: 18px; background: #eef2f4; border-radius: 999px; overflow: hidden; }
.stat-row .fill { height: 100%; border-radius: 999px; }
.stat-row .val { width: 64px; text-align: right; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.kpi-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.kpi { flex: 1; min-width: 120px; background: var(--brand-light); border-radius: 12px; padding: 14px; text-align: center; }
.kpi .num { font-size: 26px; font-weight: 900; color: var(--brand-dark); }
.kpi .cap { font-size: 12px; color: var(--ink-soft); }

/* トグルスイッチ */
.rule-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule-item:last-child { border-bottom: none; }
.rule-item .rule-name { font-size: 13.5px; font-weight: 700; }
.rule-item .rule-desc { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.switch { position: relative; width: 50px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #c9d4d8; border-radius: 999px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.threshold-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13.5px; font-weight: 700; }
.threshold-row input { width: 64px; padding: 8px; border: 1.5px solid var(--line); border-radius: 9px; font-size: 15px; text-align: center; }

.table-wrap { overflow-x: auto; }
table.records { width: 100%; border-collapse: collapse; font-size: 13px; }
table.records th, table.records td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.records th { font-size: 12px; color: var(--ink-soft); font-weight: 700; background: #f7fafb; position: sticky; top: 0; }
table.records tbody tr { cursor: pointer; }
table.records tbody tr:hover { background: var(--brand-light); }
.type-tag { display: inline-block; color: #fff; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 0; font-size: 14px; }

.modal-back { position: fixed; inset: 0; background: rgba(20,30,36,.55); display: none; align-items: center; justify-content: center; padding: 18px; z-index: 100; }
.modal-back.show { display: flex; }
.modal { background: #fff; border-radius: 16px; max-width: 520px; width: 100%; max-height: 86vh; overflow-y: auto; padding: 22px; }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .close-x { float: right; cursor: pointer; font-size: 22px; color: var(--ink-soft); line-height: 1; border: none; background: none; }
.detail-list { list-style: none; padding: 0; margin: 14px 0 0; }
.detail-list li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.detail-list .dq { color: var(--ink-soft); font-size: 12px; }
.detail-list .da { font-weight: 700; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input.search { flex: 1; min-width: 160px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 14px; }
.btn-mini { padding: 9px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--brand-dark); font-family: inherit; }
.btn-mini.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.save-state { font-size: 12.5px; color: var(--brand-dark); font-weight: 700; }
