/* =========================================================
   警備報告書メーカー デザインシステム
   方針: 「信頼感・視認性・堅牢性・業務感」に加え、
   60代以上でも説明書なしで操作できる大きな文字・大きなボタンを既定とする。
   絵文字アイコン・平坦なグラデーション・汎用AIテンプレ感を避け、
   紺(業務・信頼)+アンバー(注意喚起・確度)+線画アイコン+罫線を活かした帳票的UI。
   ========================================================= */

:root {
  /* カラートークン */
  --color-navy-950: #0a1626;
  --color-navy-900: #0f1f38;
  --color-navy-800: #16294a;
  --color-navy-700: #1e3a63;
  --color-navy-600: #2a4d80;
  --color-navy-500: #3a63a0;
  --color-navy-100: #e7ecf4;
  --color-navy-050: #f2f5fa;

  --color-amber-700: #8f5a09;
  --color-amber-600: #b5730c;
  --color-amber-500: #d9900f;
  --color-amber-400: #e6a53a;
  --color-amber-100: #fbe8c8;
  --color-amber-050: #fdf3e2;

  --color-red-600: #b3261e;
  --color-red-100: #fbe3e1;

  --color-green-600: #2e7d4f;
  --color-green-100: #e2f2e8;

  --color-ink: #171c26;
  --color-ink-soft: #4a5164;
  --color-ink-faint: #8790a3;
  --color-line: #d7dce6;
  --color-line-strong: #a7b1c4;
  --color-bg: #eef1f6;
  --color-surface: #ffffff;

  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 20px;

  --shadow-card: 0 1px 2px rgba(15, 31, 56, 0.05), 0 4px 14px rgba(15, 31, 56, 0.07);
  --shadow-card-hover: 0 2px 4px rgba(15, 31, 56, 0.06), 0 10px 24px rgba(15, 31, 56, 0.1);
  --shadow-modal: 0 20px 50px rgba(9, 17, 33, 0.4);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --header-h: 64px;

  /* ---- サイズトークン(文字サイズ設定で切り替わる) ----
     既定(data-text-size未指定 = large)は仕様書推奨の「大きい」。 */
  --fs-body: 22px;
  --fs-aux: 18px;
  --fs-button: 26px;
  --fs-button-sm: 19px;
  --fs-heading: 32px;
  --fs-heading-sm: 24px;
  --fs-label: 18px;
  --tap-primary: 76px;
  --tap-min: 60px;
  --input-h: 68px;
  --icon-size: 26px;
}

:root[data-text-size="standard"] {
  --fs-body: 18px;
  --fs-aux: 15px;
  --fs-button: 19px;
  --fs-button-sm: 15px;
  --fs-heading: 23px;
  --fs-heading-sm: 18px;
  --fs-label: 14px;
  --tap-primary: 58px;
  --tap-min: 46px;
  --input-h: 50px;
  --icon-size: 22px;
}

:root[data-text-size="xlarge"] {
  --fs-body: 26px;
  --fs-aux: 21px;
  --fs-button: 30px;
  --fs-button-sm: 23px;
  --fs-heading: 36px;
  --fs-heading-sm: 27px;
  --fs-label: 21px;
  --tap-primary: 88px;
  --tap-min: 68px;
  --input-h: 78px;
  --icon-size: 30px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* [hidden]属性は必ず優先させる。
   .modal-overlay/.loading-overlay等にdisplay:flexを直接指定しているため、
   詳細度が同じ場合は後読みの自スタイルが勝ってしまいhidden属性が無効化されるのを防ぐ。 */
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

body {
  margin: 0;
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  color: var(--color-ink);
  background: var(--color-bg);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0; }
p { margin: 0; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* キーボード操作時のみフォーカスリングを出す（マウスクリックでは出さない） */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--color-navy-500);
  outline-offset: 2px;
  border-radius: var(--radius-s);
}

/* -------------------- アイコン -------------------- */
.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
}
.icon-sm { width: calc(var(--icon-size) * 0.7); height: calc(var(--icon-size) * 0.7); }
.icon-lg { width: calc(var(--icon-size) * 1.35); height: calc(var(--icon-size) * 1.35); }

/* -------------------- ヘッダー -------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  background: var(--color-navy-900);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 2px 10px rgba(6, 12, 24, 0.35);
}
.header-btn {
  width: var(--header-h);
  height: var(--header-h);
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-s);
}
.header-btn .icon { width: 28px; height: 28px; }
.header-btn:active { background: rgba(255,255,255,0.1); }
.header-back { width: auto; min-width: var(--header-h); margin-left: 4px; padding: 0 12px 0 8px; gap: 4px; }
.header-back-label { font-size: 15px; font-weight: 700; }
.header-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  padding: 0 8px;
  overflow: hidden;
}
.header-title-main { font-weight: 700; font-size: 18px; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.header-title-sub { font-size: 12px; color: var(--color-amber-400); opacity: .9; letter-spacing: .02em; }
.online-badge {
  width: var(--header-h);
  display: flex; align-items: center; justify-content: center;
  color: #59d391;
}
.online-badge.is-offline { color: #e97a68; }

/* -------------------- 画面切替 -------------------- */
#app-main {
  min-height: calc(100vh - var(--header-h) - var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
}
.view { display: none; }
.view--active { display: block; animation: view-fade .16s ease-out; }
@keyframes view-fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: translateY(0);} }
@media (prefers-reduced-motion: reduce) {
  .view--active { animation: none; }
}

/* -------------------- ホーム(簡素化・縦積み) -------------------- */
.home-hero {
  position: relative;
  padding: 22px 20px 28px;
  background: var(--color-navy-950);
  color: #fff;
  overflow: hidden;
}
.home-hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.9), transparent 85%);
  mask-image: linear-gradient(180deg, rgba(0,0,0,.9), transparent 85%);
}
.home-hero::after {
  content: "";
  position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217,144,15,0.16), transparent 70%);
}
.home-hero-top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.home-hero-mark {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-amber-400);
}
.home-hero-brand { font-size: 12px; letter-spacing: .12em; color: rgba(255,255,255,0.7); text-transform: uppercase; }
.home-hero-date { position: relative; font-size: 20px; font-weight: 700; letter-spacing: .01em; }
.home-hero-title { position: relative; font-size: 26px; font-weight: 800; letter-spacing: .01em; margin-top: 4px; }

.home-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 16px;
  margin-top: -16px;
  position: relative;
}
.home-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 20px 20px;
  min-height: var(--tap-primary);
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  transition: box-shadow .15s ease, transform .1s ease, border-color .15s ease;
  width: 100%;
}
.home-tile:active { transform: scale(0.98); box-shadow: var(--shadow-card); }
@media (hover: hover) {
  .home-tile:hover { box-shadow: var(--shadow-card-hover); border-color: var(--color-line-strong); }
}
.home-tile--primary {
  background: var(--color-navy-800);
  border-color: var(--color-navy-800);
  min-height: 108px;
}
.home-tile--primary .home-tile-label { color: #fff; font-size: calc(var(--fs-heading-sm) + 2px); }
.home-tile--primary .home-tile-desc { color: rgba(255,255,255,0.75); }
.home-tile--primary .home-tile-icon { background: rgba(255,255,255,0.14); color: var(--color-amber-400); }
.home-tile-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-s);
  display: flex; align-items: center; justify-content: center;
  background: var(--color-navy-050);
  color: var(--color-navy-700);
  flex-shrink: 0;
}
.home-tile-icon .icon { width: 30px; height: 30px; }
.home-tile-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.home-tile-label { font-weight: 700; font-size: var(--fs-heading-sm); color: var(--color-navy-900); letter-spacing: .01em; }
.home-tile-desc { font-size: var(--fs-aux); color: var(--color-ink-soft); line-height: 1.4; }

.draft-banner {
  margin: 0 16px 16px;
  padding: 14px 16px;
  background: var(--color-amber-050);
  border: 1px solid var(--color-amber-100);
  border-radius: var(--radius-m);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-aux);
  color: #6a4600;
  flex-wrap: wrap;
}

.home-settings-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 16px 8px;
  padding: 14px;
  min-height: var(--tap-min);
  background: transparent;
  border: none;
  color: var(--color-ink-soft);
  font-size: var(--fs-button-sm);
  font-weight: 600;
  cursor: pointer;
}
.home-settings-link .icon { color: var(--color-ink-faint); }

.status-pip {
  position: absolute; top: -2px; right: -4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-line-strong);
  border: 2px solid var(--color-surface);
}
.status-pip.is-ok { background: var(--color-green-600); }
.status-pip.is-error { background: var(--color-red-600); }

/* -------------------- 汎用ボタン -------------------- */
.btn {
  min-height: var(--tap-min);
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  padding: 10px 18px;
  font-size: var(--fs-button-sm);
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform .05s ease, background-color .15s ease, box-shadow .15s ease;
  line-height: 1.3;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; min-height: var(--tap-primary); font-size: var(--fs-button); }
.btn-primary {
  background: var(--color-navy-800);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 1px 2px rgba(15,31,56,0.25);
}
.btn-primary:active { background: var(--color-navy-900); }
@media (hover: hover) { .btn-primary:hover { background: var(--color-navy-700); } }
.btn-outline { background: #fff; color: var(--color-navy-800); border-color: var(--color-line-strong); }
.btn-outline:active { background: var(--color-navy-050); }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: var(--fs-button-sm); }
.btn-text { background: transparent; color: var(--color-navy-700); min-height: 44px; padding: 6px 8px; font-weight: 600; }
.btn-danger-text { color: var(--color-red-600); }
.btn-danger-outline { background: #fff; color: var(--color-red-600); border-color: var(--color-red-100); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon-text .icon { width: 22px; height: 22px; }
.btn-small.btn-icon-text .icon { width: 18px; height: 18px; }
.btn-icon-only { width: var(--tap-primary); padding: 0; flex: 0 0 auto; }

/* -------------------- カード・フォーム -------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin: 0 16px 16px;
}
.card-title { font-size: var(--fs-heading-sm); font-weight: 700; color: var(--color-navy-900); margin-bottom: 14px; padding-left: 10px; border-left: 3px solid var(--color-amber-500); letter-spacing: .01em; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.card-title-row .card-title { margin-bottom: 0; }

.section-title { font-size: var(--fs-heading); font-weight: 800; color: var(--color-navy-900); padding: 20px 16px 6px; letter-spacing: .01em; text-wrap: balance; }
.section-hint { font-size: var(--fs-aux); color: var(--color-ink-soft); padding: 0 16px 14px; line-height: 1.55; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-grid--timeline { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-label); color: var(--color-ink-soft); }
.field--full { grid-column: 1 / -1; }
.field > span { font-weight: 700; color: var(--color-ink); }

.input, .textarea {
  min-height: var(--input-h);
  border: 2px solid var(--color-line-strong);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  font-size: var(--fs-body);
  color: var(--color-ink);
  background: #fff;
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .textarea:focus { border-color: var(--color-navy-600); box-shadow: 0 0 0 3px rgba(42,77,128,0.14); outline: none; }
.textarea { resize: vertical; min-height: 100px; }

/* -------------------- 撮影画面 -------------------- */
.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #0b1220;
  overflow: hidden;
}
.camera-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-instruction {
  position: absolute; top: 14px; left: 14px; right: 14px;
  text-align: center;
  background: rgba(10, 22, 38, 0.78);
  color: #fff;
  font-size: var(--fs-heading-sm);
  font-weight: 700;
  padding: 12px 14px;
  border-radius: var(--radius-m);
}
.camera-guide-frame {
  position: absolute;
  inset: 14% 8% 8%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.guide-corner {
  position: absolute;
  width: 34px; height: 34px;
  border-color: var(--color-amber-400);
  border-style: solid;
  border-width: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}
.guide-corner--tl { top: 0; left: 0; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 6px; }
.guide-corner--tr { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 6px; }
.guide-corner--bl { bottom: 0; left: 0; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 6px; }
.guide-corner--br { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 6px; }
.camera-guide-label {
  background: rgba(10, 22, 38, 0.78);
  color: #fff;
  font-size: var(--fs-aux);
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
  text-align: center;
}
.camera-error {
  position: absolute; inset: 0; margin: auto; height: fit-content;
  background: rgba(179, 38, 30, 0.94); color: #fff; padding: 18px; font-size: var(--fs-aux); text-align: center;
  border-radius: var(--radius-m);
}
.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  background: #0b1220;
}
#camera-controls-preview { flex-direction: column; gap: 12px; background: transparent; padding: 16px; }
.shutter-btn {
  width: 78px; height: 78px; border-radius: 50%;
  background: #fff; border: 4px solid rgba(255,255,255,0.35);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  transition: transform .08s ease;
}
.shutter-btn:active { background: var(--color-amber-100); transform: scale(0.94); }
#camera-controls-live .btn { color: #fff; background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.28); }
#camera-controls-live .btn:active { background: rgba(255,255,255,0.18); }
.capture-preview-caption {
  text-align: center;
  font-size: var(--fs-heading-sm);
  font-weight: 700;
  color: var(--color-navy-900);
  padding: 16px 16px 4px;
}

/* -------------------- 確認・修正画面 -------------------- */
.confirm-scroll { padding-top: 4px; padding-bottom: 100px; }
.warning-list { margin: 0 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.warning-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--color-amber-050);
  border: 1px solid var(--color-amber-100);
  border-left: 3px solid var(--color-amber-500);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  font-size: var(--fs-aux);
  color: #6a4600;
  line-height: 1.5;
}
.warning-item .icon { color: var(--color-amber-600); margin-top: 1px; }

.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-aux);
  font-weight: 700;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  letter-spacing: .01em;
}
.confidence-badge .icon { width: 16px; height: 16px; }
.confidence-badge[data-level="high"] { background: var(--color-green-100); color: var(--color-green-600); }
.confidence-badge[data-level="medium"] { background: var(--color-amber-100); color: var(--color-amber-600); }
.confidence-badge[data-level="low"] { background: var(--color-red-100); color: var(--color-red-600); }

.timeline-list { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { margin: 0; padding: 16px; }
.timeline-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.source-text { margin-top: 10px; font-size: var(--fs-aux); color: var(--color-ink-faint); border-top: 1px dashed var(--color-line); padding-top: 8px; line-height: 1.5; }

.missing-list { margin: 0; padding-left: 20px; font-size: var(--fs-aux); color: var(--color-ink-soft); line-height: 1.7; }
.missing-list li { margin-bottom: 4px; }

.uncertain-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--color-line);
  font-size: var(--fs-aux); gap: 12px; flex-wrap: wrap;
}
.uncertain-row:last-child { border-bottom: none; }

.bottom-action-bar {
  position: sticky;
  bottom: 0;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(238,241,246,0), var(--color-bg) 20%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bottom-action-bar--multi { flex-direction: column; }

/* -------------------- 「報告書を作る」結果サマリー画面 -------------------- */
.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  margin: 4px 16px 18px;
  overflow: hidden;
}
.summary-row {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-line);
}
.summary-row:last-child { border-bottom: none; }
.summary-row-label { font-size: var(--fs-aux); font-weight: 700; color: var(--color-ink-faint); }
.summary-row-value { font-size: var(--fs-body); font-weight: 700; color: var(--color-ink); line-height: 1.5; white-space: pre-wrap; }
.summary-event-list { display: flex; flex-direction: column; gap: 14px; }
.summary-event { padding: 14px 18px; border-bottom: 1px solid var(--color-line); }
.summary-event:last-child { border-bottom: none; }
.summary-event-time { font-size: var(--fs-body); font-weight: 800; color: var(--color-navy-800); }
.summary-event-body { font-size: var(--fs-body); color: var(--color-ink); line-height: 1.55; margin-top: 4px; }
.summary-event-confidence { margin-top: 8px; }

.result-hero {
  text-align: center;
  padding: 40px 24px 24px;
}
.result-hero-icon {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--color-green-100); color: var(--color-green-600);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.result-hero-icon .icon { width: 44px; height: 44px; }
.result-hero-title { font-size: var(--fs-heading); font-weight: 800; color: var(--color-navy-900); text-wrap: balance; }
.result-hero-desc { font-size: var(--fs-body); color: var(--color-ink-soft); margin-top: 10px; line-height: 1.6; }
.result-actions { display: flex; flex-direction: column; gap: 12px; padding: 8px 16px 16px; }

/* -------------------- 分岐選択画面(報告書を作る / 帳票選択の簡易表示) -------------------- */
.choice-list { display: flex; flex-direction: column; gap: 16px; padding: 8px 16px 16px; }
.choice-hint { font-size: var(--fs-body); color: var(--color-ink-soft); padding: 8px 16px 4px; line-height: 1.6; }

.default-report-card {
  margin: 8px 16px 16px;
  padding: 20px;
  background: var(--color-navy-050);
  border: 2px solid var(--color-navy-600);
  border-radius: var(--radius-m);
  text-align: center;
}
.default-report-card-label { font-size: var(--fs-aux); color: var(--color-ink-soft); margin-bottom: 6px; }
.default-report-card-value { font-size: var(--fs-heading-sm); font-weight: 800; color: var(--color-navy-900); }
.link-btn {
  display: block; width: 100%; text-align: center;
  background: none; border: none; color: var(--color-navy-700);
  font-size: var(--fs-button-sm); font-weight: 700; text-decoration: underline;
  min-height: 48px; cursor: pointer;
}

/* -------------------- 報告書選択 -------------------- */
.report-type-list { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.report-type-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--color-surface); border: 2px solid var(--color-line); border-radius: var(--radius-m);
  padding: 16px; box-shadow: var(--shadow-card);
  transition: border-color .12s ease;
  min-height: var(--tap-primary);
}
.report-type-item:has(input:checked) { border-color: var(--color-navy-500); background: var(--color-navy-050); }
.report-type-item input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--color-navy-800); flex-shrink: 0; }
.report-type-item-label { font-weight: 700; font-size: var(--fs-body); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-type-item-desc { font-size: var(--fs-aux); color: var(--color-ink-soft); margin-top: 4px; }

/* -------------------- 帳票プレビュー -------------------- */
.report-tabs {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 12px 16px; background: var(--color-surface); border-bottom: 1px solid var(--color-line);
  position: sticky; top: calc(var(--header-h) + var(--safe-top)); z-index: 10;
}
.report-tab {
  flex: 0 0 auto; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--color-line-strong);
  background: #fff; font-size: var(--fs-button-sm); font-weight: 700; color: var(--color-ink-soft); cursor: pointer; white-space: nowrap;
  transition: background-color .12s ease, color .12s ease;
}
.report-tab.is-active { background: var(--color-navy-800); color: #fff; border-color: var(--color-navy-800); }
.report-preview-scroll { padding: 18px 14px; }
.report-sheet-slot { display: none; }
.report-sheet-slot.is-active { display: block; }

/* A4帳票の画面内プレビュー（実寸ではなく縮小表示。文字サイズ設定の影響を受けない固定サイズ） */
.a4-sheet {
  /* 公式書類らしい認証感を出すため、ごく薄い斜め罫（セキュリティペーパー調）を地紋として敷く。
     印刷インクへの影響を避けるため極めて低いコントラストに抑える。 */
  background-color: #fff;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(15, 31, 56, 0.025) 0px,
    rgba(15, 31, 56, 0.025) 1px,
    transparent 1px,
    transparent 7px
  );
  border: 1px solid var(--color-line);
  box-shadow: var(--shadow-card-hover);
  padding: 16mm 14mm;
  margin: 0 auto 22px;
  max-width: 210mm;
  min-height: 297mm;
  font-size: 13px;
  color: #16202f;
  font-feature-settings: "palt";
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.a4-sheet + .a4-sheet { margin-top: 24px; }
.a4-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding-bottom: 10px; margin-bottom: 16px;
  border-bottom: 2.5px solid var(--color-navy-800);
  position: relative;
}
.a4-header::after {
  content: ""; position: absolute; left: 0; bottom: -5px; width: 46px; height: 2px; background: var(--color-amber-500);
}
.a4-header-title { font-size: 20px; font-weight: 800; color: var(--color-navy-900); letter-spacing: .02em; }
.a4-header-meta { text-align: right; font-size: 11px; color: #4a5164; line-height: 1.6; }
.a4-section { margin-bottom: 15px; }
.a4-section-title {
  font-size: 12.5px; font-weight: 700; color: var(--color-navy-900);
  background: var(--color-navy-050); border-left: 3px solid var(--color-navy-700);
  padding: 5px 9px; margin-bottom: 7px; letter-spacing: .01em;
}
/* 画面プレビューは実寸(210mm)より狭いため、ラベルが一文字ずつ縦に折り返されるのを防ぎつつ、
   横に入りきらない場合はテーブルごと横スクロールさせる（印刷時は実寸で収まるため影響しない）。 */
.a4-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.a4-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.a4-table th, .a4-table td { border: 1px solid #c3cad9; padding: 6.5px 9px; text-align: left; vertical-align: top; }
.a4-table th { background: var(--color-navy-050); width: 1%; white-space: nowrap; font-weight: 700; color: var(--color-navy-900); }
.a4-events-table { min-width: 560px; }
.a4-events-table th, .a4-events-table td { border: 1px solid #c3cad9; padding: 5.5px 7px; font-size: 11px; white-space: nowrap; }
.a4-events-table td { white-space: normal; min-width: 64px; }
.a4-events-table th { text-align: center; width: auto; }
.a4-footer { display: flex; justify-content: space-between; font-size: 10px; color: #6b7386; margin-top: 22px; border-top: 1px solid #d6dae3; padding-top: 7px; }
.a4-sign-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.a4-sign-box { border: 1px solid #c3cad9; width: 112px; height: 62px; text-align: center; font-size: 10px; border-radius: 3px; overflow: hidden; }
.a4-sign-box-label { border-bottom: 1px solid #c3cad9; padding: 4px; background: var(--color-navy-050); font-weight: 700; color: var(--color-navy-800); }
.a4-warning { background: var(--color-amber-050); border: 1px solid var(--color-amber-100); padding: 7px 9px; font-size: 11px; margin-bottom: 10px; border-radius: 4px; }
.a4-blank { color: #c0c6d2; }
.a4-empty-note { font-size: 11px; color: #8790a3; padding: 4px 2px; font-style: italic; }
.a4-text-block { font-size: 12px; white-space: pre-wrap; border: 1px solid #c3cad9; padding: 9px; min-height: 40px; border-radius: 3px; line-height: 1.65; }

/* -------------------- 履歴 -------------------- */
.history-search-simple { display: flex; gap: 10px; padding: 14px 16px; }
.history-search-simple .input { flex: 1; }
.history-search-toggle { text-align: center; padding: 0 16px 8px; }
.history-search-advanced { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 4px 16px 16px; }
.history-search-advanced .btn { width: 100%; }
.history-list { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.history-item {
  background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-m);
  padding: 18px; box-shadow: var(--shadow-card); cursor: pointer;
  transition: box-shadow .12s ease;
}
.history-item:active { box-shadow: var(--shadow-card); }
.history-item-top { display: flex; justify-content: space-between; font-size: var(--fs-aux); color: var(--color-ink-faint); }
.history-item-title { font-weight: 800; font-size: var(--fs-heading-sm); margin: 6px 0 10px; color: var(--color-navy-900); line-height: 1.4; }
.history-item-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.history-tag { font-size: var(--fs-aux); font-weight: 600; background: var(--color-navy-050); color: var(--color-navy-700); padding: 4px 12px; border-radius: 999px; }
.history-empty { text-align: center; color: var(--color-ink-soft); padding: 48px 16px; font-size: var(--fs-body); }

/* -------------------- 設定 -------------------- */
.settings-menu { display: flex; flex-direction: column; margin: 8px 16px; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-m); overflow: hidden; box-shadow: var(--shadow-card); }
.settings-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--tap-primary); padding: 0 18px; border: none; border-bottom: 1px solid var(--color-line);
  background: #fff; font-size: var(--fs-body); font-weight: 600; cursor: pointer; text-align: left; color: var(--color-ink);
}
.settings-menu-item:active { background: var(--color-navy-050); }
.settings-menu-item:last-child { border-bottom: none; }
.settings-menu-item-main { display: flex; align-items: center; gap: 14px; }
.settings-menu-item-main .icon { color: var(--color-navy-700); }
.chevron { color: var(--color-line-strong); width: 22px; height: 22px; }
.app-version { text-align: center; color: var(--color-ink-faint); font-size: var(--fs-aux); padding: 22px; letter-spacing: .02em; }

.sites-list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.site-item { background: #fff; border: 1px solid var(--color-line); border-radius: var(--radius-s); padding: 14px; display: flex; flex-direction: column; gap: 10px; font-size: var(--fs-aux); }
.site-item-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.site-item-name { font-size: var(--fs-body); font-weight: 700; color: var(--color-ink); }
.site-item-default { font-size: var(--fs-aux); color: var(--color-navy-700); }

.gemini-status-card { text-align: center; }
.status-badge {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 16px;
  background: var(--color-navy-050); color: var(--color-line-strong);
  border: 2px solid var(--color-line);
  transition: all .15s ease;
}
.status-badge.is-ok { background: var(--color-green-100); color: var(--color-green-600); border-color: var(--color-green-600); }
.status-badge.is-error { background: var(--color-red-100); color: var(--color-red-600); border-color: var(--color-red-600); }
.gemini-status-line { font-size: var(--fs-body); font-weight: 700; margin-bottom: 8px; color: var(--color-ink); }
.gemini-status-model { font-size: var(--fs-aux); color: var(--color-ink-soft); margin-bottom: 18px; }
.gemini-status-note { font-size: var(--fs-aux); color: var(--color-ink-faint); margin-top: 14px; line-height: 1.5; }
.gemini-status-note a { color: var(--color-navy-700); }

.card .field + .field { margin-top: 16px; }
.input-with-btn { display: flex; gap: 8px; align-items: stretch; }
.input-with-btn .input { flex: 1; min-width: 0; }
.input-with-btn .btn { flex: 0 0 auto; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { flex: 1; }

/* 文字サイズ選択 */
.text-size-options { display: flex; flex-direction: column; gap: 12px; }
.text-size-option {
  display: flex; align-items: center; gap: 14px;
  border: 2px solid var(--color-line-strong); border-radius: var(--radius-m);
  padding: 16px; cursor: pointer; background: #fff; min-height: var(--tap-primary);
}
.text-size-option input[type="radio"] { width: 26px; height: 26px; accent-color: var(--color-navy-800); flex-shrink: 0; }
.text-size-option.is-selected { border-color: var(--color-navy-600); background: var(--color-navy-050); }
.text-size-option-label { font-weight: 700; color: var(--color-ink); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.toggle-row-label { font-size: var(--fs-body); font-weight: 700; color: var(--color-ink); }
.toggle-row-desc { font-size: var(--fs-aux); color: var(--color-ink-soft); margin-top: 4px; }
.switch { position: relative; display: inline-block; width: 58px; height: 34px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--color-line-strong); border-radius: 999px;
  transition: background-color .15s ease; cursor: pointer;
}
.switch-track::before {
  content: ""; position: absolute; width: 26px; height: 26px; left: 4px; top: 4px;
  background: #fff; border-radius: 50%; transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .switch-track { background: var(--color-navy-700); }
.switch input:checked + .switch-track::before { transform: translateX(24px); }

/* -------------------- モーダル -------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 18, 32, 0.6);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
  padding: 0;
}
.modal-card {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 26px 22px calc(26px + var(--safe-bottom));
  box-shadow: var(--shadow-modal);
  max-height: 85vh; overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius-l); }
}
.modal-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.modal-icon--info { background: var(--color-navy-050); color: var(--color-navy-700); }
.modal-icon--danger { background: var(--color-red-100); color: var(--color-red-600); }
.modal-icon--warn { background: var(--color-amber-100); color: var(--color-amber-600); }
.modal-card h2 { font-size: var(--fs-heading-sm); margin-bottom: 12px; color: var(--color-navy-900); letter-spacing: .01em; line-height: 1.4; }
.modal-card p { font-size: var(--fs-aux); color: var(--color-ink-soft); margin-bottom: 10px; line-height: 1.6; }
.consent-points { font-size: var(--fs-aux); color: var(--color-ink-soft); padding-left: 20px; margin-bottom: 18px; line-height: 1.8; }
.consent-points li { margin-bottom: 6px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.candidate-options { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.candidate-option-btn {
  text-align: left; padding: 14px 16px; border-radius: var(--radius-s);
  border: 2px solid var(--color-line-strong); background: #fff; font-size: var(--fs-body); cursor: pointer;
  min-height: var(--tap-min);
}
.candidate-option-btn.is-selected { border-color: var(--color-navy-800); background: var(--color-navy-050); }

/* -------------------- トースト & ローディング -------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--color-navy-900); color: #fff; padding: 14px 24px; border-radius: 999px;
  font-size: var(--fs-aux); font-weight: 600; z-index: 200; max-width: 90vw; text-align: center;
  box-shadow: var(--shadow-modal);
}
.toast.is-error { background: var(--color-red-600); }
.toast.is-success { background: var(--color-green-600); }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(10, 18, 32, 0.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  z-index: 300; color: #fff; font-size: var(--fs-heading-sm); font-weight: 700; text-align: center; padding: 24px;
}
.loading-overlay-sub { font-size: var(--fs-aux); font-weight: 400; color: rgba(255,255,255,0.75); margin-top: -8px; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.2); border-top-color: var(--color-amber-400);
  animation: spin .75s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------- レスポンシブ(タブレット以上) -------------------- */
@media (min-width: 720px) {
  body { max-width: 720px; margin: 0 auto; box-shadow: 0 0 32px rgba(9,17,33,0.1); }
}

.no-print { }
