/* 音声SOAP — iPad（Safari）で指で押しやすく。文字は 17px、押す所は 44px 以上 */
:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --ink: #1c2329;
  --muted: #5e6a75;
  --line: #d8dee4;
  --pri: #0a6a93;
  --pri-weak: #e3f1f7;
  --rec: #d13434;
  --ok: #1d7a4c;
  --ok-weak: #e3f4ea;
  --warn-bg: #fff3d1;
  --warn-ink: #6a4b00;
  --err-bg: #fde7e7;
  --err-ink: #9a1c1c;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
}
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
a { color: var(--pri); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95em; background: #eef2f5; padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- ヘッダ ---- */
header.top {
  display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 19px; color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 14px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; }
.nav a.on { background: var(--pri-weak); color: var(--pri); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.who a { color: var(--muted); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }
form.inline { display: inline; }

.banner { padding: 10px 16px; font-size: 15px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid #f0dca0; }
.flashes { max-width: 900px; margin: 12px auto 0; padding: 0 16px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; background: #fff; border: 1px solid var(--line); }
.flash.ok { background: var(--ok-weak); border-color: #b9e0c9; }
.flash.err { background: var(--err-bg); border-color: #f3c0c0; color: var(--err-ink); }
.flash.info { background: var(--pri-weak); border-color: #bcdcea; }

main { max-width: 900px; margin: 0 auto; padding: 16px; padding-bottom: max(32px, env(safe-area-inset-bottom)); }
main.wide { max-width: 1180px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.narrow, .narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }

/* ---- 入力・ボタン ---- */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; min-height: 44px; width: 100%;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 3px solid #9fd0e6; outline-offset: 0; border-color: var(--pri); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.small { min-height: 38px; padding: 4px 12px; font-size: 15px; }
.btn.ghost { background: transparent; }
.btn-ghost-danger { background: transparent; color: var(--err-ink); border-color: #efc4c4; }
.btn.wide { width: 100%; margin-top: 18px; }
.btn.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.err { background: var(--err-bg); color: var(--err-ink); padding: 10px 14px; border-radius: 10px; margin: 10px 0; }
.note { background: var(--pri-weak); padding: 10px 14px; border-radius: 10px; }
.tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: #eef2f5; color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-weak); color: var(--ok); }
.tag.pri { background: var(--pri-weak); color: var(--pri); }
.tag.err { background: var(--err-bg); color: var(--err-ink); }
.tag.warn { background: var(--warn-bg); color: var(--warn-ink); }

/* ---- 録音 ---- */
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button {
  flex: 1; min-height: 56px; border: 0; background: #fff; font: inherit; font-weight: 700; color: var(--ink);
  padding: 8px 10px; cursor: pointer; line-height: 1.3; -webkit-tap-highlight-color: transparent;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--pri); color: #fff; }
.seg button[aria-pressed="true"] small { color: #d6ecf5; }
.seg button[disabled] { opacity: .6; }
.rec-fields details { margin-top: 10px; }
details > summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {            /* 開閉の印（flex にすると既定の ▸ が消えるので自前で描く） */
  content: ""; flex: none; width: 0; height: 0; margin-right: 2px;
  border-left: 8px solid var(--pri); border-top: 6px solid transparent; border-bottom: 6px solid transparent;
  transition: transform .15s;
}
details[open] > summary::before { transform: rotate(90deg); }
details > summary .muted { font-weight: 400; }
.rec-main { display: flex; align-items: center; gap: 24px; margin: 22px 0 8px; flex-wrap: wrap; justify-content: center; }
.recbtn {
  width: 172px; height: 172px; border-radius: 50%; border: 0; background: var(--rec); color: #fff;
  font: inherit; font-size: 19px; font-weight: 800; cursor: pointer; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 22px rgba(209, 52, 52, .32); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.recbtn .dot { width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.recbtn.on { background: #a51f1f; animation: pulse 1.6s ease-in-out infinite; }
.recbtn.on .dot { border-radius: 5px; }
.recbtn.busy { background: #7b8791; box-shadow: none; animation: none; cursor: progress; }
.recbtn.busy .dot { animation: spin 1s linear infinite; border-radius: 50%; background: transparent; border: 4px solid #fff; border-right-color: transparent; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(209, 52, 52, .45); } 50% { box-shadow: 0 0 0 18px rgba(209, 52, 52, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.rec-meta { flex: 1; min-width: 240px; }
.clock { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.clock #limit { color: var(--muted); font-weight: 600; font-size: 20px; }
.meter { height: 10px; background: #e7ecf0; border-radius: 5px; overflow: hidden; margin: 6px 0 10px; }
.meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.rec-state { margin: 0; }
/* 合図の 1 行と言い忘れ表示（2026-10-20 社長「まずは外来用」）。幅 500px の窓でも折り返すだけで崩れない */
.cue { margin: 0 0 6px; color: var(--muted); line-height: 1.5; }
.cue b { color: var(--ink); margin-right: 6px; }
.said { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
.said li { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); opacity: .5; white-space: nowrap; }
.said li::before { content: "□"; width: 1.2em; text-align: center; }
.said li.on { color: var(--ok); opacity: 1; font-weight: 700; }
.said li.on::before { content: "✓"; }
.live-text { margin: 0 0 8px; padding: 8px 12px; background: #f7fafc; border: 1px solid var(--line); border-radius: 10px; max-height: 7.5em; overflow-y: auto; font-size: 16px; white-space: pre-wrap; }
.rec-state.err { background: var(--err-bg); }
.rec-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.hints { margin: 14px 0 0; padding-left: 1.2em; }
.text-in textarea { margin: 6px 0 10px; }

/* ---- 下書き一覧 ---- */
.drafts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.drafts li { min-width: 0; }   /* 長い文で横にはみ出さない */
.drafts a { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); text-decoration: none; }
.drafts a:active { background: #f7fafc; }
.d-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.d-time { font-weight: 800; font-variant-numeric: tabular-nums; }
.d-label { font-weight: 700; }
.d-state { margin-left: auto; }
.d-snip { color: var(--muted); margin-top: 4px; min-height: 1.6em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); }

/* ---- 下書き ---- */
.draft-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.back { text-decoration: none; font-weight: 700; padding: 8px 4px; }
.draft-head .meta { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 240px; }
.label-in { width: 12em; min-height: 40px; }
.soap-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.checks { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; margin: 6px 0 12px; }
.checks ul { margin: 4px 0 0; padding-left: 1.2em; }
.kasan { background: var(--pri-weak); border-radius: 10px; padding: 10px 14px; margin: 6px 0 12px; }
.kasan ul { margin: 4px 0 0; padding-left: 1.2em; }
.warn-text { color: var(--warn-ink); }
.soap-empty { text-align: center; padding: 18px 0; }
.soap-field { display: grid; grid-template-columns: 46px 1fr; gap: 6px 12px; padding: 10px 0; border-top: 1px solid #edf1f4; }
.soap-field:first-child { border-top: 0; }
.soap-key { font-size: 26px; font-weight: 900; color: var(--pri); text-align: center; line-height: 1; padding-top: 14px; }
.soap-body label { margin-top: 0; }
.soap-body textarea { min-height: 84px; }
.field-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.unheard { margin-right: auto; color: var(--warn-ink); background: var(--warn-bg); padding: 2px 10px; border-radius: 999px; }
.btn.copy { min-width: 9.5em; }
.copy-all { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid #edf1f4; padding-bottom: 14px; margin-bottom: 4px; }
.drag {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 10px;
  border: 1px dashed var(--pri); color: var(--pri); background: var(--pri-weak); font-weight: 700;
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-user-drag: element; touch-action: none;
}
.drag:active, .drag.dragging { cursor: grabbing; background: #cfe7f2; }
.row-end { display: flex; justify-content: flex-end; margin-top: 10px; }
.save-state.err { color: var(--err-ink); }

/* ---- 管理 ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--pri); border-bottom-color: var(--pri); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.kpi .k { color: var(--muted); font-size: 14px; }
.kpi .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #edf1f4; vertical-align: middle; }
.tbl thead th { font-size: 14px; color: var(--muted); font-weight: 700; }
.tbl tfoot th { border-top: 2px solid var(--line); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.off td { color: var(--muted); background: #fafbfc; }
.tbl.small td { font-size: 14px; }
.rowform { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rowform input[name="name"] { width: 11em; flex: none; }
.rowform select { width: auto; flex: none; }
.rowform .lid { flex: none; }
.people td > form.inline { margin-left: 4px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; align-items: end; }
.grid-form label input, .grid-form label select { margin-top: 4px; font-weight: 400; }
.grid-end { grid-column: 1 / -1; margin-top: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv.big dd { font-size: 22px; font-weight: 800; }
.issued { border-color: #b9e0c9; background: var(--ok-weak); }

/* ---- お知らせ ---- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #22303a; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 640px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 50; font-size: 16px;
}
.toast.err { background: #8f1d1d; }
.toast.ok { background: #1d6b45; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .recbtn { width: 150px; height: 150px; }
  .who-name { display: none; }
  .soap-field { grid-template-columns: 30px 1fr; }
  .soap-key { font-size: 20px; }
}
.qr { max-width: 220px; margin: 12px auto; background: #fff; }
.qr svg { width: 100%; height: auto; display: block; }

/* 端末の登録コード（2026-10-09） */
.issued .devcode code { font-size: 2.4rem; letter-spacing: .15em; font-weight: 700; }
div.issued { border: 1px solid #b9e0c9; border-radius: 10px; padding: 12px 16px; margin: 12px 0; }

/* 往診同行（2026-10-12） */
.round h1 { margin: 0 0 4px; }
.round-now { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; margin: 14px 0 4px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.round-now label { grid-column: 1 / -1; margin: 0; }
.round-now .round-who { grid-row: span 2; font-size: 22px; font-weight: 700; color: var(--pri); }
.round-now input { font-size: 20px; }
.round-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 10px 0 6px; }
.round-actions .big { font-size: 20px; padding: 16px 28px; min-width: 220px; }
.round-alert { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-weight: 600; }
.round-list { list-style: none; padding: 0; margin: 6px 0; }
.round-list > li { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.round-list.big > li a { display: block; color: inherit; text-decoration: none; }
.orders, .orders-mini { margin: 6px 0 12px; }
.orders { background: #eef5ff; border-radius: 10px; padding: 10px 14px; }
.orders ul, .orders-mini { margin: 4px 0 0; padding-left: 1.2em; }
.orders-mini { font-size: 14px; }
pre.summary { white-space: pre-wrap; font-family: inherit; background: #f6f7f8; border-radius: 10px; padding: 10px 14px; min-height: 2em; }

/* 店の PC（Musubi の横に幅 500px ほどの窓で並べる。2026-10-13） */
.btn.copy-big { font-size: 20px; padding: 14px 28px; min-height: 56px; }
.btn.logout-btn { white-space: nowrap; }
@media (max-width: 560px) {
  main { padding: 10px; }
  .card { padding: 14px; }
  header.top { flex-wrap: wrap; row-gap: 4px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .copy-all { gap: 8px; }
  .btn.copy-big { width: 100%; }
  .copy-all .drag, .soap-field .drag { display: none; }   /* 狭い窓ではドラッグを隠し、コピーのボタンを広く */
  .field-foot .btn.copy { flex: 1; }
  .draft-head .meta { min-width: 0; }
  .label-in { width: 9em; }
}
.rowform label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.rowform input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; flex: none; margin: 0; }

/* ポケットモード（2026-10-13 スマートフォンを左のポケットに入れて往診） */
.pocket-btn { display: block; margin: 10px auto 0; }
.pocket { position: fixed; inset: 0; z-index: 100; background: #000; color: #555; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; user-select: none; -webkit-user-select: none;
  touch-action: none; -webkit-touch-callout: none; }
.pocket[hidden] { display: none; }
.pocket .p-rec { color: #7a1f1f; font-weight: 700; }
.pocket .p-time { font-size: 28px; font-variant-numeric: tabular-nums; }
.pocket .p-hint { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); font-size: 13px; color: #333; }
.pocket .p-back { margin-top: 18px; font-size: 20px; padding: 14px 40px; }
.pocket.alert { background: #5a0b0b; color: #fff; }
.pocket .p-stop { font-size: 20px; font-weight: 700; line-height: 1.6; }
body.pocketed { overflow: hidden; }
@media (max-width: 560px) {
  .nav { gap: 2px; }
  .nav a { white-space: nowrap; padding: 8px 9px; }
  .who { gap: 8px; }
}
