/* Clima: the canvas design as a stylesheet. Light and dark are both chosen, not flipped. */

:root {
  color-scheme: light;
  --ground: #F2F3F5;
  --card: #FFFFFF;
  --ink: #15191E;
  --ink-2: #4B5563;
  --ink-3: #596271;
  --line: #E3E6EA;
  --line-2: #EEF0F2;
  --chip: #E3E6EA;
  --temp: #eb6834;
  --rain: #2a78d6;
  --wind: #1baf7a;
  --press: #6250d6;
  --sun: #eda100;
  --air: #d55181;
  --bolt: #e34948;
  --ref: #7B8591;
  --good: #0ca30c;
  --bad: #d03b3b;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 16px;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #111312;
    --card: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #a9a89f;
    --line: #2e2f2d;
    --line-2: #262725;
    --chip: #2e2f2d;
    --temp: #d95926;
    --rain: #3987e5;
    --wind: #199e70;
    --press: #9085e9;
    --sun: #c98500;
    --air: #d55181;
    --bolt: #e66767;
    --ref: #8a8f98;
    --good: #0ca30c;
    --bad: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #111312;
  --card: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #a9a89f;
  --line: #2e2f2d;
  --line-2: #262725;
  --chip: #2e2f2d;
  --temp: #d95926;
  --rain: #3987e5;
  --wind: #199e70;
  --press: #9085e9;
  --sun: #c98500;
  --air: #d55181;
  --bolt: #e66767;
  --ref: #8a8f98;
  --good: #0ca30c;
  --bad: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
svg { display: block; }
h1, h2, h3 { margin: 0; }

.shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 20px calc(96px + env(safe-area-inset-bottom)) 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Header */
.header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.header .live { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.header h1 { font-size: 28px; font-weight: 600; line-height: 1.15; }
.header h1.station { font-size: 17px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; flex: none; }
.dot.stale { background: var(--bad); }
.iconbtn {
  width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; flex: none;
}
.iconbtn svg { width: 22px; height: 22px; }
.actions { display: flex; gap: 6px; }

/* Cards and tiles */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.card .title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--ink-2); }
.card .title b { color: var(--ink); font-weight: 600; }
.card .title a { color: var(--rain); text-decoration: none; font-weight: 500; }
.sub { font-size: 12px; color: var(--ink-2); }
.v { font-size: 24px; font-weight: 600; line-height: 1.1; }
.v small, .v .u { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.k { font-size: 11px; color: var(--ink-2); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { text-decoration: none; color: inherit; gap: 8px; min-height: 44px; }
.tile .label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.tile .label svg { width: 16px; height: 16px; }
.tile .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stats .card { padding: 12px 10px; gap: 4px; border-radius: 14px; }
.stats .v { font-size: 18px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Hero */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 2px; }
.hero .temp { display: flex; align-items: flex-start; }
.hero .big { font-size: 112px; font-weight: 300; line-height: 0.88; letter-spacing: -6px; }
.hero .unit { font-size: 34px; font-weight: 400; line-height: 1; margin: 10px 0 0 6px; color: var(--ink-2); }
.hero .side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; text-align: right; padding-bottom: 8px; font-size: 13px; color: var(--ink-2); min-width: 0; white-space: nowrap; }
.hero .side b { color: var(--ink); font-size: 15px; font-weight: 600; }
.v { white-space: nowrap; }
.mini-wide { width: 100%; height: auto; margin-top: 2px; }
.controls { display: flex; flex-direction: column; gap: 12px; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 0; }
.list .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list .item:last-child { border-bottom: 0; }
.list .item .col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list .item .right { text-align: right; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.list .item b { font-weight: 600; }
.list .item .sub { font-size: 12px; }
.list .item.link { text-decoration: none; color: inherit; cursor: pointer; }
.list .item svg.chev { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.list .item .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* Controls */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 500; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--card); border-color: var(--ink); font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--chip); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-weight: 500; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); font-weight: 600; }
.switch { flex: none; width: 48px; height: 28px; border: 0; border-radius: 14px; background: var(--chip); padding: 2px; display: flex; justify-content: flex-start; cursor: pointer; transition: background .15s; }
.switch[aria-checked="true"] { background: var(--ink); justify-content: flex-end; }
.switch span { width: 24px; height: 24px; border-radius: 12px; background: var(--card); display: block; }
.btn {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
  font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--ink); color: var(--card); border-color: var(--ink); }
.btn.dashed { background: transparent; border-style: dashed; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--ink-2); align-items: center; flex-wrap: wrap; }
.legend .sw { width: 14px; height: 2px; display: inline-block; border-radius: 1px; margin-right: 6px; vertical-align: middle; }

/* Charts */
.chart { width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart text { font-family: var(--font); }
.chart .hover { pointer-events: none; }
.chart .hover rect { fill: var(--ink); opacity: .92; }
.chart .hover text { fill: var(--card); font-size: 11px; font-weight: 500; }
.chart .hover line { stroke: var(--ink-3); stroke-dasharray: 2 3; }
.chart .hover circle { stroke: var(--card); stroke-width: 2; }
.chart .lbl { paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round; }
.mini { width: 56px; height: auto; flex: none; }

/* Table */
.table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 280px; }
th, td { padding: 7px 0; text-align: right; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th { font-weight: 600; color: var(--ink-2); font-size: 11px; padding-top: 4px; padding-bottom: 8px; }
th:first-child, td:first-child { text-align: left; font-weight: 500; }
tr:last-child td { border-bottom: 0; }

/* Tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 8px calc(14px + env(safe-area-inset-bottom)) 8px;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 480px; margin: 0 auto;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; min-height: 44px; text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 500; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* States */
.empty { padding: 48px 12px; color: var(--ink-2); text-align: center; line-height: 1.6; }
.empty code { background: var(--card); padding: 2px 6px; border-radius: 6px; }
.warn { border-left: 0; }
.warn .title b { color: var(--bad); }
.muted { color: var(--ink-3); }
.ok { color: var(--good); }
.bad { color: var(--bad); }

/* Desktop: the public-page layout */
@media (min-width: 900px) {
  .shell { max-width: 1280px; padding: 24px 32px 32px 32px; gap: 16px; }
  .header h1.station { font-size: 24px; }
  .tabs {
    position: static; max-width: none; background: transparent; border: 0; padding: 0;
    display: flex; gap: 8px;
  }
  .tab { flex-direction: row; gap: 8px; padding: 0 16px; min-height: 44px; border-radius: 12px; background: var(--card); font-size: 13px; }
  .tab[aria-current="page"] { background: var(--ink); color: var(--card); }
  .screen { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
  .screen > * { flex: 1 1 300px; }
  .screen > .hero-card { flex: 2 1 440px; }
  .screen > .wide { flex: 1 1 100%; }
  .screen > .tiles { display: contents; }
  .tiles > .tile { flex: 1 1 280px; }
  .screen > .stats { display: contents; }
  .stats > .card { flex: 1 1 200px; }
  .card { padding: 20px; gap: 12px; }
  .hero .big { font-size: 120px; }
  .v { font-size: 26px; }
  .stats .v { font-size: 22px; }
  .screen > .controls { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .screen > .controls .seg { flex: 0 1 360px; }
  .screen > .controls .chips { flex: 1 1 480px; }
  .screen > .two { flex: 1 1 100%; display: flex; gap: 8px; justify-content: flex-start; }
  .screen > .two > .btn { flex: 0 0 auto; min-width: 180px; }

  /* Now: the public-page grid. Hero spans two rows on the left, tiles fill the right, table below. */
  .screen-now { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
  .screen-now > .hero-card { grid-column: span 4; grid-row: span 2; }
  .screen-now .tile { grid-column: span 3; }
  .screen-now > .table-card { grid-column: span 4; }
  .screen-now > .warn { grid-column: 1 / -1; }
  .screen-now .hero { align-items: center; }

  .screen-rain { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 16px; }
  .screen-rain > .hero-card { grid-column: span 4; }
  .screen-rain .stats > .card { grid-column: span 1; }
  .screen-rain > .chart-card { grid-column: span 5; }
  .screen-rain > .events-card { grid-column: span 3; }

  .screen-wind { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
  .screen-wind > .hero-card { grid-column: span 6; }
  .screen-wind .stats > .card { grid-column: span 2; }
  .screen-wind > .rose-card { grid-column: span 6; }
  .screen-wind > .gust-card { grid-column: span 6; }

  .screen-sensors, .screen-alerts { align-items: flex-start; }
  .screen-sensors > .station-card { flex-basis: 100%; }
}

/* Casa M room switcher (vendored rooms.js, DRM-2418): Clima's tokens, sized like the icon buttons. */
casam-rooms {
  --casam-rooms-ink: var(--ink); --casam-rooms-bg: var(--card); --casam-rooms-line: var(--line);
  --casam-rooms-gold: var(--rain); --casam-rooms-mark-bg: var(--card);
  --casam-rooms-sans: var(--font); --casam-rooms-serif: var(--font);
}
casam-rooms:not(:defined) { display: none; }
casam-rooms::part(mark) { width: 44px; height: 44px; border-radius: 12px; border: 0; }

/* Sign-in and no-access (DRM-2418) */
.signin { max-width: 420px; margin: 0 auto; padding-top: max(48px, env(safe-area-inset-top)); }
.signin-brand { text-align: center; margin-bottom: 20px; }
.signin-brand img { border-radius: 14px; }
.signin-brand h1 { margin: 10px 0 2px; font-size: 26px; }
.signin-form { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.signin-form label { font-weight: 500; }
.signin-form input { min-height: 46px; font: inherit; font-size: 17px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--ground); color: var(--ink); }
.signin-form .btn { justify-content: center; min-height: 46px; }
.signin-note { min-height: 1.4em; margin: 0; color: var(--ink-2); }
.signin-foot { text-align: center; font-size: 13px; }
