:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1d2939;
  --ink-2: #475467;
  --ink-3: #667085;
  --line: #d6dde5;
  --line-2: #e8edf2;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e6f4f2;
  --brand-text: #0f766e;   /* 白地に置く文字・リンク用（淡い色を選んだ場合は自動で濃くなる） */
  --brand-hover: #0b5f59;
  --brand-header: #0f766e;  /* ヘッダーの背景（文字は白） */
  --brand-focus: rgba(15, 118, 110, .25);
  --alert: #b42318;
  --alert-soft: #fdecec;
  --warn: #b54708;
  --warn-soft: #fef4e6;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --radius: 10px;
  --font: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.7;
}
a { color: var(--brand-text); }
h1, h2, h3 { line-height: 1.4; margin: 0 0 .6em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-3); font-size: .9em; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "BIZ UDGothic", monospace; }
[hidden] { display: none !important; }
.print-only { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .55em 1.1em; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem;
  text-decoration: none; cursor: pointer; white-space: nowrap; min-height: 40px;
}
.btn:hover { background: #f8fafb; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { color: var(--alert); border-color: #f1b9b4; }
.btn-danger:hover { background: var(--alert-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: .3em .7em; min-height: 32px; font-size: .85rem; }
.btn-lg { padding: .8em 1.6em; font-size: 1.05rem; min-height: 52px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* ---------- forms ---------- */
input[type=text], input[type=tel], input[type=date], input[type=number], input[type=email],
input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .6em .75em; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font: inherit; color: var(--ink); min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 3px solid var(--brand-focus); outline-offset: 1px; border-color: var(--brand);
}
label { cursor: pointer; }

.flash, .notice {
  padding: .8em 1em; border-radius: 8px; margin-bottom: 1em;
  background: var(--brand-soft); color: #0b4f4a;
}
.notice-alert { background: var(--alert-soft); color: var(--alert); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }

.badge {
  display: inline-block; padding: .05em .6em; border-radius: 999px; font-size: .78rem;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap; line-height: 1.7;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-alert { background: var(--alert-soft); color: var(--alert); font-weight: bold; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-brand { background: var(--brand-soft); color: var(--brand-text); }

.card {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 20px;
}

/* =========================================================
   患者向け
   ========================================================= */
.pub-header {
  background: var(--brand-header); color: #fff;
  padding: 14px 16px; text-align: center;
  position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 6px rgba(16, 24, 40, .12);
}
.pub-header .clinic { font-weight: bold; font-size: 1.05rem; }
.pub-header .title { color: rgba(255, 255, 255, .88); font-size: .9rem; }
.pub-main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.pub-footer { text-align: center; color: var(--ink-3); font-size: .8rem; padding: 24px 16px; }
.copyright { text-align: center; color: var(--ink-3); font-size: .75rem; letter-spacing: .02em; }
.pub-footer .copyright { margin-top: 10px; }
.adm-footer { padding: 8px 16px 28px; }
.login-wrap { flex-direction: column; }
.copy-btn { padding: .3em .5em; color: var(--ink-2); }
.copy-btn .ico { display: block; }
.copy-btn .ico-ok { display: none; color: var(--ok); }
.copy-btn.copied .ico-copy { display: none; }
.copy-btn.copied .ico-ok { display: block; }

.steps { display: flex; gap: 6px; margin: 4px 0 16px; padding: 0; list-style: none; }
.steps li {
  flex: 1; text-align: center; font-size: .8rem; color: var(--ink-3);
  border-bottom: 3px solid var(--line); padding-bottom: 4px;
}
.steps li.on { color: var(--brand-text); border-color: var(--brand); font-weight: bold; }
.steps li.past { border-color: var(--brand); }
@media (max-width: 380px) { .steps li { font-size: .72rem; } }

.preview-bar {
  background: var(--warn-soft); color: var(--warn);
  text-align: center; padding: 8px; font-size: .9rem; font-weight: bold;
}

.q {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.q.has-error { border-color: var(--alert); background: #fffafa; }
.q-label { font-weight: bold; display: block; margin-bottom: .5em; }
.q-help { color: var(--ink-3); font-size: .85rem; margin: -.3em 0 .6em; }
.q-error { color: var(--alert); font-size: .88rem; margin-top: .4em; font-weight: bold; }
.req {
  display: inline-block; background: var(--alert); color: #fff; font-size: .7rem;
  border-radius: 4px; padding: 0 .4em; margin-left: .4em; vertical-align: 2px; font-weight: normal;
}
.opt { color: var(--ink-3); font-size: .75rem; margin-left: .4em; font-weight: normal; }
.q-heading { margin: 24px 2px 10px; }
.q-heading h2 { font-size: 1.1rem; padding-left: 10px; border-left: 4px solid var(--brand); }
.q-heading p { color: var(--ink-2); font-size: .9rem; margin: 0; }

.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: .6em; padding: .65em .8em; min-height: 46px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--brand); }
.other-input { margin-top: 8px; }
.birth { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.birth select { padding-left: .5em; padding-right: .3em; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }

.confirm-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.confirm-table th, .confirm-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.confirm-table th { width: 42%; font-weight: normal; color: var(--ink-2); font-size: .9rem; }
.confirm-table td { white-space: pre-wrap; word-break: break-word; }
.confirm-table tr.heading td { background: #eef2f6; font-weight: bold; }
@media (max-width: 520px) {
  .confirm-table th, .confirm-table td { display: block; width: 100%; }
  .confirm-table th { border-bottom: 0; padding-bottom: 0; }
}
.agree { margin: 20px 0; }
.privacy {
  max-height: 180px; overflow: auto; background: #fff; border: 1px solid var(--line-2);
  border-radius: 8px; padding: 12px; font-size: .85rem; color: var(--ink-2); margin-bottom: 10px;
}
.actions { display: grid; gap: 10px; margin-top: 20px; }
.done { text-align: center; padding: 40px 16px; }
.done .icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok);
  display: inline-flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 12px;
}
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* =========================================================
   管理画面
   ========================================================= */
.adm-header {
  background: var(--brand-header); color: #fff; display: flex; align-items: center; gap: 24px;
  padding: 0 24px; min-height: 56px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 6px rgba(16, 24, 40, .12);
}
.adm-header .brand { font-weight: bold; letter-spacing: .02em; }
.adm-header .brand small { opacity: .88; font-weight: normal; margin-left: .5em; }
.adm-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.adm-nav a {
  color: rgba(255, 255, 255, .85); text-decoration: none; padding: 16px 12px; font-size: .92rem;
  border-bottom: 3px solid transparent;
}
.adm-nav a.on, .adm-nav a:hover { color: #fff; border-color: #fff; }
.adm-user { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: rgba(255, 255, 255, .9); }
.adm-user .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .55); }
.adm-user .btn:hover { background: rgba(255, 255, 255, .15); }
.adm-main { max-width: 1180px; margin: 0 auto; padding: 24px; }
@media (max-width: 640px) {
  .adm-main { padding: 16px; }
  .adm-header { padding: 6px 16px 0; gap: 0 12px; min-height: 0; }
  .adm-header .brand { flex: 1; font-size: .92rem; }
  .adm-nav { order: 3; flex-basis: 100%; }
  .adm-nav a { padding: 8px 10px; }
  .adm-user span { display: none; }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 18px; text-decoration: none; color: inherit; }
.stat .n { font-size: 1.8rem; font-weight: bold; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--ink-3); font-size: .85rem; }
.stat.alert .n { color: var(--alert); }
@media (max-width: 640px) { .stats { grid-template-columns: 1fr 1fr 1fr; } .stat .n { font-size: 1.4rem; } }

.slots { display: grid; gap: 12px; }
.slot {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 16px;
}
.slot-no {
  width: 56px; height: 56px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.slot-no b { font-size: 1.4rem; }
.slot-no span { font-size: .7rem; }
.slot.empty .slot-no { background: var(--line-2); color: var(--ink-3); }
.slot-title { font-weight: bold; font-size: 1.02rem; }
.slot-url { display: flex; gap: 6px; align-items: center; margin-top: 4px; min-width: 0; }
.slot-url code {
  font-size: .8rem; color: var(--ink-2); background: var(--bg); padding: 2px 8px; border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; max-width: 520px;
}
.slot-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.slot-qr { width: 64px; height: 64px; border: 1px solid var(--line-2); border-radius: 6px; padding: 2px; background: #fff; }
@media (max-width: 760px) {
  .slot { grid-template-columns: 48px 1fr; }
  .slot-no { width: 48px; height: 48px; }
  .slot-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); text-align: left; font-size: .92rem; }
table.list th { background: #f8fafb; color: var(--ink-2); font-weight: normal; font-size: .82rem; white-space: nowrap; }
table.list tr.unread td { font-weight: bold; }
table.list tr:hover td { background: #fafcfc; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: var(--brand-soft); }
table.list a.rowlink { color: inherit; text-decoration: none; display: block; }
.table-wrap { overflow-x: auto; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label { font-size: .8rem; color: var(--ink-3); display: grid; gap: 2px; }
.filters input, .filters select { min-height: 38px; padding: .35em .6em; width: auto; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; align-items: center; }

.detail-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 16px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.alert-box { border: 1px solid #f1b9b4; background: var(--alert-soft); color: var(--alert); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.alert-box ul { margin: .3em 0 0; padding-left: 1.2em; }
.confirm-table tr.alert th, .confirm-table tr.alert td { background: var(--alert-soft); color: var(--alert); font-weight: bold; }
.confirm-table tr.patient th { background: #fbfcfd; }

.settings-grid { display: grid; gap: 16px; max-width: 720px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-weight: bold; font-size: .92rem; }

/* ---------- フォームビルダー ---------- */
.builder { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .builder { grid-template-columns: 1fr; } }
.builder > div { min-width: 0; }
.builder-side { position: sticky; top: 48px; display: grid; gap: 12px; }
.builder-side .card { padding: 16px; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.palette .btn { justify-content: flex-start; font-size: .82rem; white-space: normal; text-align: left; }

.bfield {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  margin-bottom: 10px; transition: box-shadow .15s;
}
.bfield.dragging { opacity: .5; }
.bfield.drop-before { box-shadow: 0 -3px 0 var(--brand); }
.bfield.drop-after { box-shadow: 0 3px 0 var(--brand); }
.bfield-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; }
.bfield-head .grip { cursor: grab; color: var(--ink-3); padding: 0 4px; user-select: none; font-size: 1.1rem; }
.bfield-head .num { color: var(--ink-3); font-size: .8rem; width: 1.8em; text-align: right; font-variant-numeric: tabular-nums; }
.bfield-head .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bfield-head .tags { display: flex; gap: 4px; }
.bfield.heading { background: #f3f7f7; border-style: dashed; }
.bfield.heading .lbl { font-weight: bold; }
.bfield.open { border-color: var(--brand); box-shadow: 0 2px 10px rgba(16, 24, 40, .06); }
.bfield-body { padding: 4px 16px 16px; border-top: 1px solid var(--line-2); display: grid; gap: 12px; }
.bfield-body .row { display: grid; gap: 4px; }
.bfield-body .row > span { font-size: .82rem; color: var(--ink-2); }
.bfield-body .flags { display: flex; gap: 18px; flex-wrap: wrap; font-size: .9rem; }
.bfield-body .flags label { display: flex; align-items: center; gap: 6px; }
.opt-list { display: grid; gap: 6px; }
.opt-row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; }
.opt-row input[type=text] { min-height: 36px; padding: .3em .6em; }
.opt-row .alert-toggle { font-size: .78rem; color: var(--alert); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.bfield-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.empty-builder { text-align: center; padding: 40px 16px; color: var(--ink-3); border: 2px dashed var(--line); border-radius: var(--radius); }
.pf-table { width: 100%; font-size: .88rem; border-collapse: collapse; }
.pf-table td { padding: 4px 0; }
.pf-table select { min-height: 32px; padding: .2em .4em; font-size: .85rem; }
.savebar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.save-state { font-size: .82rem; color: var(--ink-3); }
.save-state.dirty { color: var(--warn); }
.save-state.error { color: var(--alert); font-weight: 600; }

/* 編集画面の「公開の状態」 */
.pub-panel { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: .8em 1em; border-radius: 8px; margin-bottom: 1em; border: 1px solid var(--line);
  background: var(--surface); }
.pub-panel:empty { display: none; }
.pub-panel .pub-text { flex: 1 1 320px; min-width: 0; font-size: .92rem; }
.pub-panel .pub-text b { display: block; font-size: 1rem; margin-bottom: .15em; }
.pub-panel .pub-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pub-panel.is-off { background: var(--surface); }
.pub-panel.is-live { background: var(--ok-soft); border-color: transparent; }
.pub-panel.is-live .pub-text b { color: var(--ok); }
.pub-panel.is-draft { background: var(--warn-soft); border-color: var(--warn); }
.pub-panel.is-draft .pub-text b { color: var(--warn); }

.choose { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 760px; }
@media (max-width: 640px) { .choose { grid-template-columns: 1fr; } }
.choose button { text-align: left; cursor: pointer; font: inherit; color: inherit; }
.choose button:hover { border-color: var(--brand); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

/* ---------- 印刷 ---------- */
@media print {
  .adm-header, .adm-footer, .no-print, .detail-actions, .pub-footer { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .print-only { display: block; }
  .print-meta { text-align: right; font-size: 9.5pt; color: #475467; line-height: 1.5; white-space: nowrap; }
  .detail-head { flex-wrap: nowrap; }
  .pub-header { position: static; box-shadow: none; }
  .adm-main { padding: 0; max-width: none; }
  .confirm-table tr { break-inside: avoid; }
  .confirm-table tr.alert th, .confirm-table tr.alert td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- メインカラー設定 ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px var(--line);
}
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }
.color-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.color-row input[type=color] {
  width: 56px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer;
}
.color-row input[type=text] { width: 130px; font-family: Consolas, monospace; }
.theme-preview {
  margin-top: 14px; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden;
  max-width: 360px; background: var(--bg);
}
.theme-preview .tp-head { background: var(--p-header); color: #fff; text-align: center; padding: 10px; font-weight: bold; }
.theme-preview .tp-body { padding: 12px; display: grid; gap: 8px; }
.theme-preview .tp-steps { display: flex; gap: 6px; font-size: .7rem; text-align: center; white-space: nowrap; }
.theme-preview .tp-steps span { flex: 1; border-bottom: 3px solid var(--line); color: var(--ink-3); padding-bottom: 3px; }
.theme-preview .tp-steps span.on { border-color: var(--p-brand); color: var(--p-text); font-weight: bold; }
.theme-preview .tp-h { border-left: 4px solid var(--p-brand); padding-left: 8px; font-weight: bold; }
.theme-preview .tp-choice {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: .9rem;
}
.theme-preview .tp-choice.on { border-color: var(--p-brand); background: var(--p-soft); }
.theme-preview .tp-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.theme-preview .tp-choice.on .tp-dot { border: 5px solid var(--p-brand); }
.theme-preview .tp-btn { background: var(--p-brand); color: var(--p-ink); text-align: center; padding: 10px; border-radius: 8px; font-weight: bold; }

/* ---------- 固定ヘッダーの縮小表示（スクロール後は高さを約半分に） ---------- */
.pub-header, .adm-header { transition: padding .18s ease, min-height .18s ease; }
.pub-header .clinic, .adm-header .brand, .adm-nav a { transition: font-size .18s ease, padding .18s ease; }
.pub-header .title { overflow: hidden; max-height: 2em; transition: max-height .18s ease, opacity .18s ease; }

.pub-header.compact { padding: 8px 16px; }
.pub-header.compact .clinic { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub-header.compact .title { max-height: 0; opacity: 0; }

.adm-header.compact { min-height: 30px; }
.adm-header.compact .brand { font-size: .85rem; }
.adm-header.compact .adm-nav a { padding: 5px 12px 4px; font-size: .84rem; border-bottom-width: 2px; }
.adm-header.compact .adm-user { font-size: .78rem; }
.adm-header.compact .adm-user .btn { min-height: 22px; padding: 0 .6em; font-size: .75rem; }
@media (max-width: 640px) {
  /* 2段のヘッダーは、縮小時にメニューの段だけ残す */
  .adm-header.compact { padding-top: 0; }
  .adm-header.compact .brand, .adm-header.compact .adm-user { display: none; }
  .adm-header.compact .adm-nav a { padding: 8px 10px 6px; font-size: .88rem; }
}
@media (prefers-reduced-motion: reduce) {
  .pub-header, .adm-header, .pub-header .clinic, .pub-header .title, .adm-header .brand, .adm-nav a { transition: none; }
}

.receipt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: .88rem; color: var(--ink-2); margin-bottom: 12px;
}

.email-list { display: grid; gap: 8px; margin-bottom: 10px; max-width: 480px; }
.email-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }

/* ---------- 回答一覧のグループ ---------- */
.group { margin-bottom: 36px; scroll-margin-top: 56px; }
.group .page-head h1 { display: flex; align-items: baseline; gap: 10px; }
.group .count { font-size: .9rem; font-weight: normal; color: var(--ink-3); }
.group .count.alert { color: var(--alert); font-weight: bold; }
.filters.card { padding: 12px 16px; margin-bottom: 12px; }

/* ---------- 予約日 ---------- */
table.list td.appt { color: var(--brand-text); font-weight: bold; font-variant-numeric: tabular-nums; }
.appt-box {
  display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line-2); border-left: 4px solid var(--brand);
  border-radius: var(--radius); padding: 10px 16px; margin-bottom: 16px;
}
.appt-box .appt-main { font-size: 1.15rem; font-weight: bold; color: var(--brand-text); font-variant-numeric: tabular-nums; }

/* ---------- 診察券番号 / 新患 ---------- */
.badge-new { background: var(--alert-soft); color: var(--alert); font-weight: bold; }       /* 新患: 赤 */
.badge-return { background: #e8f1fd; color: #175cd3; font-weight: bold; font-variant-numeric: tabular-nums; }  /* 再診: 青 */
table.list a.rowlink.name { display: inline; }
table.list .age { font-size: .8rem; color: var(--ink-3); margin-left: .5em; white-space: nowrap; }
.more-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.more-row .btn.disabled { pointer-events: none; opacity: .6; }
table.list td.card-cell { font-variant-numeric: tabular-nums; }
.card-no {
  font-size: .85rem; font-weight: normal; color: var(--ink-2); margin-left: .6em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.detail-head h1 .badge { font-size: .8rem; margin-left: .6em; vertical-align: 3px; }
@media print { .card-no, .detail-head h1 .badge { display: none; } }

/* =========================================================
   ユーザーズマニュアル
   ========================================================= */
.manual { max-width: 860px; margin: 0 auto; line-height: 1.85; }
.manual-cover {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-bottom: 3px solid var(--brand); padding-bottom: 14px; margin-bottom: 20px;
}
.manual-cover h1 { font-size: 1.7rem; margin: 0 0 .1em; }
.manual-cover p { margin: 0; }
.manual-kicker { color: var(--brand-text); font-weight: bold; letter-spacing: .08em; }
.manual-toc {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 14px 20px; margin-bottom: 28px;
}
.manual-toc ol { margin: .4em 0 0; padding-left: 1.6em; columns: 2; column-gap: 32px; }
.manual-toc li { break-inside: avoid; padding: 1px 0; }
@media (max-width: 640px) { .manual-toc ol { columns: 1; } }
.manual section { margin-bottom: 40px; scroll-margin-top: 56px; }
.manual h2 {
  font-size: 1.3rem; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line); padding-bottom: 8px; margin: 0 0 14px;
}
.manual h2 .no {
  flex: none; width: 1.9em; height: 1.9em; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .9rem;
}
.manual h3 { font-size: 1.05rem; margin: 26px 0 8px; padding-left: 10px; border-left: 4px solid var(--brand); }
.manual ul, .manual ol { padding-left: 1.5em; margin: 0 0 1em; }
.manual li { margin-bottom: .25em; }
.manual .steps-list { counter-reset: step; list-style: none; padding-left: 0; }
.manual .steps-list > li { counter-increment: step; position: relative; padding-left: 2.4em; margin-bottom: .5em; }
.manual .steps-list > li::before {
  content: counter(step); position: absolute; left: 0; top: .15em; width: 1.6em; height: 1.6em; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-text); font-weight: bold; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.manual .flow { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.manual .flow li {
  background: var(--surface); border: 1px solid var(--line-2); border-top: 4px solid var(--brand);
  border-radius: 8px; padding: 10px 12px; font-size: .9rem; margin: 0;
}
.manual .flow li b { display: block; color: var(--brand-text); font-size: .8rem; }
@media (max-width: 640px) { .manual .flow { grid-template-columns: 1fr 1fr; } }
.manual-table { width: 100%; border-collapse: collapse; background: var(--surface); margin: 0 0 16px; font-size: .92rem; }
.manual-table th, .manual-table td { border: 1px solid var(--line-2); padding: 8px 12px; text-align: left; vertical-align: top; }
.manual-table th { background: #f1f5f8; font-weight: bold; white-space: nowrap; }
.manual-table td:first-child { width: 30%; font-weight: bold; }
.manual-table.faq td:first-child { width: 36%; }
.manual .note {
  background: var(--brand-soft); border-radius: 8px; padding: 10px 14px; font-size: .9rem; margin: 0 0 16px;
}
.manual .note p { margin: 0 0 .4em; }
.manual .note ul { margin: 0; }
.manual .shot { margin: 14px 0 20px; text-align: center; }
.manual .shot img {
  max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, .08);
}
.manual .shot.narrow img { max-width: 520px; width: 100%; }
.manual .shot figcaption { font-size: .82rem; color: var(--ink-3); margin-top: 6px; }
.manual .phones { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0 6px; }
.manual .phones .shot { margin: 0 0 12px; }
@media (max-width: 640px) { .manual .phones { grid-template-columns: 1fr 1fr; } }
.manual-end { text-align: center; border-top: 1px solid var(--line); padding-top: 14px; }

@media print {
  .manual { max-width: none; font-size: 10pt; line-height: 1.7; }
  .manual section { margin-bottom: 18pt; }
  .manual h2 { break-after: avoid; break-inside: avoid; font-size: 14pt; }
  .manual h3 { break-after: avoid; break-inside: avoid; }
  .manual h2 .no { break-inside: avoid; }
  .manual h2 .no, .manual .steps-list > li::before, .manual .note, .manual .flow li, .manual-table th {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .manual .shot, .manual-table tr, .manual .note, .manual .steps-list > li, .manual .phones { break-inside: avoid; }
  /* 表の見出しだけがページの下に残らないよう、短い表は1ページに収める（長い「困ったときは」の表は除く） */
  .manual-table:not(.faq) { break-inside: avoid; }
  .manual .manual-table.faq tr:first-child { break-after: avoid; }
  .manual p, .manual li { orphans: 3; widows: 3; }
  /* 見出しの直後の説明文と、その次の表・画像・手順が、ページをまたいで離れないようにする */
  .manual h2 + p, .manual h3 + p, .manual p:has(+ .manual-table), .manual p:has(+ .shot), .manual p:has(+ .steps-list) { break-after: avoid; }
  .manual .shot { margin: 8pt 0 12pt; }
  .manual .shot img { box-shadow: none; max-height: 88mm; width: auto; }
  .manual .shot.narrow img { max-height: 72mm; width: auto; }
  .manual .phones .shot img { max-height: 82mm; }
  .manual-cover { border-bottom-width: 2pt; }
  .manual-end { display: none; }   /* PDF では各ページのフッターに表示する */
}

/* ---------- 設問文・補足説明の改行をそのまま表示 ---------- */
.ml { white-space: pre-line; }

/* ---------- 編集画面: 文字数の表示、表示条件の選択肢 ---------- */
.bfield-body .row > .field-foot { display: flex; justify-content: space-between; gap: 12px; font-size: .8rem; }
.char-count { color: var(--ink-3); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.char-count.near { color: var(--alert); font-weight: bold; }
.cond-values {
  display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 10px; border: 1px solid var(--line-2);
  border-radius: 8px; background: #fbfcfd; max-height: 220px; overflow: auto;
}
.cond-values label {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line);
  border-radius: 999px; background: #fff; font-size: .88rem;
}
.cond-values label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.cond-values input { accent-color: var(--brand); margin: 0; }
.cond-summary { font-size: .85rem; color: var(--brand-text); }
.cond-summary.empty { color: var(--alert); font-weight: bold; }

/* ---------- 郵便番号から住所 ---------- */
.zip-note { margin: 6px 0 0; color: var(--brand-text); }

/* ---------- 作成済みの問診票をコピーして作る ---------- */
.copy-sources { max-width: 760px; margin-top: 16px; }
.copy-sources ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.copy-source {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 8px; color: inherit; text-decoration: none; background: #fff;
}
.copy-source:hover { border-color: var(--brand); background: var(--brand-soft); }
.copy-source .slot-badge {
  background: var(--brand-soft); color: var(--brand-text); border-radius: 6px; padding: 1px 8px; font-size: .82rem; font-weight: bold;
}
.copy-source .copy-title { font-weight: bold; }
.copy-source .copy-go { margin-left: auto; color: var(--brand-text); font-size: .88rem; white-space: nowrap; }
