/* ===========================================================
   QIDS-J セルフチェック  – スタイルシート
   カラー: 落ち着いた青緑系（医療的かつ緊張させない配色）
   =========================================================== */

:root {
  --c-bg-1: #eaf3f8;
  --c-bg-2: #f7fafc;
  --c-surface: #ffffff;
  --c-text: #1f3a4a;
  --c-text-soft: #516e7f;
  --c-muted: #8aa1ad;
  --c-line: #dde8ef;
  --c-primary: #5b8fb9;
  --c-primary-d: #3d6b8f;
  --c-accent: #6cb4a0;
  --c-danger: #d97b7b;
  --c-warn: #e0a458;
  /* 重症度カラー — WCAG AA 4.5:1 を白背景に対して概ね満たす濃さに調整 */
  --c-normal: #2f8f5c;
  --c-mild: #6a8f1e;
  --c-moderate: #b86f11;
  --c-severe: #c0413f;
  --c-extreme: #942828;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 20px rgba(48, 79, 99, 0.08);
  --shadow-lg: 0 12px 40px rgba(48, 79, 99, 0.14);
  --t: 0.25s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI",
               "Meiryo", sans-serif;
  color: var(--c-text);
  background:
    radial-gradient(1000px 600px at 10% -10%, #cfe3ef 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 10%, #dcefe5 0%, transparent 60%),
    linear-gradient(180deg, var(--c-bg-1), var(--c-bg-2));
  min-height: 100vh;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

img, video, canvas { max-width: 100%; display: block; }

a { color: var(--c-primary-d); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: min(720px, 100% - 32px);
  margin: 24px auto 120px;
}

/* ---------- Screens ---------- */
.screen { display: none; animation: fadeIn .35s ease; }
.screen.active { display: block; }
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Brand ---------- */
.brand { text-align: center; padding: 24px 8px 12px; }
.brand-mark {
  display: inline-block;
  letter-spacing: 2px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  padding: 6px 14px;
  border-radius: 999px;
}
.brand h1 {
  font-size: clamp(22px, 4.5vw, 30px);
  margin: 14px 0 4px;
  color: var(--c-primary-d);
}
.brand .subtitle { margin: 0; color: var(--c-text-soft); font-size: 14px; }

/* ---------- Card ---------- */
.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow);
  border: 1px solid var(--c-line);
  margin-top: 18px;
}

.card h2 { font-size: 20px; margin: 0 0 10px; color: var(--c-primary-d); }
.card h3 { font-size: 16px; margin: 18px 0 6px; color: var(--c-text); }
.card p  { margin: 6px 0; color: var(--c-text-soft); }
.card ul { padding-left: 20px; margin: 6px 0 10px; color: var(--c-text-soft); }

.notice {
  background: #f3f8fa;
  border-left: 4px solid var(--c-primary);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 10px 0 14px;
}
.notice p { margin: 0 0 6px; color: var(--c-text); }

.notice-soft {
  background: #f0f7f3;
  border-left-color: var(--c-accent);
}

/* ---------- Baseline capture screen ---------- */
.baseline-card { text-align: center; padding: clamp(28px, 5vw, 48px) clamp(22px, 4vw, 40px); }
.baseline-indicator {
  margin: 28px auto 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.baseline-ring {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--c-primary) var(--baseline-angle, 0deg), #e6eef3 0deg);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: background 0.1s linear;
}
.baseline-ring::before {
  content: "";
  position: absolute; inset: 10px;
  background: #fff;
  border-radius: 50%;
}
.baseline-countdown {
  position: relative;
  font-size: 54px;
  font-weight: 700;
  color: var(--c-primary-d);
  font-variant-numeric: tabular-nums;
}
.baseline-hint { color: var(--c-text-soft); margin: 0; font-size: 14px; }

/* ---------- Safety banner ---------- */
.banner {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 10px 0 14px;
  font-size: 14px;
  line-height: 1.6;
}
.banner-warn {
  background: #fff4e6;
  border: 1px solid #f5cba3;
  color: #7a3d00;
}
.banner-warn strong { color: #5a2c00; }

/* ---------- Consent list ---------- */
.consent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px 0 6px;
  padding: 14px 16px;
  background: #f7fafc;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
}
.consent-list .check { padding: 6px 0; }
.consent-list .camera-consent { color: var(--c-text-soft); }

/* ---------- Crisis modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 35, 50, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: #fff;
  max-width: 520px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 32px);
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.35s ease;
}
.modal-card h2 {
  margin: 0 0 10px;
  color: var(--c-primary-d);
  font-size: 22px;
}
.modal-card p { margin: 8px 0; color: var(--c-text); }

.hotline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.hotline-item {
  padding: 12px 14px;
  background: #f3f8fa;
  border-left: 4px solid var(--c-primary);
  border-radius: var(--radius-sm);
}
.hotline-item.hotline-urgent {
  background: #ffece8;
  border-left-color: #c0413f;
}
.hotline-name { font-weight: 600; color: var(--c-text); font-size: 14px; }
.hotline-num  {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 2px 0;
}
.hotline-num a { color: var(--c-primary-d); text-decoration: none; }
.hotline-num a:hover { text-decoration: underline; }
.hotline-hours { font-size: 12px; color: var(--c-muted); }

/* ---------- Extraction progress modal ---------- */
.extract-card h2 { margin-top: 0; }
.extract-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}
.extract-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--c-text-soft);
}
.extract-field .select,
select.select {
  padding: 6px 10px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  color: var(--c-text);
}
.progress-track {
  height: 10px;
  background: #e6eef3;
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 8px;
}
.progress-fill-ex {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--c-primary), var(--c-accent));
  border-radius: 999px;
  transition: width 0.2s ease;
}
.extract-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--c-text-soft);
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}
.extract-thumb-box {
  aspect-ratio: 4 / 3;
  background: #0d1b24;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.extract-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, matching the recorded-from-camera orientation */
}
.extract-thumb-box .muted { color: #5d7a89; padding: 20px; }

.extract-success {
  color: var(--c-normal);
  font-weight: 600;
  font-size: 15px;
  margin: 10px 0 6px;
}

/* ---------- Camera settings (intro) ---------- */
.camera-settings {
  margin: 14px 0 4px;
  padding: 10px 14px;
  background: #f7fafc;
  border: 1px solid var(--c-line);
  border-radius: 10px;
}
.camera-settings > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--c-text-soft);
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.camera-settings > summary::before {
  content: '▸';
  display: inline-block;
  font-size: 10px;
  color: var(--c-muted);
  transition: transform 0.15s ease;
}
.camera-settings[open] > summary::before { transform: rotate(90deg); }
.camera-settings > summary::-webkit-details-marker { display: none; }

.camera-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
  margin: 10px 0 4px;
}
.camera-settings .select {
  padding: 6px 10px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  color: var(--c-text);
}
.camera-settings .extract-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--c-text-soft);
}
.camera-settings code {
  background: #eaf3f8;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  cursor: pointer;
  user-select: none;
  color: var(--c-text);
}
.check input { width: 18px; height: 18px; accent-color: var(--c-primary); }

.tiny { font-size: 12px; color: var(--c-muted); margin-top: 14px; }
.muted { color: var(--c-muted); }

/* ---------- Buttons ---------- */
.btn-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn-row-split { justify-content: space-between; }
.btn-row-wrap { flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 0;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t), background var(--t), color var(--t), box-shadow var(--t);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-d));
  color: #fff;
  box-shadow: 0 6px 16px rgba(91, 143, 185, 0.35);
}
.btn-primary:not(:disabled):hover { box-shadow: 0 10px 20px rgba(91, 143, 185, 0.45); }

.btn-ghost {
  background: transparent;
  color: var(--c-primary-d);
  border: 1px solid var(--c-line);
}
.btn-ghost:not(:disabled):hover { background: #f3f8fa; }

.btn-outline {
  background: #fff;
  color: var(--c-primary-d);
  border: 1px solid var(--c-primary);
}
.btn-outline:not(:disabled):hover { background: #eaf3f8; }

.btn .ic { color: #ff8383; }

/* ---------- Progress ---------- */
.progress { margin: 10px 0 4px; }
.progress-info {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; color: var(--c-text-soft); margin-bottom: 6px;
}
.tag {
  background: #e3eff6;
  color: var(--c-primary-d);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.progress-bar {
  height: 8px;
  background: #e6eef3;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--c-primary), var(--c-accent));
  border-radius: 999px;
  transition: width .4s ease;
}

/* ---------- Question Card ---------- */
.qhead { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.qnum {
  flex: 0 0 auto;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 14px;
}
.qhead h2 { margin: 0; font-size: clamp(18px, 3.5vw, 22px); color: var(--c-text); }

.keyboard-hint {
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--c-muted);
}
.keyboard-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  background: #f0f5f8;
  border: 1px solid var(--c-line);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  color: var(--c-text-soft);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
@media (max-width: 560px) { .keyboard-hint { display: none; } }

.options { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 0; }

/* Focus outlines — ensure keyboard users can see where they are */
.option:focus-visible,
.btn:focus-visible,
.check input:focus-visible + span {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}
.option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: #f7fafc;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--t), background var(--t), transform var(--t);
}
.option:hover { background: #edf4f8; transform: translateY(-1px); }
.option.selected {
  border-color: var(--c-primary);
  background: #eaf3f8;
}
.option-score {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--c-line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--c-text-soft); font-size: 13px;
  transition: var(--t);
}
.option.selected .option-score {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.option-text { color: var(--c-text); font-size: 15px; line-height: 1.6; }

/* ---------- Result ---------- */
.result-head { text-align: center; margin-bottom: 14px; }
.result-head h2 { font-size: 24px; margin: 0; color: var(--c-primary-d); }

.score-display {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin: 16px 0 22px;
  flex-wrap: wrap;
}
.score-ring {
  width: 160px; height: 160px;
  border-radius: 50%;
  background: conic-gradient(var(--sev-color, var(--c-primary)) var(--sev-angle, 0deg), #e6eef3 0deg);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: background 0.6s ease;
}
.score-ring::before {
  content: "";
  position: absolute; inset: 10px;
  background: #fff;
  border-radius: 50%;
}
.score-number {
  position: relative;
  font-size: 42px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1;
}
.score-number small { font-size: 16px; color: var(--c-muted); font-weight: 500; margin-left: 2px; }

.severity-box { text-align: center; }
.severity-box .label { font-size: 13px; color: var(--c-muted); letter-spacing: 1px; }
.severity {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 700;
  color: var(--sev-color, var(--c-primary));
  margin-top: 2px;
}

.severity-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 16px 0;
}
.sev-item {
  text-align: center;
  padding: 10px 4px;
  border-radius: 10px;
  background: #f7fafc;
  font-size: 13px;
  color: var(--c-text-soft);
  border: 2px solid transparent;
  transition: var(--t);
}
.sev-item span {
  display: block;
  font-weight: 700;
  font-size: 12px;
  color: var(--c-muted);
  margin-bottom: 2px;
}
.sev-item.active { border-color: var(--sev-color, var(--c-primary)); background: #fff; }
.sev-item[data-sev="normal"].active   { color: var(--c-normal); }
.sev-item[data-sev="mild"].active     { color: var(--c-mild); }
.sev-item[data-sev="moderate"].active { color: var(--c-moderate); }
.sev-item[data-sev="severe"].active   { color: var(--c-severe); }
.sev-item[data-sev="extreme"].active  { color: var(--c-extreme); }

/* ---------- Camera panel (floating preview) ---------- */
.camera-panel {
  position: fixed;
  top: 16px; right: 16px;
  width: 220px;
  z-index: 100;
  background: #0d1b24;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.08);
}
.camera-wrapper {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
}
.camera-wrapper video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror like selfie */
}
.rec-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0,0,0,.55);
  color: #fff;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  display: flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.rec-dot {
  width: 8px; height: 8px;
  background: #ff5353;
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}
/* pose-badge removed — head pose readout happens post-hoc in the analyze view */
.camera-status {
  padding: 6px 10px;
  font-size: 11px;
  color: #a8c3d0;
  background: #0d1b24;
  text-align: center;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 20px 16px 40px;
  color: var(--c-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .camera-panel { width: 140px; top: 10px; right: 10px; }
  .camera-status { font-size: 10px; }
  .severity-scale { grid-template-columns: repeat(2, 1fr); }
  .score-ring { width: 140px; height: 140px; }
  .score-number { font-size: 36px; }
  .btn { padding: 11px 16px; font-size: 14px; width: auto; }
  .btn-row-split .btn { flex: 1; justify-content: center; }
}

@media (max-width: 380px) {
  .container { margin: 16px auto 100px; }
  .card { padding: 18px; }
  .option { padding: 12px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
