/* =============================================================
   ClinicNotify — mobile-first design system + page styles
   設計方向：醫療安心感（teal/slate）, 大字看診號, 圓角親和
   ============================================================= */

/* ── 1. Tokens ────────────────────────────────────────────── */
:root {
  /* Colors */
  --bg:            #f4f7f9;
  --surface:       #ffffff;
  --surface-soft:  #f8fafc;
  --surface-tint:  #ecfdf5;          /* primary 10% */
  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-soft:     #94a3b8;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --primary:       #0d9488;          /* teal-600 主色 */
  --primary-hover: #0f766e;
  --primary-soft:  #ccfbf1;
  --primary-tint:  #f0fdfa;

  --accent:        #0284c7;          /* sky-600 — secondary highlight */
  --line-green:    #06c755;          /* LINE brand */
  --line-green-d:  #04a847;

  --success:       #15803d;
  --success-soft:  #dcfce7;
  --warn:          #b45309;
  --warn-soft:     #fef3c7;
  --danger:        #b91c1c;
  --danger-soft:   #fee2e2;
  --info:          #1d4ed8;
  --info-soft:     #dbeafe;

  /* Type scale — uses rem so they scale with html font-size.
     User can toggle html font-size via topbar button (15 / 17.7 / 20.25px).
     Base ratio: 15px = 1rem. */
  --fz-xs:   0.733rem;  /* 11px */
  --fz-sm:   0.867rem;  /* 13px */
  --fz-base: 1rem;      /* 15px */
  --fz-lg:   1.133rem;  /* 17px */
  --fz-xl:   1.333rem;  /* 20px */
  --fz-2xl:  1.6rem;    /* 24px */
  --fz-3xl:  1.867rem;  /* 28px */
  --fz-num:  2.933rem;  /* 44px 看診號大字 */

  --lh-tight: 1.25;
  --lh-snug:  1.4;
  --lh-base:  1.55;

  /* Spacing (4 px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10:40px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl:28px;
  --r-pill: 9999px;

  /* Shadow */
  --sh-sm: 0 1px 2px rgba(15,23,42,.04);
  --sh-md: 0 4px 14px rgba(15,23,42,.06);
  --sh-lg: 0 16px 36px rgba(15,23,42,.10);
  --sh-pop:0 -8px 32px rgba(15,23,42,.10);

  /* Misc */
  --topbar-h: 56px;
  --bottomnav-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 15px; }   /* base — toggled by [data-font] below */
html[data-font="lg"]  { font-size: 17.7px; }   /* 1.18x — 大 */
html[data-font="xl"]  { font-size: 20.25px; }  /* 1.35x — 特大 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: var(--lh-base);
  font-size: var(--fz-base);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
a { color: inherit; }

/* ── 2. Topbar ────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--sp-4);
  padding-top: var(--safe-top);
  height: calc(var(--topbar-h) + var(--safe-top));
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  font-size: var(--fz-lg);
  letter-spacing: -0.01em;
}
.brand img { width: 32px; height: 32px; border-radius: var(--r-sm); }
.beta-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: var(--r-pill);
  vertical-align: middle;
  line-height: 1.4;
}
.user-menu { display: flex; align-items: center; gap: var(--sp-2); }
.user-name {
  font-size: var(--fz-sm);
  color: var(--text-muted);
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar-btn {
  appearance: none;
  border: none;
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.admin-badge {
  background: var(--primary);
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.link {
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: var(--fz-sm);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}
.link:hover { color: var(--text); background: var(--surface-soft); }
.link-danger { color: var(--text-muted); }
.link-danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Hidden by default; shown on mobile via @media */
.user-menu .desktop-only { display: inline-flex; }
.user-menu .mobile-only  { display: none; }

/* ── 3. User-menu sheet (mobile) ──────────────────────────── */
.menu-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 100;
}
.menu-sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.menu-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-4) + var(--safe-bottom));
  box-shadow: var(--sh-pop);
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  z-index: 101;
  max-height: 80vh;
  overflow-y: auto;
}
.menu-sheet.open { transform: translateY(0); }
.menu-sheet-grip {
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  margin: -8px auto var(--sp-4);
}
.menu-sheet-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface-soft);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-3);
}
.menu-sheet-user img {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.menu-sheet-user .name { font-weight: 600; font-size: var(--fz-base); }
.menu-sheet-user .sub  { font-size: var(--fz-xs); color: var(--text-muted); }
.menu-sheet-list { list-style: none; margin: 0; padding: 0; }
.menu-sheet-list li {
  border-bottom: 1px solid var(--border);
}
.menu-sheet-list li:last-child { border-bottom: none; }
.menu-sheet-list a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  text-decoration: none;
  color: var(--text);
  font-size: var(--fz-base);
  font-weight: 500;
}
.menu-sheet-list a:hover { background: var(--surface-soft); }
.menu-sheet-list a.danger { color: var(--danger); }
.menu-sheet-list .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* ── 4. Layout ────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4)
           calc(var(--bottomnav-h) + var(--sp-6) + var(--safe-bottom));
  flex: 1;
}

/* ── 5. Card ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: var(--sp-5);
  margin-bottom: var(--sp-3);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.card h2 {
  margin: 0;
  font-size: var(--fz-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.history-card summary {
  cursor: pointer;
  font-weight: 700;
  font-size: var(--fz-base);
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.history-card summary::-webkit-details-marker { display: none; }
.history-card summary::before {
  content: "▶";
  font-size: 10px;
  color: var(--text-soft);
  transition: transform .15s;
}
.history-card[open] summary::before { transform: rotate(90deg); }
.history-card[open] summary { margin-bottom: var(--sp-3); }

/* ── 6. Banner ────────────────────────────────────────────── */
.banner {
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.banner-info {
  background: var(--info-soft);
  border: 1px solid #bfdbfe;
  color: var(--info);
}
.banner > div { flex: 1; min-width: 200px; font-size: var(--fz-sm); }
.banner strong { font-weight: 700; }

/* ── 7. Buttons ───────────────────────────────────────────── */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 12px 18px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fz-base);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .05s, box-shadow .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: var(--success); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-soft); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover { background: var(--danger-soft); border-color: #fecaca; }

.btn-block { width: 100%; }
.btn-mini {
  font-size: var(--fz-xs);
  font-weight: 600;
  padding: 5px 10px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.btn-mini:hover {
  background: var(--primary-tint);
  border-color: var(--primary-soft);
  color: var(--primary-hover);
}
.btn-mini:active { transform: scale(.96); }

/* ── 8. Monitor list (the hero of dashboard) ──────────────── */
.monitor-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.empty {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-muted);
}
/* 只給「列表級」.empty（empty 是直接子元素，無父輩 .value）顯示 🏥 emoji；
   inline value 的 <span class="value empty">—</span> 不適用，避免覆蓋掉 dash。 */
.empty:not(.value)::before {
  content: "🏥";
  display: block;
  font-size: 40px;
  margin-bottom: var(--sp-2);
  opacity: .55;
}
.muted { color: var(--text-muted); font-size: var(--fz-sm); }

/* card-style monitor — different visual weight per status */
.monitor-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  transition: border-color .15s, box-shadow .15s;
}
.monitor-row.is-active {
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary-soft) inset;
}
.monitor-row.is-completed {
  background: var(--success-soft);
  border-color: #86efac;
}
.monitor-row.is-error {
  background: var(--warn-soft);
  border-color: #fcd34d;
}

.mr-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
}
.mr-head-main { min-width: 0; flex: 1; }
.mr-hospital {
  font-size: var(--fz-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 2px;
}
.mr-doctor {
  font-size: var(--fz-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  word-break: break-word;
}
.mr-dept {
  font-size: var(--fz-sm);
  color: var(--text-muted);
  margin-top: 2px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fz-xs);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-pill::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-active    { background: var(--primary-soft); color: var(--primary-hover); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-cancelled { background: #f1f5f9; color: var(--text-muted); }
.status-expired   { background: var(--danger-soft); color: var(--danger); }
.status-error     { background: var(--warn-soft); color: var(--warn); }

/* hero numbers */
.mr-numbers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface-soft);
  border-radius: var(--r-md);
}
.mr-num-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.mr-num-cell .label {
  font-size: var(--fz-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.mr-num-cell .value {
  font-size: var(--fz-num);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}
.mr-num-cell.current .value { color: var(--primary); }
.mr-num-cell .value.empty {
  color: var(--text-soft);
  font-size: 28px;
  font-weight: 500;
}
.mr-summary {
  text-align: center;
  font-size: var(--fz-sm);
  color: var(--text-muted);
  padding: var(--sp-2) 0 0;
}
.mr-summary strong { color: var(--text); font-weight: 700; }
.mr-summary.is-soon { color: var(--warn); font-weight: 600; }
.mr-summary.is-now  { color: var(--success); font-weight: 700; }

.mr-meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fz-sm);
}
.mr-meta-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-muted);
}
.mr-meta-row .label {
  font-size: var(--fz-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  flex-shrink: 0;
}
.alert-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.alert-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fz-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid #bfdbfe;
}
.alert-chip.fired   { background: var(--success-soft); color: var(--success); border-color: #86efac; }
.alert-chip.pending { background: var(--warn-soft);    color: var(--warn);    border-color: #fcd34d; }
.alert-chip.final   { background: var(--primary-soft); color: var(--primary-hover); border-color: var(--primary); }
.channel-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: var(--fz-xs);
  font-weight: 500;
  color: var(--text-muted);
}

.mr-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}
.mr-actions .btn { flex: 1; }

/* ── 9. Form ──────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: var(--fz-sm);
  font-weight: 600;
  color: var(--text);
}
.field > .field-hint {
  font-size: var(--fz-xs);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: -2px;
}
.field input,
.field select,
.field textarea,
input.field-input {
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fz-base);
  min-height: 48px;
  width: 100%;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  -moz-appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%2364748b' stroke-width='2' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.alert-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: var(--sp-2);
}
.channels-checklist {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.channels-checklist label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: var(--fz-base);
  background: var(--surface);
  transition: border-color .15s, background .15s, box-shadow .15s, transform .05s;
  position: relative;
}
.channels-checklist label:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.channels-checklist label:active { transform: scale(0.99); }

.channels-checklist label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 700;
  color: var(--primary-hover);
  box-shadow: 0 0 0 3px var(--primary-tint), inset 0 0 0 1px var(--primary);
}
.channels-checklist label:has(input:checked)::after {
  content: "✓";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.channels-checklist .channel-disabled { opacity: 0.55; cursor: not-allowed; }
.channels-checklist .channel-pending {
  border-style: dashed;
  border-color: var(--border-strong);
}
.channels-checklist .channel-pending .pending-hint {
  margin-left: auto;
  font-size: 12px;
}

/* Brand colors per channel — make LINE / 瀏覽器推播 視覺區分清楚 ──── */
/* LINE 推播 — LINE 官方品牌綠 (#06C755) */
.channels-checklist .channel-line:hover {
  background: #f0fdf4;
  border-color: #34d399;
}
.channels-checklist .channel-line:has(input:checked) {
  border-color: #06C755;
  background: #ecfdf3;
  color: #065f46;
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.18), inset 0 0 0 1px #06C755;
}
.channels-checklist .channel-line:has(input:checked)::after {
  background: #06C755;
}

/* 手機瀏覽器推播 — 藍紫 (violet-600 #7c3aed) */
.channels-checklist .channel-webpush:hover {
  background: #faf5ff;
  border-color: #a78bfa;
}
.channels-checklist .channel-webpush:has(input:checked) {
  border-color: #7c3aed;
  background: #f5f3ff;
  color: #5b21b6;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18), inset 0 0 0 1px #7c3aed;
}
.channels-checklist .channel-webpush:has(input:checked)::after {
  background: #7c3aed;
}
/* Pending（尚未授權，dashed border）也用 webpush 紫色框 */
.channels-checklist .channel-webpush.channel-pending {
  border-color: #c4b5fd;
}
.channels-checklist .channel-webpush.channel-pending:hover {
  border-color: #a78bfa;
}

/* Channel block — 把 channel checkbox 與其提醒號碼視覺上綁在一起。
   手機(上) 與 LINE(下) 各自一塊，提醒號碼用配色左 border 連到上方的 channel checkbox。*/
.channel-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-3);
}
.channel-block:last-of-type { margin-bottom: 0; }

/* 提醒號碼 雙區塊（LINE / Webpush）— 各自 alerts，老人家不需要懂逗號 */
.alert-section {
  margin-top: 8px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}

/* alert-section 在 channel-block 內：改用左 border 連結，避免雙重框 */
.channel-block .alert-section {
  margin-top: 0;
  margin-left: 18px;
  padding: 8px 0 4px 14px;
  border: none;
  border-left: 3px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.channel-block-webpush .alert-section { border-left-color: #c4b5fd; }
.channel-block-line .alert-section    { border-left-color: #6ee7b7; }
.alert-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}
.ch-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}
.ch-dot-line { background: #06C755; }
.ch-dot-webpush { background: #7c3aed; }

.alert-input-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.alert-input-area .alert-num {
  flex: 1 1 auto;
  min-width: 80px;
  max-width: 130px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  /* prevent iOS zoom on focus (font-size >= 16px works) */
}
.alert-input-area .alert-num:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.alert-input-area .alert-num:not(:placeholder-shown) {
  background: var(--primary-tint);
  border-color: var(--primary-soft);
}
/* hide the spin buttons on number inputs (not useful, takes space) */
.alert-input-area .alert-num::-webkit-inner-spin-button,
.alert-input-area .alert-num::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.alert-input-area .alert-num {
  -moz-appearance: textfield;
}

/* LINE 一日 1 次額度已用 — 反白 + 灰底 */
.channels-checklist .channel-line-exhausted {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  color: #6b7280 !important;
  cursor: not-allowed !important;
  text-decoration: line-through;
  text-decoration-color: rgba(107, 114, 128, 0.5);
}
.channels-checklist .channel-line-exhausted .channel-quota-note {
  text-decoration: none;
  font-weight: 600;
}
.channels-checklist .channel-line-exhausted::after {
  display: none !important;  /* hide ✓ badge */
}

/* Quota badge in card-header — 大字醒目，不該被忽略 */
.quota-badge {
  display: inline-block;
  font-size: 18px;
  font-weight: 700;
  margin-left: 12px;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  vertical-align: middle;
  letter-spacing: 0.5px;
  border: 1.5px solid var(--primary-tint);
}
.quota-badge.quota-warn {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}
.quota-badge.quota-full {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
  animation: quota-pulse 1.6s ease-in-out infinite;
}
@keyframes quota-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* Font-size toggle (老花友善) — html[data-font] sets root font-size,
   all rem-based --fz-* tokens scale automatically. */
.font-toggle {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.font-toggle:hover { background: var(--primary-tint); border-color: var(--primary); color: var(--primary-hover); }
.font-toggle .a-small { font-size: 11px; }
.font-toggle .a-big   { font-size: 16px; }
html[data-font="lg"] .font-toggle,
html[data-font="xl"] .font-toggle {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-hover);
}

/* Re-monitor button on history cards */
.btn-remonitor {
  background: var(--primary-tint);
  color: var(--primary-hover);
  border-color: var(--primary-soft);
}
.btn-remonitor:hover { background: var(--primary-soft); }
.channels-checklist input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
}
.form-actions .btn { min-width: 96px; }

/* ── 10. Hospital select with grouping ────────────────────── */
#hospital-select optgroup { font-weight: 700; }
.target-select-wrapper { display: flex; flex-direction: column; gap: 4px; }

/* ── 10b. Peek status (查詢目前號碼) ──────────────────────── */
#target-peek:empty { display: none; }
.peek-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: var(--fz-base);
  line-height: 1.4;
  border: 1.5px solid transparent;
}
.peek-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.peek-title { font-weight: 600; }
.peek-sub { font-size: 12px; color: var(--text-muted); }

/* Loading — 醒目橘金背景 + 脈動 spinner，告訴 user 還在跑 */
.peek-loading {
  background: #fff7ed;             /* orange-50 */
  border-color: #fdba74;            /* orange-300 */
  color: #9a3412;                   /* orange-800 */
  animation: peek-loading-pulse 1.6s ease-in-out infinite;
}
.peek-loading .peek-sub { color: #c2410c; }   /* orange-700 */
.peek-spinner {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid #fed7aa;       /* orange-200 */
  border-top-color: #ea580c;         /* orange-600 */
  animation: peek-spinner-spin 0.7s linear infinite;
}
@keyframes peek-spinner-spin {
  to { transform: rotate(360deg); }
}
@keyframes peek-loading-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(234, 88, 12, 0); }
}

/* OK — 成功撈到號碼，主色調 */
.peek-ok {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--text);
  flex-wrap: wrap;
}
.peek-badge {
  font-weight: 700;
  color: var(--primary-hover);
}
.peek-badge strong {
  color: var(--primary);
  font-size: 20px;
  margin: 0 2px;
}
.peek-meta { color: var(--text-muted); font-size: 13px; }

/* Idle — 還沒開診 */
.peek-idle {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--text-muted);
}

/* Error — 紅色警示 */
.peek-error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

@media (prefers-reduced-motion: reduce) {
  .peek-loading, .peek-spinner { animation: none; }
}

/* ── 11. Bottom nav ───────────────────────────────────────── */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 40;
  box-shadow: 0 -4px 16px rgba(15,23,42,.04);
}
.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--sp-2) var(--sp-1);
  min-height: var(--bottomnav-h);
  text-decoration: none;
  color: var(--text-muted);
  font-size: var(--fz-xs);
  font-weight: 500;
  position: relative;
  transition: color .15s;
}
.bottom-nav a.active {
  color: var(--primary);
  font-weight: 700;
}
.bottom-nav a.active::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 3px;
  border-radius: 0 0 var(--r-pill) var(--r-pill);
  background: var(--primary);
}
.bottom-nav .nav-icon {
  font-size: 22px;
  line-height: 1;
}
.bottom-nav .nav-label {
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* ── 12. Toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + var(--sp-3) + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: var(--fz-sm);
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: var(--sh-lg);
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-error   { background: var(--danger); }
.toast-success { background: var(--success); }

/* ── 13. Footer ───────────────────────────────────────────── */
.page-footer {
  text-align: center;
  font-size: var(--fz-xs);
  color: var(--text-soft);
  padding: var(--sp-4) 0 var(--sp-6);
  letter-spacing: 0.02em;
}

.alert {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: var(--fz-sm);
  margin-bottom: var(--sp-3);
}

/* ── 14. Responsive ───────────────────────────────────────── */
/* Mobile (default) */

/* Tablet+ */
@media (min-width: 641px) {
  :root {
    --topbar-h: 64px;
    --fz-num: 56px;
  }
  .container { padding: var(--sp-6) var(--sp-5) var(--sp-8); }
  .card { padding: var(--sp-6); }
  .bottom-nav { display: none; }
  .container { padding-bottom: var(--sp-8); }
  .form-actions .btn { min-width: 120px; }
}

/* Desktop topbar shows full nav, mobile collapses to avatar+sheet */
@media (max-width: 640px) {
  .user-menu .desktop-only { display: none !important; }
  .user-menu .mobile-only  { display: inline-flex; }
  .form-actions .btn { flex: 1; }
  .form-actions { flex-direction: row; }
}

/* Tablet+: optional 2-col monitor list */
@media (min-width: 768px) {
  .monitor-list { /* keep single column for clarity */ }
}

/* iPhone safe areas already handled via env() above */
