/* ============================================================
   Lucina Tools 臨床メモツール
   方針：ナースステーションの申し送りボード／白衣ポケットの臨床カード。
   清潔・落ち着き・実用・信頼感。白＋温かいオフホワイト＋ブルーグレー。
   ブランドカラー(コーラル)は主要ボタンなどアクセントに絞る。
   ============================================================ */

:root {
  --paper: #ffffff;
  --bg: #edebe5;            /* 温かいオフホワイトの地（ボードとの面差を出すため一段深く） */
  --panel: #fbfaf7;         /* 入力ボードの面 */
  --ink: #23282d;           /* 強い文字（スレートブラック） */
  --ink-2: #47525c;         /* 本文 */
  --ink-3: #7c858d;         /* 補助 */
  --line: #e5e5e0;          /* ヘアライン */
  --line-2: #d7d8d2;
  --slate: #44607a;         /* 構造・信頼のブルーグレー */
  --slate-bg: #eef1f4;
  --coral: #dd5f7d;         /* 主要アクション専用 */
  --coral-deep: #c2495f;
  --coral-bg: #fceef1;
  --sky: #3f8db0;           /* 心電図モードのアクセント */
  --sky-bg: #ebf3f7;
  --warn: #a9742a;          /* 注意（落ち着いたアンバー） */
  --warn-bg: #faf3e3;
  --warn-line: #ead9b4;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-memo: 0 1px 2px rgba(40,45,50,0.04), 0 6px 18px rgba(40,45,50,0.06);
  --font: "Noto Sans JP", system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;

  --accent: var(--coral);   /* モードの差し色（既定＝報告整理＝コーラル） */
}
.wrap[data-mode="ecg"] { --accent: var(--sky); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-feature-settings: "palt";
  color: var(--ink-2);
  line-height: 1.8;
  background: var(--bg);
}

.wrap { max-width: 760px; margin: 0 auto; padding: 22px 20px 56px; }

/* ---------- マストヘッド ---------- */
.masthead { margin-bottom: 18px; }
.mast-top { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.mast-id { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mast-brand {
  font-size: 12px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--slate); text-transform: uppercase;
}
.mast-title {
  font-size: 22px; font-weight: 900; letter-spacing: -0.01em;
  color: var(--ink); margin: 0 0 6px; line-height: 1.35;
}
.mast-lead { font-size: 13px; color: #5a646d; margin: 0; line-height: 1.7; max-width: 56ch; }

.logout-btn {
  font-family: var(--font); font-size: 11.5px; font-weight: 600;
  color: var(--ink-3); background: transparent;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; /* タップターゲット44px確保 */
}
.logout-btn:hover { background: var(--paper); color: var(--ink-2); }

/* ---------- 場面セレクタ（ツール集に見せる） ---------- */
.scene-tabs { display: flex; gap: 8px; margin-top: 16px; }
.scene-tab {
  flex: 1 1 0; min-width: 0; text-align: left; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line-2);
  border-top: 2px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-family: var(--font); transition: border-color .15s, background .15s;
}
.scene-tab .scene-name { display: block; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.scene-tab .scene-sub { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }
.scene-tab:hover { background: var(--panel); }
.scene-tab.is-active {
  border-color: var(--line-2); border-top-color: var(--accent);
  background: var(--paper);
}
.scene-tab.is-active .scene-name { color: var(--ink); }
.scene-tab.is-active .scene-sub { color: var(--accent); }
.scene-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 入力ボード（カードで囲まず、面＋罫線で整理） ---------- */
.board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 22px;
  margin-top: 16px;
  position: relative;
}
.board-head { margin-bottom: 14px; }
.board-title { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 3px; }
.board-note { font-size: 12.5px; color: var(--ink-3); margin: 0; line-height: 1.7; }

.try-btn {
  display: block; width: 100%; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 18px;
}
.try-btn::before { content: "▶ "; font-size: 11px; color: var(--slate); }
.try-btn:hover { background: var(--slate-bg); }

.fgroup-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--slate); margin: 18px 0 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.fgroup { display: block; }
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field-key label { color: var(--ink); font-weight: 700; }

.field textarea, .field select, .field input {
  width: 100%; font-family: var(--font); font-size: 15px; line-height: 1.7;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.field textarea { resize: vertical; }
.field-key textarea { border-color: #c7ccca; background: #fffefb; }
.field textarea::placeholder { color: #9aa2a9; }
.field textarea:focus, .field select:focus, .field input:focus {
  outline: none; border-color: var(--slate);
  box-shadow: 0 0 0 3px rgba(68,96,122,0.12);
}
.field select {
  cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237c858d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
  padding-right: 34px;
}

/* ---------- ボタン ---------- */
.actions { display: flex; align-items: center; gap: 14px; margin-top: 20px; }
.btn-go {
  font-family: var(--font); font-size: 14.5px; font-weight: 700;
  color: #fff; background: var(--coral);
  border: none; border-radius: var(--radius-sm);
  padding: 12px 24px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(194,73,95,0.18);
  transition: background .15s, transform .1s;
}
.btn-go:hover { background: var(--coral-deep); }
.btn-go:active { transform: translateY(1px); }
.btn-go:focus-visible { outline: 2px solid var(--coral-deep); outline-offset: 2px; }
.btn-text {
  font-family: var(--font); font-size: 13px; color: var(--ink-3);
  background: none; border: none; cursor: pointer;
  padding: 11px 12px; /* タップターゲット44px確保 */
}
.btn-text:hover { color: var(--ink-2); text-decoration: underline; }
.btn-line {
  font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--slate);
  background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 11px 14px; cursor: pointer; /* タップターゲット44px確保 */
}
.btn-line:hover { background: var(--slate-bg); }
.btn-line.subtle { color: var(--ink-3); }

/* ---------- 通知 ---------- */
.notice, .notice-area {
  margin-top: 14px; padding: 10px 13px; border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.6;
}
.notice-info { background: var(--slate-bg); border: 1px solid #d6dde2; color: var(--ink-2); }
.notice-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); }

/* ---------- 心電図 波形モチーフ ---------- */
.ecg-motif { display: block; width: 100%; height: 24px; margin: -2px 0 14px; color: var(--sky); opacity: 0.45; }
.ecg-motif svg { display: block; width: 100%; height: 100%; }

/* ============================================================
   出力＝申し送りメモ（紙・臨床カード）
   ============================================================ */
.memo {
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-memo);
  padding: 20px 20px 22px;
  margin-top: 16px;
}

.yuka-lead { font-size: 12.5px; color: var(--slate); margin: 0 0 16px; line-height: 1.7; }

/* ブロック見出し：本文より一段立てて階層を作る（申し送り項目） */
.result-heading {
  font-size: 13.5px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--slate); text-transform: none;
  margin: 20px 0 9px; padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.result-heading:first-child { margin-top: 0; }
.result-heading.danger-heading { color: var(--warn); border-bottom-color: var(--warn-line); }
.result-heading.danger-heading::before { content: "⚠ "; }
/* 答え合わせパートと参照パート（つながり以降）の間に余白の段差 */
.result-heading.part-break { margin-top: 32px; }

/* 報告文のたたき台＝一番見せたいブロック。面と差し色で立てる */
.report-text {
  white-space: pre-wrap; word-break: break-word;
  background: #f7f5ef; border: 1px solid var(--line);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-sm); padding: 16px 18px;
  font-size: 15px; line-height: 1.95; color: var(--ink);
}
.copy-btn { margin-top: 12px; }

.danger-intro { font-size: 12.5px; line-height: 1.7; color: var(--warn); margin: 0 0 9px; }
.chain-intro { font-size: 12.5px; line-height: 1.7; color: var(--ink-3); margin: 0 0 9px; }
.yuka-voice {
  font-size: 13px; line-height: 1.75; color: var(--coral-deep);
  background: var(--coral-bg); border-radius: var(--radius-sm);
  padding: 10px 13px; margin: 11px 0 0;
}

.check-list, .plain-list { margin: 0; padding-left: 1.35em; }
.check-list li, .plain-list li { margin: 5px 0; font-size: 14px; line-height: 1.7; color: var(--ink-2); }
.check-list li { font-size: 15px; }
.check-list li::marker { color: var(--slate); }
.plain-list li::marker { color: var(--ink-3); }

.missing-intro { font-size: 13px; color: var(--ink-2); margin: 0 0 6px; }
.missing-none { font-size: 13px; color: var(--slate); margin: 0; }
.missing-none::before { content: "✓ "; font-weight: 700; }

/* ---------- 履歴 ---------- */
.history { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.history-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.history-title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 0; }
.history-actions { display: flex; gap: 8px; }

.history-item { padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: none; }
.history-head { display: flex; align-items: center; gap: 9px; margin-bottom: 3px; }
.history-time { font-size: 11.5px; color: var(--ink-3); }
.history-mode { font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: var(--radius-sm); }
.history-mode.mode-report { background: var(--coral-bg); color: var(--coral-deep); }
.history-mode.mode-ecg { background: var(--sky-bg); color: var(--sky); }
.history-disease { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.history-now { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.history-report { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.history-empty { font-size: 13px; color: var(--ink-3); padding: 6px 0; }

/* ---------- フッタ（注記は控えめ） ---------- */
.foot { margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--line); }
.foot-note { font-size: 11px; color: var(--ink-3); line-height: 1.7; margin: 0 0 6px; }
.foot-meta { font-size: 10.5px; color: #a8afb4; margin: 8px 0 0; }

.placeholder-note { color: var(--ink-3); font-size: 14px; margin: 0; }

/* ============================================================
   ログイン（購入者限定ツールに見せる）
   ============================================================ */
.login-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 22px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--paper); border: 1px solid var(--line-2);
  border-top: 3px solid var(--coral);
  border-radius: var(--radius); box-shadow: var(--shadow-memo);
  padding: 32px 28px 28px;
}
.login-brand { font-size: 19px; font-weight: 900; letter-spacing: 0.04em; color: var(--ink); margin: 0 0 6px; }
.login-lead { font-size: 13px; color: var(--ink-2); margin: 0 0 14px; }
.login-limited {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--slate); background: var(--slate-bg);
  border-radius: var(--radius-sm); padding: 3px 12px; margin: 0 0 20px;
}
.login-fields { text-align: left; margin-bottom: 18px; }
.login-fields .field { margin-bottom: 12px; }
.login-card .btn-go { width: 100%; }
.login-error { color: var(--coral-deep); font-size: 12.5px; margin: 12px 0 0; }

/* ============================================================
   答え合わせ（ゆか式・8ブロック）※棒線アクセント禁止＝色差と余白で
   ============================================================ */
.field-hint { font-size: 11px; color: var(--ink-3); line-height: 1.6; margin: 4px 0 0; }

.kotae-accept {
  font-size: 14px; line-height: 1.85; color: #8d3d50;
  background: var(--coral-bg); border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 0 0 4px;
}

/* 生成直後、受容箱だけふわっと出す（js側でanim-in→is-shownを付与） */
.anim-in { opacity: 0; transform: translateY(8px); transition: opacity .3s ease, transform .3s ease; }
.anim-in.is-shown { opacity: 1; transform: none; }
.kotae-sub {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--slate); margin: 14px 0 6px;
}
.kotae-agree { list-style: none; margin: 0; padding: 0; }
.kotae-agree li {
  font-size: 14px; line-height: 1.75; color: var(--ink-2);
  padding-left: 1.4em; position: relative; margin: 5px 0;
}
.kotae-agree li::before {
  content: "✓"; position: absolute; left: 0.15em; top: 0;
  color: var(--coral-deep); font-weight: 700;
}
.kotae-agree .agree-label { font-weight: 700; color: var(--ink); }
.kotae-gap {
  font-size: 14px; line-height: 1.8; color: var(--ink);
  background: var(--slate-bg); border-radius: var(--radius-sm);
  padding: 11px 14px;
}
.kotae-gap .gap-label { font-weight: 700; color: var(--slate); }
.kotae-next { font-size: 13.5px; line-height: 1.75; color: var(--ink-2); margin: 8px 0 0; }
.kotae-extra { font-size: 13.5px; line-height: 1.8; color: var(--ink-2); margin: 10px 0 0; }
.homework-note {
  font-size: 13px; line-height: 1.7; color: var(--slate);
  background: var(--paper); border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm); padding: 9px 12px; margin: 14px 0 0;
}
.homework-note .hw-tag { font-weight: 700; letter-spacing: 0.04em; margin-right: 6px; }
.homework-back {
  font-size: 13px; line-height: 1.7; color: var(--coral-deep);
  background: var(--coral-bg); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 0 0 10px;
}
.streak-note { font-size: 12px; color: var(--ink-3); margin: 8px 0 0; }

/* 入力の整理（事実の並べ直し） */
.fact-rows { margin: 0; }
.fact-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.fact-row:last-child { border-bottom: none; }
.fact-label { flex: 0 0 8.5em; font-size: 12px; color: var(--ink-3); padding-top: 2px; }
.fact-value { flex: 1 1 auto; font-size: 13.5px; line-height: 1.7; color: var(--ink); word-break: break-word; }

/* ゆか式メモ・固定フッタ */
.yuka-memo {
  font-size: 13.5px; line-height: 1.85; color: var(--coral-deep);
  background: var(--coral-bg); border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.yuka-memo .memo-sig { display: block; margin-top: 4px; font-size: 11px; color: #c98a9b; }
.fixed-footer {
  font-size: 12px; line-height: 1.75; color: var(--warn);
  background: var(--warn-bg); border-radius: var(--radius-sm);
  padding: 10px 13px; margin-top: 18px;
}

/* PIIガード */
.field.pii-flag textarea {
  border-color: var(--warn);
  box-shadow: 0 0 0 3px rgba(169, 116, 42, 0.14);
}
.pii-msg { margin: 0 0 8px; }
.pii-ok-btn { display: inline-block; }

@media (max-width: 560px) {
  .fact-row { flex-direction: column; gap: 1px; }
  .fact-label { flex-basis: auto; color: var(--ink-2); }
}

/* ---------- 動きを減らす設定の人にはアニメを出さない ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto !important; }
  .anim-in { opacity: 1; transform: none; }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 560px) {
  .wrap { padding: 16px 14px 40px; }
  .mast-title { font-size: 19px; }
  .scene-tabs { gap: 6px; }
  .scene-tab { padding: 8px 9px; }
  .scene-tab .scene-sub { display: none; }      /* 狭い時はサブ説明を隠してタブ崩れ防止 */
  .board, .memo { padding: 16px 15px 18px; }
  .actions { gap: 10px; }
  .btn-go { flex: 1; text-align: center; }
}

/* ---------- 夜勤モード（暗い詰所で眩しくない） ---------- */
html[data-theme="night"] {
  --paper: #20262c;
  --bg: #171b20;
  --panel: #232a31;
  --ink: #e8eaec;
  --ink-2: #c3c9cf;
  --ink-3: #8b949c;
  --line: #333b43;
  --line-2: #3d454e;
  --slate: #93b3cd;
  --slate-bg: #26313b;
  --coral: #e57e97;
  --coral-deep: #ef9db1;
  --coral-bg: #372028;
  --sky: #6fb3d2;
  --sky-bg: #1e2c34;
  --warn: #d9a75a;
  --warn-bg: #2e2618;
  --warn-line: #4a3b22;
  --shadow-memo: 0 1px 2px rgba(0,0,0,0.4), 0 6px 18px rgba(0,0,0,0.35);
}
html[data-theme="night"] .mast-lead { color: var(--ink-3); }
html[data-theme="night"] .field-key textarea { border-color: #4a545d; background: #262e36; }
html[data-theme="night"] .field textarea::placeholder { color: #6b757e; }
html[data-theme="night"] .foot-meta { color: #6b7379; }
html[data-theme="night"] .kotae-accept { color: #f2b9c8; }
html[data-theme="night"] .yuka-memo .memo-sig { color: #b98a97; }
.theme-btn { margin-right: 6px; color: var(--ink-2); }

/* 数値アラート（答え合わせ直後・2行だけ） */
.fired-inline {
  margin: 14px 0 4px; padding: 10px 14px;
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  border-radius: var(--radius-sm);
}
.fired-inline .fired-tag { display: block; font-size: 12.5px; font-weight: 700; color: var(--warn); margin-bottom: 2px; }
.fired-inline p { margin: 2px 0; font-size: 14px; color: var(--ink-2); }

/* 夜勤モードの残修正（実Chromium批評 2026-08-13） */
html[data-theme="night"] .report-text { background: #262e36; border-color: var(--line-2); }
html[data-theme="night"] .btn-go { background: #c2495f; }
html[data-theme="night"] .btn-go:hover, html[data-theme="night"] .btn-go:active { background: #b04255; }
html[data-theme="night"] .foot-meta { color: #8b949c; }

/* ---------- 入力の整理（折りたたみ） ---------- */
.fact-details { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 10px; }
.fact-details summary {
  cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink-2);
  list-style: none; -webkit-tap-highlight-color: transparent; min-height: 44px; display: flex; align-items: center;
}
.fact-details summary::before { content: "▸ "; margin-right: 2px; }
.fact-details[open] summary::before { content: "▾ "; }

/* タップ44px未満の残り（実Chromium実測 2026-08-13） */
.scene-tab, .btn-text, .btn-line, .logout-btn { min-height: 44px; }

/* 実Chromium深掘り批評の反映（2026-08-13） */
.btn-go { background: var(--coral-deep); }              /* 昼の白文字CTA 3.50→4.76 */
.result-heading { font-size: 15.5px; }                  /* 見出し<本文の階層反転を解消 */
.kotae-accept { font-size: 16px; font-weight: 600; }    /* クライマックスを箇条書きと同級にしない */


/* ── 入力の進み具合（2026-08-27） ───────────────────
   忙しい人が「あとどれを書けばいいか」で迷わないようにする */
.meter { margin: 2px 0 18px; }
.meter-track {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: rgba(0, 0, 0, .07);
}
.meter-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #c98b93, #a2454f);
  transition: width .32s ease;
}
.meter-msg {
  margin: 7px 0 0; font-size: .82rem; line-height: 1.6;
  color: var(--muted, #7b6f6f);
}
.draft-note {
  margin: -10px 0 16px; padding: 8px 12px;
  font-size: .8rem; line-height: 1.6; border-radius: 8px;
  color: #6b5b5b; background: rgba(162, 69, 79, .06);
}
/* 「確認したいこと」は答えの並びを決める欄なので、少しだけ強調する */
.field-ask label::after {
  content: "答えの並びが変わる";
  margin-left: 8px; padding: 2px 8px;
  font-size: .68rem; font-weight: 600; letter-spacing: .02em;
  border-radius: 999px; vertical-align: 2px;
  color: #a2454f; background: rgba(162, 69, 79, .1);
}
/* スマホで押しやすく。生成ボタンは画面下に貼りつける */
@media (max-width: 640px) {
  .actions {
    position: sticky; bottom: 0; z-index: 5;
    margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(255, 252, 250, 0), var(--bg, #fffcfa) 34%);
  }
  .btn-go { width: 100%; min-height: 52px; font-size: 1.02rem; }
  .field textarea { font-size: 16px; }   /* iOSで勝手に拡大されないように */
}
