/* =========================================================================
   Weather Forecast + AI Chat
   Design tokens first, then layout, then components. Everything is
   self-hosted: no webfont, no CDN, no external request at view time, because
   the box this runs on may not have outbound internet when a phone on the LAN
   opens the page.
   ========================================================================= */

:root {
  color-scheme: light;

  --bg: #eef2fb;
  --bg-tint-a: rgba(94, 134, 235, .18);
  --bg-tint-b: rgba(120, 196, 224, .16);

  --surface: #ffffff;
  --surface-2: #f2f5fb;
  --surface-3: #e7ecf6;
  --line: rgba(23, 42, 77, .10);
  --line-strong: rgba(23, 42, 77, .18);

  --ink: #17233a;
  --ink-2: #435372;
  --ink-3: #78859e;

  --accent: #3563d6;
  --accent-ink: #2a51b4;
  --accent-soft: rgba(53, 99, 214, .10);
  --good: #1d8a5c;
  --warn: #b26a10;
  --bad: #c2382d;

  --p1: #3563d6;
  --p2: #d97706;
  --p3: #0d9488;
  --p4: #a855c7;
  --p5: #dc2626;
  --p6: #0284c7;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;

  --shadow-sm: 0 1px 2px rgba(19, 32, 58, .06), 0 2px 8px rgba(19, 32, 58, .05);
  --shadow: 0 2px 6px rgba(19, 32, 58, .06), 0 14px 34px rgba(19, 32, 58, .09);
  --shadow-lg: 0 10px 30px rgba(19, 32, 58, .12), 0 30px 70px rgba(19, 32, 58, .14);

  --wrap: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0b101c;
    --bg-tint-a: rgba(63, 104, 194, .26);
    --bg-tint-b: rgba(31, 116, 141, .20);

    --surface: #141b2b;
    --surface-2: #1a2334;
    --surface-3: #212c40;
    --line: rgba(160, 186, 231, .13);
    --line-strong: rgba(160, 186, 231, .24);

    --ink: #e7edfa;
    --ink-2: #a9b8d4;
    --ink-3: #7d8bA8;

    --accent: #6f9bff;
    --accent-ink: #9dbaff;
    --accent-soft: rgba(111, 155, 255, .14);
    --good: #3ec08a;
    --warn: #e0a248;
    --bad: #ff7a70;

    --p1: #6f9bff;
    --p2: #f0a338;
    --p3: #2dd4bf;
    --p4: #c084fc;
    --p5: #fb7185;
    --p6: #38bdf8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .34), 0 2px 8px rgba(0, 0, 0, .30);
    --shadow: 0 2px 6px rgba(0, 0, 0, .36), 0 16px 38px rgba(0, 0, 0, .44);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .46), 0 32px 76px rgba(0, 0, 0, .52);
  }
}

* { box-sizing: border-box; }

/* The browser's own [hidden] rule is a bare attribute selector, so any class
   here that sets `display` outruns it and the element stays on screen. Several
   sections are shown and hidden through the attribute, so make it win. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 12% -8%, var(--bg-tint-a), transparent 62%),
    radial-gradient(900px 520px at 92% 4%, var(--bg-tint-b), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.6 "Noto Sans Thai", "IBM Plex Sans Thai", "Segoe UI", system-ui,
        -apple-system, "Helvetica Neue", sans-serif;
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico, .hero-ico {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.muted { color: var(--ink-2); }
.small { font-size: 13px; }

h1, h2, h3 { letter-spacing: -.015em; }

main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 22px 18px 56px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ------------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

/* color-mix is recent; without it the bar simply stays opaque, which is fine. */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--bg); }
}

.topbar-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.brand .ico { width: 30px; height: 30px; color: var(--accent); stroke-width: 1.6; }

.brand-text {
  display: flex;
  flex-direction: column;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
}

.brand-text small {
  font-size: 11.5px;
  font-weight: 450;
  color: var(--ink-3);
  letter-spacing: 0;
}

.clock {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.clock .ico { width: 16px; height: 16px; color: var(--accent); }
.clock-body { display: flex; flex-direction: column; line-height: 1.15; }
.clock .k {
  font-size: 10.5px;
  color: var(--ink-3);
  /* The label carries a city name now, which runs far longer than "เวลาไทย".
     Truncate it rather than let it shove the search box off the row. */
  max-width: 13ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clock .v {
  font-size: 14px;
  font-weight: 660;
  /* Tabular figures, or the whole row twitches once a second as the digits
     change width. */
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  margin-left: auto;
  padding: 5px 5px 5px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color .16s, box-shadow .16s;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-ico { width: 17px; height: 17px; color: var(--ink-3); }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 7px 0;
}

.search input:focus { outline: none; }
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 620;
  padding: 9px 18px;
  cursor: pointer;
  transition: filter .15s, transform .1s, background .15s;
}

button:hover:not(:disabled) { filter: brightness(1.07); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }

.suggestions {
  max-width: var(--wrap);
  margin: 10px auto 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 60vh;
  overflow-y: auto;
}

.suggestions li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.suggestions li .sub { color: var(--ink-3); font-size: 13px; }
.suggestions li:hover, .suggestions li:focus { background: var(--accent-soft); outline: none; }
.suggestions li.muted { cursor: default; }
.suggestions li.muted:hover { background: transparent; }

/* --------------------------------------------------------------------- hero */

.hero {
  position: relative;
  overflow: hidden;
  padding: 24px 26px 22px;
  border-radius: var(--radius-lg);
  color: #fff;
  background: linear-gradient(140deg, var(--sky-a, #4b6cb7) 0%, var(--sky-b, #182848) 100%);
  box-shadow: var(--shadow-lg);
  animation: rise .4s ease both;
}

.hero-glow {
  position: absolute;
  inset: -40% -10% auto -10%;
  height: 90%;
  background: radial-gradient(60% 100% at 78% 0%, rgba(255, 255, 255, .34), transparent 70%);
  pointer-events: none;
}

.hero > *:not(.hero-glow) { position: relative; }

.hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.hero-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.hero-actions .stamp {
  font-size: 12px;
  color: rgba(255, 255, 255, .75);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero-place h1 { margin: 0; font-size: 25px; font-weight: 680; }
.hero-place p { margin: 2px 0 0; font-size: 13px; color: rgba(255, 255, 255, .78); }

.hero .icon-btn {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .26);
  color: #fff;
}

.hero .icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .24);
  border-color: rgba(255, 255, 255, .5);
  color: #fff;
}

.hero .icon-btn.spin .ico { animation: spin .8s linear infinite; }

.hero-main {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 14px 0 4px;
  flex-wrap: wrap;
}

.hero-ico {
  width: 82px;
  height: 82px;
  stroke-width: 1.25;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .28));
}

.hero-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  color: rgba(255, 255, 255, .78);
  margin-bottom: 4px;
}

.hero-temp {
  display: flex;
  align-items: flex-start;
  font-size: 68px;
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.hero-temp .unit { font-size: 24px; font-weight: 600; margin-top: 6px; opacity: .8; }

.hero-cond { margin-top: 8px; font-size: 16px; color: rgba(255, 255, 255, .9); }
.hero-cond .sep { opacity: .5; margin: 0 7px; }

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .16);
}

.chip .ico { width: 19px; height: 19px; opacity: .85; }
.chip .body { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chip .k { font-size: 11.5px; color: rgba(255, 255, 255, .74); }
.chip .v { font-size: 15px; font-weight: 640; font-variant-numeric: tabular-nums; }

.hero-note {
  margin: 16px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .78);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.hero-note b { font-weight: 640; color: #fff; }

.hero-note .tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .2);
  font-weight: 600;
}

.hero-note .tag.home {
  background: rgba(255, 255, 255, .92);
  border-color: transparent;
  color: #1b2b46;
}

/* Sky palettes. Named by what the sky is doing, not by provider code. */
.sky-clear-day  { --sky-a: #3f8fe0; --sky-b: #1b4f9c; }
.sky-clear-night{ --sky-a: #2b3a75; --sky-b: #0e1533; }
.sky-cloud-day  { --sky-a: #5c7fa8; --sky-b: #2f4763; }
.sky-cloud-night{ --sky-a: #3a4665; --sky-b: #171d33; }
.sky-rain       { --sky-a: #3b6b8c; --sky-b: #16304a; }
.sky-storm      { --sky-a: #4b4573; --sky-b: #1b1733; }
.sky-snow       { --sky-a: #7b93b5; --sky-b: #37506e; }
.sky-fog        { --sky-a: #6c7a8c; --sky-b: #313a48; }

/* --------------------------------------------------------------------- card */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  animation: rise .4s ease both;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 660;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-head h2 .ico { width: 17px; height: 17px; color: var(--accent); }

.sources { margin-top: 2px; }

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

/* Safari still paints its own triangle without this. */
.sec-head::-webkit-details-marker { display: none; }
.sec-head:hover { border-color: var(--line-strong); }

.sum-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 640;
}

.sum-title .chev {
  width: 17px;
  height: 17px;
  color: var(--ink-3);
  transition: transform .18s ease;
}

details[open] > .sec-head .chev { transform: rotate(180deg); }
details[open] > .sec-head { border-radius: 14px 14px 0 0; border-bottom-color: transparent; }

details[open] > .providers {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  padding: 14px;
  background: var(--surface-2);
}

/* -------------------------------------------------------------- hourly chart */

.chart-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -6px;
  padding: 0 6px 4px;
  scrollbar-width: thin;
}

.chart svg { display: block; }

/* Off-screen but still read aloud. Not `display: none`, which would take it
   out of the accessibility tree along with everything else. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.chart .point { stroke: none; }

.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .axis.strong { fill: var(--ink-2); font-weight: 600; }
.chart .bar { fill: var(--accent); opacity: .18; }
.chart .bar-label { fill: var(--accent-ink); font-size: 10px; font-weight: 600; }
.chart .line { fill: none; stroke-width: 1.6; opacity: .55; stroke-linecap: round; stroke-linejoin: round; }
.chart .mean-line { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.chart .mean-area { fill: url(#meanFade); }
.chart .mean-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.chart .temp-label { fill: var(--ink); font-size: 11.5px; font-weight: 640; font-variant-numeric: tabular-nums; }
.chart .daysep { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 4; }

/* The same alpha that reads as a soft tint on white nearly disappears on the
   dark panel, so the rain bars get their own weight there. */
@media (prefers-color-scheme: dark) {
  .chart .bar { opacity: .30; }
}

.head-tools { display: flex; align-items: center; gap: 8px; }

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 570;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.chip-btn .ico { width: 15px; height: 15px; }
.chip-btn:hover:not(:disabled) { color: var(--accent-ink); border-color: var(--accent); }

.chip-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.legend button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 560;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.legend button .swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: currentColor;
}

.legend button.on { color: var(--ink); border-color: var(--line-strong); }
.legend button.off { opacity: .45; }
.legend button.mean .swatch { border-radius: 2px; height: 3px; width: 14px; }

/* -------------------------------------------------------------------- daily */

.daily { display: flex; flex-direction: column; }

.daily .row {
  display: grid;
  grid-template-columns: 30px 104px 1fr minmax(120px, 1.15fr) 92px;
  align-items: center;
  gap: 12px;
  padding: 11px 6px;
  border-top: 1px solid var(--line);
}

.daily .row:first-child { border-top: 0; }
.daily .row:hover { background: var(--surface-2); border-radius: 12px; }

.daily .ico { width: 22px; height: 22px; color: var(--ink-2); }
.daily .day { font-weight: 600; }
.daily .day .rel { display: block; font-size: 11.5px; font-weight: 450; color: var(--ink-3); }
.daily .cond { color: var(--ink-2); font-size: 13.5px; }

.daily .pop {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent-ink);
  font-weight: 600;
}

.daily .pop .ico { width: 13px; height: 13px; color: inherit; }

.range {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.range span {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #4a9fe0, #f0a338);
}

.temps {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.temps .lo { color: var(--ink-3); }
.temps .hi { font-weight: 680; margin-left: 8px; }

/* ---------------------------------------------------------------- providers */

.providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
  gap: 14px;
}

.pcard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 15px 16px 14px;
  overflow: hidden;
  animation: rise .4s ease both;
}

.pcard::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tint, var(--accent));
}

.pcard.down { opacity: .78; }
.pcard.down::before { background: var(--bad); }
/* A dead source keeps no series colour, so its dot would otherwise fall back
   to the accent and read as just another working provider. */
.pcard.down .dot { background: var(--bad); }

.pcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pcard-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 640;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pcard-head .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tint, var(--accent));
  flex: 0 0 auto;
}

.badge {
  font-size: 11px;
  font-weight: 640;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge.err { background: transparent; color: var(--bad); border: 1px solid currentColor; }

.pnow { display: flex; align-items: center; gap: 12px; }
.pnow .ico { width: 34px; height: 34px; color: var(--ink-2); stroke-width: 1.5; }
.pnow .t { font-size: 30px; font-weight: 690; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.pnow .c { font-size: 13px; color: var(--ink-2); margin-top: 3px; }

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 9px 12px;
  margin: 13px 0 2px;
}

.kv div { min-width: 0; }
.kv .k { display: block; font-size: 11px; color: var(--ink-3); }
.kv .v { font-size: 13.5px; font-weight: 560; font-variant-numeric: tabular-nums; }

.meter {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meter-row { display: flex; flex-direction: column; gap: 5px; }

.meter-row .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.meter-row .top b { font-size: 12.5px; color: var(--ink); font-weight: 660; font-variant-numeric: tabular-nums; }

.track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.track i { display: block; height: 100%; border-radius: 999px; background: var(--tint, var(--accent)); }
.track.calm i { background: var(--ink-3); opacity: .55; }

.pfoot { margin: 10px 0 0; font-size: 11.5px; color: var(--ink-3); }
.pwarn { margin: 9px 0 0; font-size: 12px; color: var(--warn); }
.perr { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-2); }

/* ------------------------------------------------------------------- report */

.report {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  animation: rise .4s ease both;
}

.report .q {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-right: 2px;
}

.report .q .ico { width: 17px; height: 17px; color: var(--accent); }

.report .opts { display: flex; gap: 7px; flex-wrap: wrap; }

.report .opts button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-weight: 560;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.report .opts button .ico { width: 16px; height: 16px; color: var(--ink-2); }

.report .opts button:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.report .opts button:hover:not(:disabled) .ico { color: var(--accent); }

.report input {
  width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
}

.report input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.report .hint { color: var(--ink-3); font-size: 12px; }
.report .report-error { color: var(--bad); font-size: 12.5px; width: 100%; }
.report.done { color: var(--good); }
.report.done .q .ico { color: var(--good); }

/* --------------------------------------------------------------------- chat */

/* Floating launcher, the way a shop's help bubble sits on the page: always
   reachable, never occupying a slot in the forecast. */
.chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 20px 13px 17px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 620;
  box-shadow: 0 6px 18px rgba(19, 32, 58, .22), 0 18px 40px rgba(19, 32, 58, .22);
  animation: rise .35s ease both;
}

.chat-fab .ico { width: 19px; height: 19px; }
.chat-fab:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }

.chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 41;
  width: min(396px, calc(100vw - 32px));
  max-height: min(600px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  padding: 14px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  animation: pop .22s ease both;
  transform-origin: bottom right;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.chat-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 660;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-head h2 .ico { width: 17px; height: 17px; color: var(--accent); }
.chat-head .icon-btn { width: 32px; height: 32px; }
.chat-head .icon-btn .ico { width: 15px; height: 15px; }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 2px 4px;
  scrollbar-width: thin;
}

.chat-log:empty { display: none; }

.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise .25s ease both;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.msg.sys {
  align-self: center;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}

.msg.err {
  align-self: flex-start;
  background: transparent;
  color: var(--bad);
  border: 1px solid currentColor;
  font-size: 13px;
}

.msg .src {
  display: block;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}

.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: blink 1.1s infinite; }
.dots i:nth-child(2) { animation-delay: .18s; }
.dots i:nth-child(3) { animation-delay: .36s; }

.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 5px 5px 5px 15px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color .16s, box-shadow .16s;
}

.chat-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.chat-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 8px 0;
}

.chat-form input:focus { outline: none; }
.chat-form .send { background: var(--accent); color: #fff; border-color: transparent; }
.chat-form .send:hover:not(:disabled) { color: #fff; border-color: transparent; }
.chat-form .send .ico { transform: translateX(-1px); }

.chat-panel p.small { margin: 10px 2px 0; }

.msg { max-width: 86%; }

/* ------------------------------------------------------------------ various */

footer {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 18px 36px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
}

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.empty .ico { width: 34px; height: 34px; display: block; margin: 0 auto 10px; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

/* Skeletons: the same shape as the content that replaces them, so the layout
   does not jump when real numbers land. */
.skel {
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: var(--radius);
}

.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .16), transparent);
  animation: sweep 1.25s infinite;
}

.loading-place {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 2px 4px 10px;
  font-size: 15px;
}

.loading-place b { font-weight: 660; }
.loading-place span { color: var(--ink-3); font-size: 13px; }

.skel.hero-skel { height: 232px; border-radius: var(--radius-lg); }
.skel.card-skel { height: 168px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sweep { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------------ compact */

@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .brand-text small { display: none; }
  .search { max-width: none; width: 100%; margin-left: 0; }
  main { padding: 16px 14px 44px; gap: 14px; }
  .hero { padding: 20px 18px; border-radius: 22px; }
  .hero-place h1 { font-size: 21px; }
  .hero-temp { font-size: 56px; }
  .hero-ico { width: 66px; height: 66px; }
  .card { padding: 15px 15px; }
  /* Explicit areas rather than auto-placement: with a two-column span in the
     middle of the flow the sparse cursor pushes the temperatures onto a row of
     their own instead of keeping them beside the date. */
  .daily .row {
    grid-template-columns: 26px 1fr auto;
    grid-template-areas: "ico day temps" "cond cond cond" "range range range";
    row-gap: 6px;
    column-gap: 10px;
  }
  .daily .row > .ico { grid-area: ico; }
  .daily .day { grid-area: day; }
  .daily .temps { grid-area: temps; }
  .daily .cond { grid-area: cond; font-size: 12.5px; }
  .daily .range-cell { grid-area: range; }
  .msg { max-width: 88%; }
  .clock { padding: 5px 10px; margin-left: auto; }
  .clock .k { display: none; }
  .chat-fab { right: 14px; bottom: 14px; padding: 12px 17px 12px 15px; }

  /* Nearly full screen on a phone: a 396px panel floating over a 390px
     viewport is just a page with wasted margins. */
  .chat-panel {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-height: min(78vh, calc(100vh - 16px));
    border-radius: 18px;
  }
}

@media (max-width: 420px) {
  .hero-temp { font-size: 48px; }
  .chips { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------- sign-in */

.auth { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  transition: border-color .16s, background .16s, transform .16s;
}

.auth-btn .ico { width: 16px; height: 16px; }
.auth-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.auth-btn:active { transform: translateY(1px); }

.auth-who {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  max-width: 210px;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: 0 0 auto;
  object-fit: cover;
  background: var(--surface-3);
}

.avatar.fallback {
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.auth-name {
  font-size: 12.5px;
  font-weight: 580;
  color: var(--ink-2);
  /* A Google display name can be far longer than the bar has room for. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-out { width: 32px; height: 32px; }
.auth-out .ico { width: 16px; height: 16px; }
.auth-out:hover { color: var(--bad); border-color: var(--bad); }

/* ------------------------------------------------------------- favourites */

.favbar {
  display: flex;
  gap: 7px;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 0 10px;
  /* A long list scrolls sideways inside its own strip rather than wrapping the
     header onto a second row on every page it appears. */
  overflow-x: auto;
  scrollbar-width: thin;
}

.fav-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 560;
  cursor: pointer;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: color .16s, border-color .16s, background .16s;
}

.fav-chip .ico { width: 13px; height: 13px; color: var(--ink-3); }
.fav-chip:hover { color: var(--accent-ink); border-color: var(--accent); }

.fav-chip.on {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.fav-chip.on .ico { color: var(--accent); fill: currentColor; }

.fav-btn .ico { transition: fill .16s; }
.fav-btn.on { color: var(--warn); border-color: var(--warn); }
/* The outline star is the same glyph; filling it is what says "saved". */
.fav-btn.on .ico { fill: currentColor; }

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 60;
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  padding: 11px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 560;
  text-align: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* --------------------------------------------------- the signed-out chat */

.chat-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: auto;
  padding: 22px 18px;
  text-align: center;
}

.chat-gate p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  max-width: 26ch;
}
