:root {
  --ink: #1c1915;
  --muted: #5e584f;
  --paper: #f4f0e8;
  --panel: #fffcf7;
  --line: #ddd4c4;
  --focus: #1d4e3a;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100%;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.45 "Segoe UI", "PingFang HK", "Noto Sans CJK HK", "Noto Sans CJK TC", "Noto Sans TC", "Noto Sans", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, select { font: inherit; color: inherit; }

a { color: var(--focus); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  max-width: 72rem;
  margin: 0 auto;
}

.utility {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 0;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 14px 8px 8px;
  border: 1px solid #c9bfae;
  border-radius: 999px;
  background: #fff;
  color: var(--focus);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.home-link:hover { border-color: var(--ink); color: var(--ink); }

.home-chevron {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  transform: translateY(-1px);
}

.lang-switch {
  display: inline-flex;
  border: 1px solid #c9bfae;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.lang-switch button {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-weight: 650;
}

.lang-switch button + button { border-left: 1px solid #c9bfae; }

.lang-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: #fbf8f2;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 12px 16px 8px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: Palatino, "Palatino Linotype", "Iowan Old Style", "Times New Roman", serif;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.header-note {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  text-align: right;
}

.disclaimer {
  margin: 0 16px 10px;
  padding: 8px 12px;
  border: 1px solid #e7c07a;
  background: #fff6df;
  color: #3f2e10;
  font-size: 13.5px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 12px;
}

.status {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.status[data-state="loading"] { color: var(--muted); }
.status[data-state="archive"] { background: #fffaf0; }
.status[data-state="error"] { background: #f6f3ec; }

#refresh {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border: 1px solid #c9bfae;
  border-radius: 999px;
  background: #fff;
  font-weight: 650;
}

#refresh:disabled { opacity: 0.55; }

.filters {
  display: grid;
  gap: 8px;
  margin: 0 16px 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  min-height: 44px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #c9bfae;
  border-radius: 10px;
  background: #fff;
}

.count {
  margin: 0 16px 8px;
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 18px;
}

.region {
  margin: 10px 0 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.district {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.district h2 {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.clinic {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.clinic h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.session {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.session-label {
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.days li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.dow {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.avg {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.avg[data-na="true"] {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 550;
}

.empty {
  margin: 0 16px 16px;
  color: var(--muted);
}

.credits {
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line);
  background: #ebe4d6;
  font-size: 12.5px;
  color: #3f3a33;
}

.credits p { margin: 0; }

.noscript {
  margin: 16px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

@media (min-width: 720px) {
  h1 { font-size: 40px; }
  .filters { grid-template-columns: minmax(0, 1.4fr) minmax(14rem, 0.8fr); }
}

@media (min-width: 880px) {
  .clinic {
    display: grid;
    grid-template-columns: minmax(16rem, 1.15fr) minmax(22rem, 1.5fr);
    gap: 8px 20px;
    align-items: center;
  }

  .session { margin: 4px 0 0; }
}

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: flex-start; }
  .header-note { text-align: left; max-width: none; }
  .status-row { align-items: stretch; }
  #refresh { align-self: center; }
}

@media (max-width: 380px) {
  .avg { font-size: 0.82rem; }
  .days { gap: 2px; }
}
