/* 現場ポケット5S診断 — Sur Communication デザイン言語 (ネイビー #1e3a5f × オレンジ #ff7a00) */

:root {
  --navy: #1e3a5f;
  --navy-dark: #142942;
  --orange: #ff7a00;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #22303f;
  --muted: #5f7185;
  --line: #dde4ec;
  --good: #2e9e5b;
  --mid: #e0a800;
  --low: #e2711d;
  --danger: #c0392b;
  --radius: 12px;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* ---------- ヘッダー ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: 10px 16px calc(10px);
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.app-title { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .02em; }
.app-title .accent { color: var(--orange); }
.guide-link {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; min-height: 44px;
  cursor: pointer;
}
.guide-link:active { background: rgba(255,255,255,.25); }
.header-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; flex: none; }
#btn-settings { padding: 8px 12px; font-size: 16px; }

/* ---------- 設定(診断AI / BYOK) ---------- */
.settings-key-label { display: block; font-weight: 700; font-size: 14px; margin: 14px 0 6px; }
#settings-key {
  width: 100%; min-height: 48px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.settings-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.settings-status {
  background: #e9f7ee; border: 1px solid #bfe5cc; color: #1d6b3d;
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px; margin-top: 12px;
}

.offline-banner {
  background: var(--danger); color: #fff; text-align: center;
  font-size: 13px; padding: 6px 12px;
}

/* ---------- ビュー / スクリーン ---------- */
.view { display: none; }
.view.active { display: block; }
.screen { padding: 16px; max-width: 640px; margin: 0 auto; }

.lead { font-size: 15px; color: var(--muted); margin-top: 4px; }

/* ---------- プリセット ---------- */
.preset-group { border: none; margin: 8px 0 4px; padding: 0; }
.preset-group legend { font-weight: 700; font-size: 14px; padding: 0 0 6px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 18px; border-radius: 999px;
  background: var(--card); border: 1.5px solid var(--line);
  font-size: 14px; cursor: pointer; user-select: none;
}
.chip input:checked + span {
  background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700;
}
.chip input:focus-visible + span { outline: 3px solid var(--orange); }

/* ---------- ボタン ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 52px; margin: 10px 0 0;
  border-radius: var(--radius); border: none;
  font-size: 16px; font-weight: 700; cursor: pointer;
  text-decoration: none; text-align: center;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:active { background: var(--navy-dark); }
.btn-secondary { background: #fff; color: var(--navy); border: 2px solid var(--navy); }
.btn-cta { background: var(--orange); color: #fff; box-shadow: 0 3px 10px rgba(255,122,0,.35); }
.btn-ghost { background: none; color: var(--muted); font-weight: 500; min-height: 44px; }
.btn-danger-ghost { background: none; color: var(--danger); border: 1px solid var(--danger); margin-top: 24px; }
.capture-buttons { margin-top: 12px; }

.privacy-note {
  font-size: 12px; color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 20px;
}

/* ---------- 解析中 ---------- */
.spinner {
  width: 56px; height: 56px; margin: 60px auto 16px;
  border: 6px solid var(--line); border-top-color: var(--orange);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.5s; }
}
.loading-text { text-align: center; color: var(--muted); }

/* ---------- 結果: 写真+マーカー ---------- */
.photo-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
.photo-wrap img { display: block; width: 100%; height: auto; }
.marker {
  position: absolute; border: 3px solid var(--orange);
  background: rgba(255,122,0,.16); border-radius: 6px;
}
.marker-num {
  position: absolute; top: -2px; left: -2px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--orange); color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- ゲージ・グラフ ---------- */
.gauge-block { display: flex; justify-content: center; margin: 18px 0 4px; }
.deduction-block { margin: 8px 0; }
.deduction-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 4px; }
.trend-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 12px 0; }

.gauge-caption { text-align: center; font-size: 12px; color: var(--muted); margin: 0 0 6px; }

/* ---------- 状態バンド(3段階・数字なし) ---------- */
.band-indicator { display: flex; gap: 6px; width: 100%; max-width: 420px; margin: 0 auto; }
.band-seg {
  flex: 1; text-align: center; padding: 10px 4px; border-radius: 8px;
  background: #eef2f7; color: #9aa7b4; font-size: 13px; font-weight: 700;
}
.band-seg.active { color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.band-caption { text-align: center; font-weight: 700; font-size: 15px; margin: 8px 0 0; }
.band-history { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.band-chip { display: inline-block; color: #fff; font-weight: 700; font-size: 13px; padding: 4px 12px; border-radius: 999px; }
.band-history-arrow { color: var(--muted); font-weight: 700; }
.area-band { flex: none; color: #fff; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; }
.session-band { display: inline-block; color: #fff; font-weight: 700; font-size: 13px; padding: 3px 12px; border-radius: 999px; }
.cmp-msg { text-align: center; font-size: 15px; font-weight: 700; color: var(--navy); margin: 10px 0 0; }
.summary { font-size: 15px; font-weight: 700; text-align: center; margin: 8px 0; }
.easy-first {
  background: #e9f7ee; border: 1px solid #bfe5cc; color: #1d6b3d;
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px;
}

/* ---------- 指摘カード ---------- */
.findings { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.finding-card {
  background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--orange);
  border-radius: var(--radius); padding: 12px 14px;
}
.finding-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.finding-num {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--orange); color: #fff; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.finding-type { font-weight: 700; font-size: 15px; }
.badge {
  display: inline-block; border-radius: 999px; padding: 2px 10px;
  font-size: 12px; font-weight: 700;
}
.badge-sev-high { background: #fdeaea; color: var(--danger); }
.badge-sev-mid { background: #fdf3dd; color: #8a6d00; }
.badge-sev-low { background: #eef2f7; color: var(--muted); }
.badge-easy { background: #e9f7ee; color: #1d6b3d; }
.badge-mid { background: #fdf3dd; color: #8a6d00; }
.badge-hard { background: #fdeaea; color: var(--danger); }
.finding-comment { margin: 8px 0 4px; font-size: 14px; }
.finding-suggest { margin: 0; font-size: 13px; color: var(--muted); }
.finding-cost { margin: 6px 0 0; font-size: 12px; color: var(--orange); font-weight: 700; }
.finding-guide-link { font-size: 12px; display: inline-block; color: var(--navy); padding: 12px 2px; min-height: 44px; line-height: 20px; }

.lowconf {
  background: #fdf3dd; border: 1px solid #eeda9e; border-radius: var(--radius);
  padding: 14px; text-align: center; font-size: 14px;
}
.disclaimer {
  font-size: 12px; color: var(--muted); background: var(--card);
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-top: 16px;
}
.engine-note { text-align: center; font-size: 11px; color: var(--muted); margin: 10px 0 0; }
.result-actions { margin-top: 8px; }
.error-msg { text-align: center; font-size: 15px; color: var(--danger); margin: 48px 0 12px; }

/* ---------- 記録タブ ---------- */
h2 { font-size: 18px; margin: 8px 0 12px; }
h3 { font-size: 16px; margin: 22px 0 8px; color: var(--navy); }
.area-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; cursor: pointer; font: inherit;
}
.area-card .area-name { font-weight: 700; font-size: 15px; }
.area-card .area-meta { font-size: 12px; color: var(--muted); }
.area-score { font-size: 24px; font-weight: 800; color: var(--navy); flex: none; }
.empty-note { color: var(--muted); font-size: 14px; text-align: center; margin-top: 40px; }

.session-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; margin-bottom: 8px;
}
.session-card img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; flex: none; }
.session-info { flex: 1; font-size: 13px; }
.session-score { font-size: 20px; font-weight: 800; color: var(--navy); }
.session-del { background: none; border: none; color: var(--muted); font-size: 18px; min-width: 44px; min-height: 44px; cursor: pointer; }

.ba-photos { display: flex; gap: 8px; }
.ba-photos figure { flex: 1; margin: 0; }
.ba-photos img { width: 100%; border-radius: 8px; display: block; }
.ba-photos figcaption { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.score-change { text-align: center; font-size: 30px; font-weight: 800; color: var(--navy); margin: 14px 0; }
.score-change .arrow { color: var(--orange); margin: 0 8px; }
.score-change .up { color: var(--good); }
.score-change .down { color: var(--danger); }

.resolved-list { display: flex; flex-direction: column; gap: 8px; }
.resolved-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; font-size: 14px;
}
.status-chip { flex: none; border-radius: 6px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.status-解消 { background: #e9f7ee; color: #1d6b3d; }
.status-残 { background: #fdeaea; color: var(--danger); }
.status-判定不可 { background: #eef2f7; color: var(--muted); }

/* ---------- ゴーストガイド ---------- */
.ghost-modal video { width: 100%; border-radius: var(--radius); display: block; }
.ghost-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .35; pointer-events: none;
}
.ghost-stage { position: relative; border-radius: var(--radius); overflow: hidden; }
.ghost-fallback { display: flex; gap: 8px; }
.ghost-fallback img { width: 50%; border-radius: 8px; align-self: flex-start; }

/* ---------- 帳票(準備中) ---------- */
.coming-soon { text-align: center; color: var(--muted); padding-top: 48px; }
.big-emoji { font-size: 48px; margin: 0; }

/* ---------- 2Sガイド ---------- */
.guide-def {
  background: var(--card); border-left: 5px solid var(--orange);
  border-radius: 8px; padding: 10px 14px; font-size: 15px;
}
.fives-stairs { display: flex; align-items: flex-end; gap: 4px; margin: 16px 0 8px; }
.fives-stairs .stair {
  flex: 1; background: var(--line); color: var(--muted);
  border-radius: 8px 8px 0 0; text-align: center; padding: 8px 2px;
  display: flex; flex-direction: column; font-size: 13px;
}
.fives-stairs .stair small { font-size: 10px; }
.fives-stairs .stair:nth-child(1) { height: 58px; }
.fives-stairs .stair:nth-child(2) { height: 72px; }
.fives-stairs .stair:nth-child(3) { height: 86px; }
.fives-stairs .stair:nth-child(4) { height: 100px; }
.fives-stairs .stair:nth-child(5) { height: 114px; }
.fives-stairs .stair.s2 { background: var(--navy); color: #fff; }
.fives-stairs .stair.s2 b { color: var(--orange); }

.ba-figure { display: flex; align-items: stretch; gap: 6px; margin: 12px 0; }
.ba-box {
  flex: 1; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 8px; text-align: center;
  display: flex; flex-direction: column; gap: 6px;
}
.ba-box small { color: var(--muted); font-size: 11px; }
.ba-tag { font-size: 11px; font-weight: 700; color: var(--muted); }
.ba-after { border-color: var(--good); }
.ba-after .ba-tag { color: var(--good); }
.ba-items { min-height: 74px; border-radius: 8px; padding: 6px; font-size: 20px; }
.ba-items.scatter {
  background: #fdeaea;
  display: flex; flex-wrap: wrap; gap: 2px 10px; justify-content: space-around; align-items: center;
}
.ba-items.scatter .ba-item:nth-child(odd) { transform: rotate(-14deg) translateY(6px); }
.ba-items.scatter .ba-item:nth-child(even) { transform: rotate(10deg) translateY(-4px); }
.ba-items.tidy {
  background: #e9f7ee;
  display: flex; gap: 12px; justify-content: center; align-items: center;
}
.ba-arrow { align-self: center; color: var(--orange); font-size: 22px; font-weight: 700; }

.rule-list { margin: 8px 0; padding-left: 20px; font-size: 14px; }
.rule-list li { margin: 6px 0; }
.rule-list b { color: var(--navy); }

.three-cards { display: flex; gap: 8px; margin: 10px 0; }
.mini-card {
  flex: 1; background: var(--card); border: 1.5px solid var(--navy);
  border-radius: var(--radius); text-align: center; padding: 12px 4px;
  display: flex; flex-direction: column;
}
.mini-card b { color: var(--navy); font-size: 16px; }
.mini-card span { font-size: 12px; color: var(--muted); }

.type-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.type-table th, .type-table td { border: 1px solid var(--line); padding: 8px 6px; text-align: left; }
.type-table th { background: var(--navy); color: #fff; font-weight: 700; }

.level-legend { list-style: none; padding: 0; margin: 8px 0 4px; }
.level-legend li { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.level-legend .badge { flex: none; min-width: 58px; text-align: center; }

.band-list { list-style: none; padding: 0; margin: 8px 0; }
.band-list li { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 14px; }
.band { width: 28px; height: 14px; border-radius: 4px; display: inline-block; }
.band-good { background: var(--good); }
.band-mid { background: var(--mid); }
.band-low { background: var(--low); }

.guide-cta {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 24px 0 8px; text-align: center;
}

/* ---------- 改善プラン(TODO) ---------- */
.todo-progress {
  position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 10;
  background: var(--bg); padding: 8px 0 10px;
}
.todo-progress-text { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.todo-bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.todo-bar-fill { height: 100%; width: 0; background: var(--good); border-radius: 999px; transition: width .3s ease; }
@media (prefers-reduced-motion: reduce) { .todo-bar-fill { transition: none; } }

.todo-step-head {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0 10px; padding: 8px 12px;
  border-radius: var(--radius); color: #fff;
}
.todo-step-head.step-easy { background: var(--good); }
.todo-step-head.step-mid { background: var(--mid); color: #4a3b00; }
.todo-step-head.step-hard { background: var(--low); }
.todo-step-num {
  flex: none; font-weight: 800; font-size: 13px;
  background: rgba(255,255,255,.28); border-radius: 999px; padding: 3px 10px;
}
.todo-step-label { display: flex; flex-direction: column; line-height: 1.3; }
.todo-step-label b { font-size: 15px; }
.todo-step-label span { font-size: 12px; opacity: .92; }

.todo-card {
  background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--navy);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
}
.todo-card-head { display: flex; align-items: center; gap: 8px; }
.todo-icon { font-size: 22px; }
.todo-type { font-weight: 700; font-size: 15px; color: var(--navy); }
.todo-mini {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 8px 0;
  font-size: 20px;
}
.todo-mini-b { filter: grayscale(.15); }
.todo-mini-arrow { color: var(--orange); font-weight: 700; font-size: 18px; }
.todo-ctx { font-size: 13px; color: var(--muted); margin: 6px 0 8px; }
.todo-list { list-style: none; margin: 6px 0 0; padding: 0; }
.todo-list li { margin: 2px 0; }
.todo-check {
  display: flex; align-items: flex-start; gap: 10px;
  min-height: 44px; padding: 6px 0; cursor: pointer; font-size: 14px;
}
.todo-check input[type="checkbox"] {
  width: 24px; height: 24px; flex: none; margin-top: 1px;
  accent-color: var(--good); cursor: pointer;
}
.todo-list li.done span { text-decoration: line-through; color: var(--muted); }

/* ---------- 改善イラスト集 ---------- */
.fix-block {
  background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--orange);
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
  scroll-margin-top: 70px;
}
.fix-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fix-head h3 { margin: 0; flex: 1; font-size: 16px; color: var(--navy); }
.fix-icon { font-size: 22px; }
.fix-note { font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.fix-steps { margin: 10px 0 0; padding-left: 22px; }
.fix-steps li { font-size: 14px; margin: 5px 0; }
.fix-flash { animation: fixflash 1.2s ease-out 1; }
@keyframes fixflash {
  0% { box-shadow: 0 0 0 3px rgba(255,122,0,.55); }
  100% { box-shadow: 0 0 0 3px rgba(255,122,0,0); }
}
@media (prefers-reduced-motion: reduce) { .fix-flash { animation: none; } }
.finding-fix-link { font-size: 12px; margin-right: 16px; display: inline-block; color: var(--orange); font-weight: 700; padding: 12px 2px; min-height: 44px; line-height: 20px; }

/* ---------- タブバー ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; color: var(--muted); min-height: 44px;
}
.tab .tab-icon { font-size: 20px; }
.tab.active { color: var(--navy); font-weight: 700; }
.tab.active .tab-icon { filter: none; }

/* ---------- モーダル / トースト ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20,41,66,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; border-radius: 16px 16px 0 0;
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal h3 { margin-top: 0; }
.modal input[type="text"] {
  width: 100%; min-height: 48px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.modal .site-pick {
  display: block; width: 100%; text-align: left; font: inherit;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 8px;
  padding: 12px; margin: 8px 0; min-height: 48px; cursor: pointer;
}

.toast {
  position: fixed; bottom: calc(var(--tabbar-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--navy-dark); color: #fff; border-radius: 999px;
  padding: 10px 22px; font-size: 14px; z-index: 50; white-space: nowrap;
}

/* ---------- SVGゲージ アニメーション ---------- */
.gauge-num { font-weight: 800; }
