@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/NotoSansThai-Regular.woff2?v=p1-001") format("woff2");
}
@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/NotoSansThai-Medium.woff2?v=p1-001") format("woff2");
}
@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/NotoSansThai-Bold.woff2?v=p1-001") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #0B0E14;
  --surface: #131821;
  --surface-2: #1A202B;
  --surface-3: #232A37;
  --border: #262E3B;
  --border-strong: #3A4556;
  --text: #EDF0F5;
  --text-2: #BAC3D1;
  --muted: #8793A6;
  --primary: #5B8CFF;
  --primary-hover: #7AA2FF;
  --on-primary: #0B0E14;
  --success: #34C77B;
  --warning: #F0B03F;
  --danger: #EF5A5F;
  --violet: #A98BFF;
  --cyan: #3FC1E8;
  --tone: var(--muted);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; overscroll-behavior: none; touch-action: manipulation; }
*, *::before, *::after { touch-action: manipulation; }
body.ov-open { overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.25rem; line-height: 1.35; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 700; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon { width: 22px; height: 22px; flex: none; }
.icon.big { width: 44px; height: 44px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.head { max-width: 560px; margin: 0 auto; padding: 14px 16px 4px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.conn { flex: none; width: 7px; height: 7px; margin-top: 10px; border-radius: 50%; background: var(--muted); opacity: 0.7; }
.conn.ok { background: var(--success); }
.conn.retry { background: var(--warning); }

.main { max-width: 560px; margin: 0 auto; padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.card-title { margin-bottom: 10px; }
.center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); padding: 32px 16px; }
.big-text { font-size: 1.125rem; color: var(--text); }

.status { position: relative; overflow: hidden; text-align: center; padding-top: 20px; }
.status-top { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.cd-inline { font-size: 0.9375rem; color: var(--text-2); }
.cd-inline strong { font-size: 1.125rem; color: var(--tone); font-variant-numeric: tabular-nums; }
.status.compact { text-align: left; padding: 14px 16px 12px; }
.status.compact .status-top { justify-content: space-between; }
.status.compact .status-line { margin-top: 6px; }
.status.compact .status-msg { margin-top: 6px; font-size: 1rem; }
.status.compact .stats-line { margin-top: 4px; font-size: 0.875rem; }
.status-line { color: var(--text-2); margin-top: 10px; font-size: 0.9375rem; }
.status::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--tone); }
.tone-wait { --tone: var(--warning); }
.tone-reg { --tone: var(--violet); }
.tone-prep { --tone: var(--cyan); }
.tone-open { --tone: var(--success); }
.tone-done { --tone: var(--primary); }
.tone-closed { --tone: var(--muted); }
.tone-bad { --tone: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; font-size: 0.875rem; font-weight: 700; color: var(--tone); background: color-mix(in srgb, var(--tone) 15%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
.badge:empty { display: none; }
.cd-label { color: var(--text-2); margin-top: 12px; font-weight: 500; }
.cd-label:empty { display: none; }
.cd { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.cd-unit { display: flex; flex-direction: column; align-items: center; min-width: 66px; padding: 8px 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.cd-num { font-size: 2.5rem; font-weight: 700; line-height: 1.1; }
.cd-name { font-size: 0.75rem; color: var(--muted); }
.status-line:empty, .status-msg:empty, .stats-line:empty { display: none; }
.status-msg { margin-top: 10px; font-size: 1.0625rem; font-weight: 500; }
.stats-line { margin-top: 8px; color: var(--violet); font-weight: 500; }
.steps { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.step-no { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.875rem; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.step-body { display: flex; flex-direction: column; min-width: 0; }
.step-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-title { font-weight: 700; }
.step-chip { font-size: 0.75rem; font-weight: 700; padding: 0 8px; border-radius: 999px; color: var(--step, var(--muted)); border: 1px solid color-mix(in srgb, var(--step, var(--muted)) 50%, transparent); }
.step-date { font-size: 0.8125rem; color: var(--muted); }
.step-time { font-size: 1.25rem; font-weight: 700; text-align: right; white-space: nowrap; }
.step-next, .step-now { --step: var(--tone); border: 2px solid color-mix(in srgb, var(--tone) 70%, transparent); background: color-mix(in srgb, var(--tone) 10%, var(--surface-2)); }
.step-next .step-no, .step-now .step-no { background: var(--tone); color: var(--on-primary); }
.step-next .step-time, .step-now .step-time { color: var(--tone); }
.step-done { opacity: 0.55; }
.step-done .step-time { font-size: 1rem; }
.step-later .step-time { font-size: 1.0625rem; color: var(--text-2); }
.banner-live { margin: -6px 0 12px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--success) 14%, transparent); border: 1px solid color-mix(in srgb, var(--success) 45%, transparent); color: var(--success); font-weight: 700; }

.success { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; border-color: color-mix(in srgb, var(--success) 50%, transparent); background: color-mix(in srgb, var(--success) 8%, var(--surface)); padding: 20px 16px; }
.success-head { display: flex; align-items: center; gap: 8px; color: var(--success); }
.success-head h2 { font-size: 1.25rem; }
.success-line { font-size: 1.0625rem; font-weight: 700; word-break: break-word; }
.success-slot { font-size: 2rem; line-height: 1.2; font-weight: 700; color: var(--success); word-break: break-word; }
.success .btn { margin-top: 6px; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 4px 0 0; text-align: left; width: 100%; max-width: 360px; }
.info dt { color: var(--muted); font-size: 0.875rem; padding-top: 3px; }
.info dd { margin: 0; font-size: 1.125rem; font-weight: 700; word-break: break-word; }
.pin-toggle { background: none; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--primary-hover); font: inherit; font-size: 0.8125rem; font-weight: 700; padding: 2px 10px; cursor: pointer; align-self: center; }
.pin-box { display: inline-flex; align-items: baseline; gap: 10px; padding: 6px 14px; border-radius: 12px; border: 1px dashed var(--border-strong); background: var(--bg); color: var(--text-2); font-size: 0.875rem; }
.pin-box strong { font-size: 1.375rem; letter-spacing: 0.2em; color: var(--text); }
.registered .pin-box { margin-top: 8px; }
.registered .small { margin-top: 6px; }
.registered { text-align: center; padding: 14px 16px; border-color: color-mix(in srgb, var(--violet) 50%, transparent); background: color-mix(in srgb, var(--violet) 8%, var(--surface)); }
.registered h2 { color: var(--violet); margin-bottom: 4px; }

.announcement { white-space: pre-line; color: var(--text-2); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-label { font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.counter { font-weight: 400; font-size: 0.8125rem; color: var(--muted); }
input[type=text] {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font: inherit; font-size: 1.0625rem;
}
input[type=text]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.25); }
input[type=text]:disabled { opacity: 0.6; }
input.invalid { border-color: var(--danger); }
.size-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.size-btn { min-height: 44px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.125rem; font-weight: 700; cursor: pointer; }
.size-btn[aria-checked="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.size-btn:disabled { opacity: 0.5; }
.hint { padding: 10px 12px; border-radius: 12px; font-size: 0.9375rem; margin-bottom: 8px; }
.hint.warn { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); }
.hint.ok { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border: 1px solid color-mix(in srgb, var(--success) 40%, transparent); }
.rule-line { font-size: 0.875rem; color: var(--muted); margin: -8px 0 8px; }
.form-error { color: var(--danger); font-weight: 500; }
.form-error:empty { display: none; }
.form-error + .btn { margin-top: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.125rem; }
.btn-sm { min-height: 40px; font-size: 0.875rem; padding: 4px 12px; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.form-error + .btn-ghost { margin-top: 8px; }
.btn-ghost + .btn { margin-top: 12px; }
.link-btn { align-self: center; background: none; border: 0; padding: 4px 8px; color: var(--muted); font: inherit; font-size: 0.875rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
#recoverHelp { margin: -4px 0 12px; }
.row-btns { display: flex; gap: 10px; margin-top: 12px; }
.row-btns .btn { flex: 1; }
.notice-list { display: flex; flex-direction: column; gap: 10px; }
.announcement + .notice-list:not(:empty) { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.notice-item { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.notice-time { font-size: 0.75rem; color: var(--primary-hover); font-weight: 700; }
.notice-body { white-space: pre-line; word-break: break-word; }
.change-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 10px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 12%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); color: var(--primary-hover); font-weight: 700; }
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); background: rgba(5, 7, 11, 0.94); }
.overlay-box { width: min(100%, 520px); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: 28px 20px; border-radius: 20px; background: var(--surface); border: 2px solid var(--primary); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.ov-ack .overlay-box { border-color: var(--warning); }
.overlay-box { text-align: center; align-items: center; }
.overlay-box .btn { align-self: stretch; }
.overlay-body { width: 100%; }
.overlay-kicker { font-size: 0.875rem; font-weight: 700; color: var(--primary-hover); letter-spacing: 0.02em; }
.ov-ack .overlay-kicker { color: var(--warning); }
.overlay-body { font-size: 1.375rem; line-height: 1.55; font-weight: 700; white-space: pre-line; word-break: break-word; }
.overlay-note { font-size: 0.875rem; color: var(--muted); }
.ov-alert .overlay-box { border-color: var(--danger); }
.ov-alert .overlay-kicker { color: var(--danger); }
.ov-alert .overlay-body { font-size: 1.125rem; }
.overlay-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.overlay-bar span { display: block; height: 100%; width: 100%; background: var(--primary); }

.slots-msg { color: var(--text-2); margin: -4px 0 10px; font-size: 0.9375rem; }
.slots-msg:empty { display: none; }
.slot-list { display: flex; flex-direction: column; gap: 10px; }
.slot { width: 100%; min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
button.slot { cursor: pointer; }
.slot-main { display: flex; flex-direction: column; min-width: 0; }
.slot-label { font-size: 1.125rem; font-weight: 700; }
.slot-rule { font-size: 0.8125rem; color: var(--muted); }
.slot-state { font-size: 0.9375rem; font-weight: 500; text-align: right; flex: none; max-width: 55%; word-break: break-word; }
.slot.can { border: 2px solid var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); }
.slot.can .slot-state { color: var(--primary-hover); font-weight: 700; }
.slot.can:active { transform: scale(0.99); }
.slot.dim { opacity: 0.5; }
.slot.dim .slot-rule { color: var(--warning); font-weight: 500; }
.slot.taken .slot-state { color: var(--muted); }
.slot.mine { border: 2px solid var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface-2)); }
.slot.mine .slot-state { color: var(--success); font-weight: 700; }
.slot.hl { border-color: color-mix(in srgb, var(--violet) 60%, transparent); }
.slot.busy .slot-state { color: var(--primary-hover); }

.notes { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.note { font-size: 0.8125rem; color: var(--text-2); }
.note.warn { color: var(--warning); font-size: 0.9375rem; font-weight: 500; padding: 10px 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 10%, transparent); }

.inapp { background: color-mix(in srgb, var(--warning) 14%, var(--bg)); border-bottom: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); color: var(--warning); padding: 12px 16px; font-size: 0.9375rem; }
.inapp p { max-width: 560px; margin: 0 auto 8px; }
.inapp-actions { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }

.toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(92vw, 480px); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); font-weight: 500; }
.toast.warn { border-color: color-mix(in srgb, var(--warning) 60%, transparent); color: var(--warning); }
.toast.bad { border-color: color-mix(in srgb, var(--danger) 60%, transparent); color: var(--danger); }
.toast.good { border-color: color-mix(in srgb, var(--success) 60%, transparent); color: var(--success); }
.toast.notice { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 18%, var(--surface-3)); color: var(--text); white-space: pre-line; }

@media (max-width: 360px) {
  .cd-unit { min-width: 56px; }
  .cd-num { font-size: 2rem; }
  .step-time { font-size: 1.0625rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.foot { max-width: 560px; margin: 0 auto; padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center; display: flex; flex-direction: column; gap: 6px; }
.foot-live { color: var(--warning); font-size: 0.875rem; font-weight: 500; }
.foot-copy { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.04em; }
.foot-sep { margin: 0 4px; }
