:root {
  /* 色は現行カード（黒板）とロゴから採取 */
  --board-top: #47444b;
  --board-bottom: #2b282b;
  --chalk: #ffffff;
  --chalk-dim: #cdc9d1;
  --brand-teal: #0b6f73;
  --brand-navy: #0d2f7a;
  --panel: #ffffff;
  --ink: #1f2427;
  --ink-dim: #5d6469;
  --page: #eef0f1;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.view[hidden] { display: none !important; }

#view-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 70vh; color: var(--ink-dim);
}
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid #d3d8db; border-top-color: var(--brand-teal);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 診察券（黒板） ---------- */
.card {
  container-type: inline-size;           /* 中の寸法はカード幅基準（cqw）で原本比率を再現 */
  color: var(--chalk);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
  background:
    url("/assets/chalkboard.jpg") center top / cover no-repeat,
    linear-gradient(180deg, var(--board-top), var(--board-bottom));
}

/* 上部：原本 1050×600 の配置を % で再現 */
.card-face { padding: 11.4cqw 0 5cqw; text-align: center; }
.card-title { margin: 0; line-height: 0; }
.card-title img { width: 43.8cqw; height: auto; }
.card-rule {
  width: 83cqw; margin: 11cqw auto 0;
  border: 0; border-top: max(1.5px, .3cqw) solid rgba(255, 255, 255, .95);
}
.brand {
  display: flex; align-items: center; justify-content: center;
  gap: 3cqw; margin-top: 5.6cqw;
}
.brand-mark { width: 18.5cqw; height: auto; flex: none; }
.brand-text { width: 39cqw; text-align: left; line-height: 0; }
.brand-ja { width: 100%; height: auto; }
.brand-en { width: 78%; height: auto; margin-top: 1.2cqw; }
.brand-branch {
  margin-top: 1.6cqw;
  font-size: 3.85cqw; line-height: 1.15; font-weight: 200;
  letter-spacing: .1em; white-space: nowrap;
}

/* 下部：患者情報 */
.card-body {
  margin: 0 6cqw; padding-top: 4cqw;
  border-top: 1px solid rgba(255, 255, 255, .18);
  display: grid; gap: 2.5cqw;
}
.card-body > div {
  display: grid; grid-template-columns: 5.5em 1fr; align-items: baseline;
  padding-bottom: 2.5cqw; border-bottom: 1px dashed rgba(255, 255, 255, .22);
}
.card-body dt { font-size: 13px; color: var(--chalk-dim); letter-spacing: .05em; }
.card-body dd { margin: 0; font-size: 18px; font-weight: 600; word-break: break-all; letter-spacing: .04em; }
.card-body dd.name { font-size: 22px; }
.card-body dd.pno { font-size: 26px; letter-spacing: .1em; font-variant-numeric: tabular-nums; }

.codes {
  margin: 5cqw 6cqw 0;
  background: #fff; border-radius: 12px; padding: 16px;
  display: flex; justify-content: center;
}
.qr { width: 160px; height: 160px; }
.qr img, .qr svg { width: 100%; height: 100%; image-rendering: pixelated; }
.card-note { margin: 0; padding: 4cqw 0 5cqw; text-align: center; font-size: 13px; color: var(--chalk-dim); }

/* ---------- 登録・確認中画面 ---------- */
.page-brand {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin: 8px 0 18px; color: var(--ink-dim); font-size: 14px; letter-spacing: .12em;
}
.page-brand img { width: 220px; height: auto; }
.page-brand span:empty { display: none; }

.panel {
  background: var(--panel); border-radius: 16px; padding: 22px 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.panel.center { text-align: center; padding: 36px 20px; }
.panel h1 { font-size: 20px; margin: 0 0 10px; }
.lead { margin: 0 0 18px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }
.notice { background: #fff6e0; border-radius: 8px; padding: 10px 12px; font-size: 14px; line-height: 1.6; }

form { display: grid; gap: 16px; }
label, legend { font-size: 14px; font-weight: 600; display: grid; gap: 6px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { margin-bottom: 6px; }
small { font-weight: 400; color: var(--ink-dim); font-size: 12px; }
input, select {
  font: inherit; font-size: 17px; font-weight: 400;
  padding: 12px; border: 1px solid #c9d0d4; border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--brand-teal); outline-offset: 1px; }
.dob { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }

button {
  font: inherit; font-size: 17px; font-weight: 700;
  padding: 14px; border: 0; border-radius: 12px;
  background: var(--brand-teal); color: #fff; width: 100%; cursor: pointer;
}
button:disabled { opacity: .6; }
button.secondary { background: #e6eaec; color: var(--ink); margin-top: 12px; }
.error { color: var(--danger); font-size: 14px; margin: 0; }
.fineprint { font-size: 12px; color: var(--ink-dim); margin: 16px 0 0; line-height: 1.6; }
