:root {
  color-scheme: light;
  --paper: #f7f5f0;
  --card: #fffefa;
  --ink: #262521;
  --muted: #838078;
  --line: #e7e3da;
  --red: #c6282c;
  --red-dark: #9f1f24;
  --red-soft: #fbefed;
  --green: #397052;
  --amber: #a76823;
  font-family: "DM Sans", "Noto Sans HK", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 88% 5%, rgba(198, 40, 44, .045), transparent 28rem),
    var(--paper);
}

button, input, select { font: inherit; }

.page-shell { width: min(100% - 40px, 720px); margin: 0 auto; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}

.wordmark-light { color: var(--muted); font-weight: 500; }
.mark { width: 23px; height: 23px; border: 3px solid var(--red); border-radius: 50%; display: grid; place-items: center; }
.mark span { width: 10px; height: 3px; background: var(--red); border-radius: 2px; transform: rotate(-14deg); }

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .04em;
}

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #a7a197; box-shadow: 0 0 0 3px #e8e5de; }

main { padding: 64px 0 40px; }

.intro { margin-bottom: 39px; }
.eyebrow { margin: 0 0 14px; color: var(--red); font-size: 10px; font-weight: 700; letter-spacing: .17em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-family: "Noto Sans HK", sans-serif; font-size: clamp(31px, 7vw, 42px); font-weight: 600; letter-spacing: -.055em; line-height: 1.22; }
.intro-copy { margin-bottom: 0; color: var(--muted); font-family: "Noto Sans HK", sans-serif; font-size: 14px; }

.branch-panel, .queue-panel { border-top: 1px solid var(--line); }
.branch-panel { padding: 23px 0 20px; }
.section-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 15px; font-family: "Noto Sans HK", sans-serif; font-size: 14px; font-weight: 600; }
.section-index { color: #b5afa4; font-family: "DM Sans", sans-serif; font-size: 10px; font-weight: 600; letter-spacing: .1em; }
.branch-fields { display: grid; grid-template-columns: minmax(150px, .85fr) minmax(190px, 1.15fr); gap: 10px; }
.search-wrap, .select-wrap { position: relative; }
.search-wrap { display: flex; align-items: center; }
.search-icon { position: absolute; z-index: 1; left: 14px; width: 17px; height: 17px; color: #99958d; pointer-events: none; }
input[type="search"], select {
  width: 100%;
  height: 48px;
  border: 1px solid #ddd9d0;
  border-radius: 7px;
  outline: none;
  color: var(--ink);
  background: var(--card);
  font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
input[type="search"] { padding: 0 13px 0 40px; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
select { appearance: none; padding: 0 42px 0 14px; cursor: pointer; }
.select-wrap > svg { position: absolute; top: 17px; right: 14px; width: 15px; height: 15px; color: #77736c; pointer-events: none; }
input[type="search"]:focus, select:focus-visible, button:focus-visible { border-color: var(--red); box-shadow: 0 0 0 3px rgba(198, 40, 44, .13); }
input::placeholder { color: #a39f96; }
input:disabled, select:disabled { cursor: wait; opacity: .68; }
.branch-detail { min-height: 18px; margin: 10px 0 0; color: var(--muted); font-family: "Noto Sans HK", sans-serif; font-size: 11px; }
.location-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 10px; }
.location-button { min-height: 34px; padding: 0 11px; border: 1px solid #e4cbc1; border-radius: 5px; color: var(--red-dark); background: #fffefa; font-size: 11px; font-weight: 600; cursor: pointer; }
.location-button:hover:not(:disabled) { border-color: #cfa49a; background: #fff; }
.location-button:focus-visible { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(198, 40, 44, .13); }
.location-button:disabled { cursor: wait; opacity: .55; }
.location-status { flex: 1 1 180px; min-width: 0; margin: 0; color: var(--muted); font-family: "Noto Sans HK", sans-serif; font-size: 11px; line-height: 1.6; }
.location-status[data-kind="success"] { color: var(--green); }
.location-status[data-kind="error"] { color: var(--amber); }

.queue-panel { padding-top: 22px; }
.queue-heading-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.section-heading-queue { margin-bottom: 0; }
.section-heading h2 { margin: 0; font-size: 14px; font-weight: 600; }
.refresh-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 76px; height: 33px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; color: #5b5851; background: #fffefa; font-size: 11px; cursor: pointer; }
.refresh-button:hover:not(:disabled) { border-color: #c9c3b8; background: #fff; }
.refresh-button:disabled { cursor: wait; opacity: .55; }
.refresh-button svg { width: 15px; height: 15px; }
.refresh-button.is-loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status-card { display: flex; align-items: flex-start; gap: 13px; min-height: 87px; padding: 19px 18px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 254, 250, .8); }
.status-card[hidden], .queue-content[hidden], [hidden] { display: none !important; }
.status-icon { flex: 0 0 28px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); }
.status-icon-loading span { width: 13px; height: 13px; border: 1.5px solid rgba(198, 40, 44, .25); border-top-color: var(--red); border-radius: 50%; animation: spin .85s linear infinite; }
.status-icon-error { color: var(--amber); background: #f9f0e4; }
.status-icon-error svg { width: 15px; height: 15px; }
.status-icon-empty { color: var(--green); background: #eaf2eb; }
.status-icon-empty svg { width: 15px; height: 15px; }
.status-title { margin: 1px 0 5px; font-family: "Noto Sans HK", sans-serif; font-size: 13px; font-weight: 600; }
.status-copy { margin: 0; color: var(--muted); font-family: "Noto Sans HK", sans-serif; font-size: 12px; line-height: 1.65; }
.status-action { display: inline-flex; margin-top: 10px; padding: 0; border: 0; color: var(--red-dark); background: transparent; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.queue-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 23px; margin: -1px 0 12px; }
.open-status { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-family: "Noto Sans HK", sans-serif; font-size: 11px; }
.open-status::before { width: 6px; height: 6px; border-radius: 50%; background: #68a07b; content: ""; }
.open-status.is-closed { color: #817d75; }
.open-status.is-closed::before { background: #a8a49c; }
.open-status.is-unknown { color: #817d75; }
.open-status.is-unknown::before { background: #a8a49c; }
.updated-at { color: #99958c; font-size: 10px; text-align: right; }
.queue-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.queue-card { min-width: 0; min-height: 154px; padding: 20px 20px 17px; border: 1px solid #eadbd4; border-radius: 8px; background: linear-gradient(145deg, #fffefa 40%, #fbf7f2); }
.queue-card-label { margin-bottom: 18px; color: #77736c; font-family: "Noto Sans HK", sans-serif; font-size: 12px; font-weight: 500; }
.queue-card-number { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .18em; row-gap: .05em; min-width: 0; margin: 0; color: var(--red); font-size: clamp(54px, 12vw, 78px); font-weight: 600; letter-spacing: -.075em; line-height: .98; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.queue-number-value { white-space: nowrap; }
.queue-number-separator { display: none; }
.queue-card-number.is-unavailable { color: #b8b2a8; font-size: 38px; letter-spacing: -.04em; }
.queue-card-hint { margin: 12px 0 0; color: #9a958c; font-family: "Noto Sans HK", sans-serif; font-size: 10px; }
.stale-notice { display: flex; align-items: flex-start; gap: 7px; margin: 12px 0 0; color: var(--amber); font-family: "Noto Sans HK", sans-serif; font-size: 11px; line-height: 1.6; }
.stale-notice::before { flex: 0 0 auto; margin-top: 5px; width: 5px; height: 5px; border-radius: 50%; background: #c88a42; content: ""; }
.footer-note { display: flex; align-items: center; gap: 10px; margin-top: 41px; color: #9b978f; font-family: "Noto Sans HK", sans-serif; font-size: 10px; }
.footer-note p { margin: 0; }
.footer-rule { width: 18px; height: 1px; background: #c9c3b8; }

@media (max-width: 520px) {
  .page-shell { width: min(100% - 36px, 720px); }
  .topbar { height: 65px; }
  main { padding-top: 48px; }
  .intro { margin-bottom: 31px; }
  .branch-fields { grid-template-columns: 1fr; gap: 8px; }
  .branch-panel { padding-top: 19px; }
  .queue-list { grid-template-columns: 1fr; gap: 9px; }
  .queue-card { min-height: 135px; padding: 17px 18px 15px; }
  .queue-card-label { margin-bottom: 13px; }
  .queue-card-number { font-size: 64px; }
  .queue-meta { align-items: flex-start; }
  .updated-at { max-width: 60%; line-height: 1.5; }
  .footer-note { align-items: flex-start; margin-top: 34px; line-height: 1.7; }
  .footer-rule { margin-top: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
