:root {
  color-scheme: light;
  --bg: #efe6d6;
  --paper: #fffaf3;
  --ink: #1c1915;
  --muted: #3f3a34;
  --line: #e3d8c6;
  --teal: #143e3a;
  --teal-ink: #f4efe6;
  --alert: #7a2e22;
  --alert-bg: #f8e4d4;
  --long: #f3d7c4;
  --ok-bg: #e7f2ea;
  --ok-line: #b7d0c0;
  --warn-bg: #f8ecd4;
  --warn-line: #e2c48a;
  --focus: #0b5cab;
  --band-short: #157a45;
  --band-medium: #c4840a;
  --band-long: #c2332b;
  --band-neutral: #8a8178;
  --band-short-bg: #e3f6ea;
  --band-medium-bg: #fff3d4;
  --band-long-bg: #fde3e0;
  --band-neutral-bg: #f1eee8;
  font-family: "Segoe UI", "Helvetica Neue", "PingFang HK", "Noto Sans CJK HK", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  padding-bottom: 7.25rem;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--paper);
  color: var(--ink);
  padding: 0.4rem 0.7rem;
  z-index: 10;
}

.skip:focus { top: 0.75rem; }

a { color: var(--teal); }
a:hover { text-decoration-thickness: 2px; }

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

.top-nav,
.top,
.disclaimer,
.wrap {
  width: min(1120px, calc(100% - 1.5rem));
  margin-inline: auto;
}

.top-nav {
  margin-top: 0.2rem;
}

.top-nav .back {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.4rem 0.75rem 0.4rem 0.1rem;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--teal);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.top-nav .back-chevron {
  font-size: 1.4rem;
  line-height: 1;
  transform: translateY(-1px);
}

.top-nav .back:hover { text-decoration: underline; text-underline-offset: 3px; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.15rem 0 0.7rem;
}

.brand {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 700;
}

h1 {
  margin: 0.1rem 0 0;
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 1.05rem;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.lang {
  display: inline-flex;
  border: 2px solid var(--teal);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.lang button {
  background: transparent;
  color: var(--teal);
  border-radius: 0;
  min-height: 40px;
  min-width: 48px;
  padding: 0.3rem 0.75rem;
  font-weight: 750;
}

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

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

button {
  background: var(--teal);
  color: var(--teal-ink);
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

#refresh-note {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.disclaimer p,
.legend {
  font-size: 0.92rem;
}

.disclaimer p {
  margin: 0 0 0.85rem;
  background: #fff6ea;
  border: 1px solid #efd3b0;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}

.status {
  display: grid;
  gap: 0.15rem;
  margin-bottom: 0.75rem;
}

.status p,
.section-head p {
  margin: 0;
}

#ha-stamp { font-weight: 650; }

#checked-stamp,
#source-note,
.section-head p,
.legend {
  color: var(--muted);
}

.banner {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: var(--alert-bg);
  color: var(--alert);
}

.weather {
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  border-radius: 14px;
  padding: 0.85rem 1rem 0.95rem;
  margin-bottom: 1rem;
}

.weather.has-warnings {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.weather.is-error {
  background: var(--alert-bg);
  border-color: #e7b8a8;
}

.weather-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.pill {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 750;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--teal);
  color: var(--teal-ink);
  white-space: nowrap;
}

.weather.has-warnings .pill {
  background: #6a3d08;
}

.weather.is-error .pill {
  background: var(--alert);
}

#weather-body p { margin: 0.45rem 0 0; }

.warning-list,
.cancelled-list {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.warning-list li,
.cancelled-list li {
  background: rgba(255, 250, 243, 0.72);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
}

.warning-list strong { display: block; }

.warning-meta,
.cancelled-list {
  color: var(--muted);
  font-size: 0.85rem;
}

.section-head { margin-bottom: 0.55rem; }

#map-section { margin-bottom: 1.1rem; }

.map-wrap {
  position: relative;
  height: 380px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #e7e1d6;
}

#map { height: 100%; background: #e7e1d6; }

.map-legend {
  position: absolute;
  z-index: 500;
  top: 10px;
  left: 10px;
  margin: 0;
  padding: 0.4rem 0.6rem;
  list-style: none;
  background: rgba(255, 250, 243, 0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.map-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.12rem 0;
}

.map-fallback {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.leaflet-container { font: inherit; }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-popup-content p { margin: 0.2rem 0 0; }

.pin-popup strong { display: block; }

.dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
}

.dot.band-short { background: var(--band-short); }
.dot.band-medium { background: var(--band-medium); }
.dot.band-long { background: var(--band-long); }
.dot.band-neutral { background: var(--band-neutral); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.65rem;
}

.toolbar label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted);
}

input,
select {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  min-width: 14rem;
}

.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

caption {
  caption-side: bottom;
  text-align: left;
  padding: 0.55rem 0.7rem 0.7rem;
  color: var(--muted);
  font-size: 0.8rem;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.42rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

thead th {
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

thead th span {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

thead th span:first-child {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

tbody th {
  font-weight: 650;
  min-width: 12rem;
}

tr:last-child th,
tr:last-child td { border-bottom: 0; }

tr.band-short { background: var(--band-short-bg); }
tr.band-medium { background: var(--band-medium-bg); }
tr.band-long { background: var(--band-long-bg); }
tr.band-neutral { background: var(--band-neutral-bg); }

tr.band-short > :first-child { box-shadow: inset 6px 0 0 var(--band-short); }
tr.band-medium > :first-child { box-shadow: inset 6px 0 0 var(--band-medium); }
tr.band-long > :first-child { box-shadow: inset 6px 0 0 var(--band-long); }
tr.band-neutral > :first-child { box-shadow: inset 6px 0 0 var(--band-neutral); }

.wait.alert {
  background: var(--alert-bg);
  color: var(--alert);
  font-weight: 700;
}

.hosp-btn {
  display: inline;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-weight: 650;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.band-tag {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.cards { display: grid; gap: 0.65rem; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 14px;
  padding: 0.75rem 0.85rem 0.85rem;
}

.card.band-short { background: var(--band-short-bg); border-left-color: var(--band-short); }
.card.band-medium { background: var(--band-medium-bg); border-left-color: var(--band-medium); }
.card.band-long { background: var(--band-long-bg); border-left-color: var(--band-long); }
.card.band-neutral { background: var(--band-neutral-bg); border-left-color: var(--band-neutral); }

.card h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.card dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.75rem;
  margin: 0;
}

.card dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 700;
}

.card dd { margin: 0.1rem 0 0; }

.legend { margin: 0.7rem 0 0; }

.attrib {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  background: var(--teal);
  color: var(--teal-ink);
  padding: 0.6rem 0.9rem 0.7rem;
  font-size: 0.82rem;
}

.attrib p {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.attrib p + p { margin-top: 0.15rem; }

.attrib a { color: #f4efe6; }

.noscript {
  width: min(1120px, calc(100% - 1.5rem));
  margin: 1rem auto;
}

@media (max-width: 720px) {
  body { padding-bottom: 8.5rem; }

  .top {
    align-items: flex-start;
    padding-top: 0.7rem;
    padding-bottom: 0.4rem;
  }

  h1 { font-size: 1.4rem; }

  .actions { text-align: right; }

  .disclaimer p {
    font-size: 0.84rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.6rem;
  }

  .weather {
    padding: 0.6rem 0.7rem 0.7rem;
    margin-bottom: 0.7rem;
  }

  input,
  select { min-width: 0; width: 100%; }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .map-wrap { height: 210px; }

  .card { padding: 0.6rem 0.7rem 0.7rem; }

  .card h3 { margin-bottom: 0.3rem; }

  .attrib {
    padding: 0.45rem 0.7rem 0.55rem;
    font-size: 0.75rem;
  }

  thead th span { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
