:root {
  color-scheme: light;
  /* Warm sunny palette, inspired by the Toasty sun favicon. */
  --ink: #2a2030;
  --muted: #8c7a6a;
  --line: #ecd9bd;
  --soft: #fbf3e4;
  --panel: #fffdf7;
  --cream: #fdf6e9;
  --sun: #f59e0b;
  --sun-deep: #e0770b;
  --sun-soft: #fff0d2;
  --blue: #2f7fc4;
  --green: #0d9488;
  --red: #dc2f3f;
  --amber: #d97706;
  --sky: #fff4d6;
  --shadow: 0 18px 40px rgba(224, 119, 11, 0.10);
  --shadow-soft: 0 10px 24px rgba(180, 120, 40, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --font-rounded: ui-rounded, "SF Pro Rounded", "Segoe UI Rounded", "Nunito", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #fdf6e9;
  /* Guard against sub-pixel / safe-area horizontal overflow in the iOS PWA.
     Intentional horizontal scrollers (chart, tables, range buttons) are nested
     with their own overflow-x, so this only clips stray page-level overflow. */
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100dvh;
  max-width: 100%;
  background:
    radial-gradient(1200px 480px at 50% -120px, rgba(255, 213, 128, 0.55), rgba(255, 213, 128, 0) 70%),
    linear-gradient(180deg, #fff7ea 0%, #fdf4e2 320px, #fdf6e9 100%);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding:
    calc(24px + env(safe-area-inset-top))
    calc(24px + env(safe-area-inset-right))
    calc(24px + env(safe-area-inset-bottom))
    calc(24px + env(safe-area-inset-left));
}

.pull-refresh {
  position: fixed;
  z-index: 20;
  top: calc(6px + env(safe-area-inset-top));
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid rgba(29, 36, 48, 0.12);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(29, 36, 48, 0.16);
  pointer-events: none;
  transform: translate3d(-50%, 0, 0);
  transition: transform 160ms ease, opacity 160ms ease;
}

.pull-refresh[hidden] {
  display: none;
}

.pull-refresh strong {
  font-size: 12px;
  line-height: 1;
}

.pull-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #f3dca8;
  border-top-color: var(--sun-deep);
  border-radius: 999px;
}

.pull-refresh.ready .pull-spinner,
.is-refreshing .pull-spinner {
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.topbar,
.toolbar,
.latest-reading,
.day-comparison,
.workbench,
.annual-panel,
.setup-band {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mascot {
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff7da, #ffd23f 55%, #f7991f);
  box-shadow:
    0 0 0 6px rgba(255, 213, 128, 0.35),
    0 10px 22px rgba(231, 122, 12, 0.35);
  font-size: 28px;
  line-height: 1;
  animation: mascot-bob 4.5s ease-in-out infinite;
}

@keyframes mascot-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-3px) rotate(4deg); }
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: var(--font-rounded);
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 800;
  background: linear-gradient(135deg, #e0770b, #d97706 40%, #dc2f3f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 {
  font-family: var(--font-rounded);
  font-size: 19px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.status-strip,
.toolbar,
.year-toggles,
.chart-legend,
.range-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.pill {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.button.primary {
  background: linear-gradient(135deg, #f59e0b, #e0770b);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(224, 119, 11, 0.32);
}

.button.primary:hover {
  box-shadow: 0 14px 28px rgba(224, 119, 11, 0.42);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.pill {
  border-radius: 999px;
}

.pill.ok {
  color: #ffffff;
  background: var(--green);
  border-color: transparent;
}

.pill.warn {
  color: #ffffff;
  background: var(--amber);
  border-color: transparent;
}

.setup-band {
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid #f0c987;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #fff8e8, #fff1d2);
}

.setup-band div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cache-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.cache-notice[hidden] {
  display: none;
}

.cache-notice-spinner {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--sun-deep);
  border-radius: 50%;
  animation: cache-notice-spin 0.8s linear infinite;
}

@keyframes cache-notice-spin {
  to { transform: rotate(360deg); }
}

.cache-notice.is-stale {
  color: var(--amber);
  border-color: #f0c987;
  background: #fff8e8;
}

.cache-notice.is-stale .cache-notice-spinner {
  display: none;
}

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

.toolbar {
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
}

.latest-reading {
  --wake-accent: 224, 119, 11;
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  background:
    linear-gradient(135deg, var(--sun-soft), rgba(255, 255, 255, 0.96) 60%),
    var(--panel);
  box-shadow: var(--shadow);
  transition: background 0.4s ease, border-color 0.4s ease;
  overflow: hidden;
}

/* One-shot "Weather Wake-Up" layer. Temperature decides the colour and
   texture; the narrator's short-term trend decides how the number moves. */
.latest-reading::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -55% -20%;
  background: linear-gradient(
    112deg,
    transparent 34%,
    rgba(var(--wake-accent), 0.06) 43%,
    rgba(var(--wake-accent), 0.5) 50%,
    rgba(255, 255, 255, 0.86) 54%,
    transparent 66%
  );
  opacity: 0;
  pointer-events: none;
  transform: translateX(-55%) rotate(-5deg);
}

.latest-reading[data-wake-band="hot"] { --wake-accent: 220, 47, 63; }
.latest-reading[data-wake-band="warm"] { --wake-accent: 224, 119, 11; }
.latest-reading[data-wake-band="neutral"] { --wake-accent: 245, 158, 11; }
.latest-reading[data-wake-band="cool"] { --wake-accent: 47, 127, 196; }
.latest-reading[data-wake-band="cold"] { --wake-accent: 33, 102, 172; }

.latest-reading.is-weather-waking {
  animation: weather-wake-card 2.05s cubic-bezier(0.16, 0.9, 0.25, 1) both;
}

.latest-reading.is-weather-waking::before {
  animation: weather-wake-sweep 1.75s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-mode="soft"]::before {
  animation-name: weather-wake-sweep-soft;
}

.latest-reading.is-weather-waking::after {
  animation: weather-wake-glow 2.1s ease-out both;
}

@keyframes weather-wake-card {
  0%, 100% {
    box-shadow: var(--shadow);
    transform: translateY(0) scale(1);
  }
  20% {
    box-shadow: 0 0 0 4px rgba(var(--wake-accent), 0.24), 0 14px 34px rgba(var(--wake-accent), 0.24);
    transform: translateY(-4px) scale(1.012);
  }
  44% {
    box-shadow: 0 0 0 9px rgba(var(--wake-accent), 0.08), 0 18px 44px rgba(var(--wake-accent), 0.2);
    transform: translateY(-1px) scale(1.004);
  }
  68% { transform: translateY(-2px) scale(1.007); }
}

@keyframes weather-wake-sweep {
  0% { opacity: 0; transform: translateX(-55%) rotate(-5deg); }
  16% { opacity: 1; }
  64% { opacity: 0.84; }
  100% { opacity: 0; transform: translateX(55%) rotate(-5deg); }
}

@keyframes weather-wake-sweep-soft {
  0% { opacity: 0; transform: translateX(-48%) rotate(-5deg); }
  28% { opacity: 0.8; }
  100% { opacity: 0; transform: translateX(48%) rotate(-5deg); }
}

@keyframes weather-wake-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  28% { opacity: 1; transform: scale(1.55); }
  58% { opacity: 0.78; transform: scale(1.24); }
}

/* Sunny glow corner accent */
.latest-reading::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 210, 63, 0.45), rgba(255, 210, 63, 0) 70%);
  pointer-events: none;
}

/* Temperature-reactive hero tones (set from app.js) */
.latest-reading[data-tone="hot"] {
  border-color: rgba(220, 47, 63, 0.4);
  background:
    linear-gradient(135deg, rgba(255, 224, 224, 0.92), rgba(255, 255, 255, 0.96) 60%),
    var(--panel);
}
.latest-reading[data-tone="hot"]::after {
  background: radial-gradient(circle, rgba(220, 47, 63, 0.35), rgba(220, 47, 63, 0) 70%);
}

.latest-reading[data-tone="warm"] {
  border-color: rgba(224, 119, 11, 0.38);
  background:
    linear-gradient(135deg, rgba(255, 234, 200, 0.94), rgba(255, 255, 255, 0.96) 60%),
    var(--panel);
}

.latest-reading[data-tone="cool"] {
  border-color: rgba(47, 127, 196, 0.32);
  background:
    linear-gradient(135deg, rgba(224, 238, 255, 0.94), rgba(255, 255, 255, 0.96) 60%),
    var(--panel);
}
.latest-reading[data-tone="cool"]::after {
  background: radial-gradient(circle, rgba(47, 127, 196, 0.28), rgba(47, 127, 196, 0) 70%);
}

.latest-reading[data-tone="cold"] {
  border-color: rgba(33, 102, 172, 0.38);
  background:
    linear-gradient(135deg, rgba(210, 228, 246, 0.94), rgba(255, 255, 255, 0.96) 60%),
    var(--panel);
}
.latest-reading[data-tone="cold"]::after {
  background: radial-gradient(circle, rgba(33, 102, 172, 0.3), rgba(33, 102, 172, 0) 70%);
}

.latest-reading-headline {
  display: grid;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.yesterday-reading-card {
  display: grid;
  gap: 4px;
  min-width: 178px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.85);
  position: relative;
  z-index: 1;
}

.yesterday-reading-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.latest-reading .yesterday-reading-card strong {
  color: var(--ink);
  font-family: var(--font-rounded);
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
}

.yesterday-reading-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.trend-phrase {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 92px;
  margin-bottom: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 48px 20px 24px;
  background: rgba(255, 255, 255, 0.85);
  font-family: var(--font-rounded);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
  text-transform: none;
  -webkit-text-size-adjust: 100%;
  transition: color 0.3s, background 0.3s, border-color 0.3s;
}

.trend-phrase-inner {
  margin: 0;
  text-align: center;
}

.tide-schedule {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #176399;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
}

.tide-schedule[hidden] {
  display: none !important;
}

.tide-schedule-label {
  color: var(--muted);
  font-weight: 700;
}

.tide-time {
  display: inline-block;
  border: 1px solid rgba(47, 127, 196, 0.32);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(218, 239, 255, 0.9);
  color: #165c90;
  font-weight: 800;
  white-space: nowrap;
}

.trend-refresh-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.trend-refresh-button:hover {
  background: rgba(255, 255, 255, 0.95);
}

.trend-refresh-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.trend-refresh-button.is-loading {
  animation: trend-refresh-spin 0.9s linear infinite;
}

.trend-refresh-button[hidden] {
  display: none !important;
}

@keyframes trend-refresh-spin {
  to { transform: rotate(360deg); }
}

.trend-phrase[hidden] {
  display: none !important;
}

.trend-phrase[data-tone="hot"] {
  color: #b01f2b;
  border-color: rgba(220, 47, 63, 0.4);
  background: linear-gradient(135deg, rgba(255, 224, 224, 0.85), rgba(255, 255, 255, 0.85) 60%);
}

.trend-phrase[data-tone="warm"] {
  color: #b45f09;
  border-color: rgba(224, 119, 11, 0.4);
  background: linear-gradient(135deg, rgba(255, 234, 200, 0.9), rgba(255, 255, 255, 0.85) 60%);
}

.trend-phrase[data-tone="neutral"] {
  color: var(--muted);
  border-color: var(--line);
  background: linear-gradient(135deg, rgba(255, 240, 210, 0.7), rgba(255, 255, 255, 0.85) 60%);
}

.trend-phrase[data-tone="cool"] {
  color: #1f5f9d;
  border-color: rgba(47, 127, 196, 0.4);
  background: linear-gradient(135deg, rgba(224, 238, 255, 0.9), rgba(255, 255, 255, 0.85) 60%);
}

.trend-phrase[data-tone="cold"] {
  color: #2166ac;
  border-color: rgba(33, 102, 172, 0.4);
  background: linear-gradient(135deg, rgba(214, 230, 248, 0.92), rgba(255, 255, 255, 0.85) 60%);
}

.reading-history {
  position: relative;
  z-index: 1;
  display: grid;
  flex: 1;
  gap: 8px;
  justify-items: center;
}

.reading-history[hidden] {
  display: none;
}

.reading-history h2 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.reading-timeline {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: center;
}

.reading-chip {
  display: grid;
  gap: 2px;
  justify-items: center;
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.82);
  transition: transform 0.12s ease;
}

.reading-chip:hover {
  transform: translateY(-2px);
}

.reading-chip-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Scoped under .reading-chip to outrank `.latest-reading strong` (these values
   are <strong> elements inside the latest-reading section). */
.reading-chip .reading-chip-value {
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
  line-height: 1;
}

.reading-chip.is-now {
  border-color: rgba(224, 119, 11, 0.55);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(245, 158, 11, 0.04));
  box-shadow: 0 2px 10px rgba(224, 119, 11, 0.22);
}

.reading-chip.is-now .reading-chip-label {
  color: var(--sun-deep);
}

.reading-chip.is-now .reading-chip-value {
  font-size: 24px;
  font-weight: 850;
}

.latest-reading-headline > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.latest-reading strong {
  color: var(--ink);
  font-family: var(--font-rounded);
  font-size: 46px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

#latestTemperature {
  position: relative;
  z-index: 2;
  display: inline-block;
  transform-origin: 50% 60%;
}

#latestTemperature::before {
  content: attr(data-previous-temperature);
  position: absolute;
  inset: 0 auto auto 0;
  width: max-content;
  color: inherit;
  opacity: 0;
  pointer-events: none;
}

.latest-reading-value {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  perspective: 520px;
}

.latest-reading-value::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -14px -18px;
  border: 3px solid rgba(var(--wake-accent), 0.72);
  border-radius: 999px;
  box-shadow:
    0 0 0 0 rgba(var(--wake-accent), 0.28),
    inset 0 0 22px rgba(var(--wake-accent), 0.16);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.45);
}

.latest-reading-value::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: -18px;
  top: 50%;
  min-width: calc(100% + 36px);
  color: rgba(var(--wake-accent), 0.88);
  font-family: var(--font-rounded);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
}

.latest-reading.is-weather-waking[data-wake-band="hot"] .latest-reading-value::after {
  content: "⌁  ≈  ⌁";
  font-size: 34px;
  animation: weather-heat-flourish 1.95s 0.1s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-band="cold"] .latest-reading-value::after {
  content: "✦  ❄  ✦";
  font-size: 30px;
  color: rgba(33, 102, 172, 0.78);
  animation: weather-frost-flourish 1.95s 0.08s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-band="warm"] .latest-reading-value::after {
  content: "✦  ✹  ✦";
  font-size: 28px;
  animation: weather-spark-flourish 1.75s 0.12s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-band="neutral"] .latest-reading-value::after {
  content: "✦  ✦";
  font-size: 27px;
  animation: weather-spark-flourish 1.75s 0.12s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-band="cool"] .latest-reading-value::after {
  content: "✦  ❄  ✦";
  font-size: 27px;
  animation: weather-frost-flourish 1.75s 0.12s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-mode="soft"] .latest-reading-value::after {
  animation: weather-soft-flourish 1.65s 0.08s ease-out both;
}

.latest-reading.is-weather-waking .latest-reading-value::before {
  animation: weather-temperature-shockwave 1.7s 0.08s cubic-bezier(0.12, 0.76, 0.22, 1) both;
}

.latest-reading.is-weather-waking[data-wake-mode="soft"] #latestTemperature {
  animation: weather-temperature-soft 1.55s cubic-bezier(0.16, 0.9, 0.25, 1.1) both;
}

.latest-reading.is-weather-waking[data-wake-mode="fresh"] {
  --wake-distance: 18px;
}

.latest-reading.is-weather-waking[data-wake-mode="fresh"][data-wake-intensity="quick"] {
  --wake-distance: 34px;
}

.latest-reading.is-weather-waking[data-wake-mode="fresh"][data-wake-direction="rising"] #latestTemperature {
  animation: weather-temperature-rise-in 1.4s cubic-bezier(0.14, 0.9, 0.2, 1.18) both;
}

.latest-reading.is-weather-waking[data-wake-mode="fresh"][data-wake-direction="rising"] #latestTemperature::before {
  animation: weather-temperature-rise-out 0.72s ease-in both;
}

.latest-reading.is-weather-waking[data-wake-mode="fresh"][data-wake-direction="falling"] #latestTemperature {
  animation: weather-temperature-fall-in 1.4s cubic-bezier(0.14, 0.9, 0.2, 1.16) both;
}

.latest-reading.is-weather-waking[data-wake-mode="fresh"][data-wake-direction="falling"] #latestTemperature::before {
  animation: weather-temperature-fall-out 0.72s ease-in both;
}

.latest-reading.is-weather-waking[data-wake-mode="fresh"][data-wake-direction="steady"] #latestTemperature {
  animation: weather-temperature-settle 1.45s cubic-bezier(0.16, 0.9, 0.25, 1.1) both;
}

@keyframes weather-temperature-soft {
  0% { opacity: 0.28; filter: blur(2px); transform: scale(0.7) rotate(-3deg); }
  30% { opacity: 1; filter: blur(0); transform: scale(1.2) rotate(1.5deg); }
  54% { transform: scale(0.94) rotate(-0.5deg); }
  74% { transform: scale(1.07) rotate(0); }
  100% { opacity: 1; filter: blur(0); transform: scale(1) rotate(0); }
}

@keyframes weather-temperature-rise-in {
  0% { opacity: 0; filter: blur(3px); transform: translateY(var(--wake-distance)) rotateX(-72deg) scale(0.68); }
  38% { opacity: 1; filter: blur(0); transform: translateY(-9px) rotateX(10deg) scale(1.17); }
  60% { transform: translateY(3px) rotateX(-4deg) scale(0.96); }
  78% { transform: translateY(-2px) rotateX(1deg) scale(1.05); }
  100% { opacity: 1; filter: blur(0); transform: translateY(0) rotateX(0) scale(1); }
}

@keyframes weather-temperature-rise-out {
  0% { opacity: 0.62; transform: translateY(0) scale(1); }
  38%, 100% { opacity: 0; transform: translateY(calc(var(--wake-distance) * -1)) scale(0.9); }
}

@keyframes weather-temperature-fall-in {
  0% { opacity: 0; filter: blur(3px); transform: translateY(calc(var(--wake-distance) * -1)) rotateX(72deg) scale(0.68); }
  38% { opacity: 1; filter: blur(0); transform: translateY(9px) rotateX(-10deg) scale(1.17); }
  60% { transform: translateY(-3px) rotateX(4deg) scale(0.96); }
  78% { transform: translateY(2px) rotateX(-1deg) scale(1.05); }
  100% { opacity: 1; filter: blur(0); transform: translateY(0) rotateX(0) scale(1); }
}

@keyframes weather-temperature-fall-out {
  0% { opacity: 0.62; transform: translateY(0) scale(1); }
  38%, 100% { opacity: 0; transform: translateY(var(--wake-distance)) scale(0.9); }
}

@keyframes weather-temperature-settle {
  0% { opacity: 0.25; filter: blur(2px); transform: scale(0.64) rotate(-4deg); }
  32% { opacity: 1; filter: blur(0); transform: scale(1.2) rotate(2deg); }
  52% { transform: scale(0.93) rotate(-1deg); }
  72% { transform: scale(1.07) rotate(0.5deg); }
  100% { opacity: 1; filter: blur(0); transform: scale(1) rotate(0); }
}

@keyframes weather-temperature-shockwave {
  0% { opacity: 0; transform: scale(0.42); }
  18% { opacity: 0.9; transform: scale(0.72); }
  62% {
    border-width: 2px;
    box-shadow: 0 0 0 14px rgba(var(--wake-accent), 0.1), inset 0 0 30px rgba(var(--wake-accent), 0.08);
    opacity: 0.42;
    transform: scale(1.28);
  }
  100% {
    border-width: 1px;
    box-shadow: 0 0 0 30px rgba(var(--wake-accent), 0), inset 0 0 34px rgba(var(--wake-accent), 0);
    opacity: 0;
    transform: scale(1.72);
  }
}

@keyframes weather-heat-flourish {
  0% { opacity: 0; filter: blur(5px); transform: translateY(16px) scaleX(0.58); }
  26% { opacity: 0.94; filter: blur(0.5px); }
  62% { opacity: 0.74; transform: translateY(-30px) scaleX(1.14); }
  100% { opacity: 0; filter: blur(5px); transform: translateY(-62px) scaleX(1.34); }
}

@keyframes weather-frost-flourish {
  0% { opacity: 0; filter: blur(2px); transform: translateY(-50%) scale(0.22) rotate(-18deg); }
  30% { opacity: 0.96; filter: blur(0); transform: translateY(-50%) scale(1.18) rotate(5deg); }
  62% { opacity: 0.72; transform: translateY(-50%) scale(1.45) rotate(-5deg); }
  100% { opacity: 0; filter: blur(2px); transform: translateY(-50%) scale(1.85) rotate(14deg); }
}

@keyframes weather-spark-flourish {
  0% { opacity: 0; transform: translate(-12px, -34%) scale(0.22) rotate(-28deg); }
  28% { opacity: 0.98; transform: translate(8px, -72%) scale(1.2) rotate(8deg); }
  64% { opacity: 0.64; transform: translate(32px, -96%) scale(0.92) rotate(24deg); }
  100% { opacity: 0; transform: translate(56px, -130%) scale(0.42) rotate(48deg); }
}

@keyframes weather-soft-flourish {
  0%, 100% { opacity: 0; transform: translateY(-50%) scale(0.42); }
  30% { opacity: 0.8; transform: translateY(-62%) scale(1.08); }
  62% { opacity: 0.5; transform: translateY(-76%) scale(1.28); }
}

.weather-emoji {
  position: relative;
  z-index: 2;
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.10));
  animation: emoji-appear 0.4s ease-out both;
}

.weather-emoji[hidden] {
  display: none !important;
}

@keyframes emoji-appear {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.trend-arrow {
  position: relative;
  z-index: 2;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
  transition: color 0.3s;
}

.trend-arrow::before {
  content: "";
  position: absolute;
  right: 50%;
  bottom: 50%;
  width: max-content;
  color: currentColor;
  font-size: 18px;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 50%);
}

.trend-arrow[hidden] {
  display: none !important;
}

.trend-arrow[data-direction="rising"] {
  color: #dc2f3f;
}

.trend-arrow[data-direction="falling"] {
  color: #2f7fc4;
}

.trend-arrow[data-direction="steady"] {
  color: var(--muted);
}

.latest-reading.is-weather-waking[data-wake-direction="rising"] .trend-arrow {
  animation: weather-arrow-rise 1.45s cubic-bezier(0.14, 0.9, 0.2, 1.2) both;
}

.latest-reading.is-weather-waking[data-wake-direction="falling"] .trend-arrow {
  animation: weather-arrow-fall 1.45s cubic-bezier(0.14, 0.9, 0.2, 1.18) both;
}

.latest-reading.is-weather-waking[data-wake-direction="steady"] .trend-arrow {
  animation: weather-arrow-steady 1.4s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-intensity="quick"] .trend-arrow {
  animation-duration: 1.65s;
}

.latest-reading.is-weather-waking[data-wake-mode="soft"] .trend-arrow {
  animation: weather-arrow-soft 1.45s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-direction="rising"] .trend-arrow::before {
  content: "↑  ↑";
  animation: weather-arrow-trail-rise 1.75s 0.08s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-direction="falling"] .trend-arrow::before {
  content: "↓  ↓";
  animation: weather-arrow-trail-fall 1.75s 0.08s ease-out both;
}

.latest-reading.is-weather-waking[data-wake-direction="steady"] .trend-arrow::before {
  content: "—  —";
  animation: weather-arrow-trail-steady 1.65s 0.08s ease-out both;
}

@keyframes weather-arrow-rise {
  0% { filter: blur(2px); opacity: 0.1; transform: translateY(24px) scale(0.46); }
  30% { filter: blur(0); opacity: 1; transform: translateY(-14px) scale(1.5); }
  54% { transform: translateY(5px) scale(0.88); }
  74% { transform: translateY(-3px) scale(1.12); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes weather-arrow-fall {
  0% { filter: blur(2px); opacity: 0.1; transform: translateY(-24px) scale(0.46); }
  30% { filter: blur(0); opacity: 1; transform: translateY(14px) scale(1.5); }
  54% { transform: translateY(-5px) scale(0.88); }
  74% { transform: translateY(3px) scale(1.12); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes weather-arrow-steady {
  0% { filter: blur(2px); opacity: 0.1; transform: scaleX(0.3) scaleY(0.7); }
  34% { filter: blur(0); opacity: 1; transform: scaleX(1.55) scaleY(1.18); }
  62% { transform: scaleX(0.82) scaleY(0.94); }
  100% { opacity: 1; transform: scaleX(1); }
}

@keyframes weather-arrow-soft {
  0%, 100% { opacity: 1; transform: translateY(0) scale(1); }
  26% { opacity: 0.82; transform: translateY(-5px) scale(1.36); }
  54% { opacity: 1; transform: translateY(2px) scale(0.9); }
  76% { transform: translateY(-1px) scale(1.08); }
}

@keyframes weather-arrow-trail-rise {
  0% { opacity: 0; transform: translate(50%, 75%) scale(0.45); }
  28% { opacity: 0.72; }
  100% { opacity: 0; transform: translate(50%, -145%) scale(1.15); }
}

@keyframes weather-arrow-trail-fall {
  0% { opacity: 0; transform: translate(50%, -75%) scale(0.45); }
  28% { opacity: 0.72; }
  100% { opacity: 0; transform: translate(50%, 145%) scale(1.15); }
}

@keyframes weather-arrow-trail-steady {
  0% { opacity: 0; transform: translate(50%, 50%) scaleX(0.2); }
  32% { opacity: 0.62; transform: translate(50%, 50%) scaleX(1.25); }
  100% { opacity: 0; transform: translate(50%, 50%) scaleX(1.8); }
}

@media (prefers-reduced-motion: reduce) {
  .latest-reading.is-weather-waking,
  .latest-reading.is-weather-waking::after,
  .latest-reading.is-weather-waking #latestTemperature,
  .latest-reading.is-weather-waking #latestTemperature::before,
  .latest-reading.is-weather-waking .trend-arrow,
  .latest-reading.is-weather-waking .trend-arrow::before {
    animation: none !important;
  }

  .latest-reading.is-weather-waking::before,
  .latest-reading.is-weather-waking .latest-reading-value::before,
  .latest-reading.is-weather-waking .latest-reading-value::after {
    animation: none !important;
    opacity: 0 !important;
  }

  #latestTemperature::before {
    display: none !important;
  }
}

.trend-status {
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s;
}

.trend-status::after {
  content: " — ";
}

.trend-status[hidden] {
  display: none !important;
}

.trend-status[data-direction="rising"] {
  color: #dc2f3f;
}

.trend-status[data-direction="falling"] {
  color: #2f7fc4;
}

.trend-status[data-direction="steady"] {
  color: var(--muted);
}

.latest-reading time {
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  margin-top: 4px;
}

.latest-reading-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.pressure-pill {
  min-height: 34px;
}

.pressure-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid rgba(47, 127, 196, 0.2);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pressure-pill[data-trend="up"] {
  color: #9e3a1d;
}

.pressure-pill[data-trend="down"] {
  color: #1f5f9d;
}

.pressure-pill[data-trend="stable"] {
  color: var(--muted);
}

.status-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.status-button.battery-low {
  border-color: #e5a93c;
  background: #fff4d6;
  color: #9a4d05;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.battery-alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: -6px 0 16px;
  border: 1px solid #e5a93c;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: linear-gradient(135deg, #fff4d6, #fffaf0);
  color: #7c3d05;
  box-shadow: var(--shadow-soft);
}

.battery-alert[hidden] {
  display: none;
}

.battery-alert-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.battery-alert div {
  display: grid;
  gap: 2px;
}

.battery-alert strong {
  font-size: 14px;
}

.battery-alert span:not(.battery-alert-icon) {
  font-size: 13px;
  font-weight: 650;
}

.battery-alert-button {
  min-height: 36px;
  border-color: #e5a93c;
  color: #7c3d05;
  white-space: nowrap;
}

.status-dialog {
  width: min(680px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.status-dialog::backdrop {
  background: rgba(42, 32, 48, 0.45);
  backdrop-filter: blur(2px);
}

.status-dialog-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(224, 119, 11, 0.22);
  overflow: hidden;
}

.status-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.status-dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.health-sections {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.ai-settings {
  display: grid;
  grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
  gap: 7px 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  background: linear-gradient(180deg, #fffdf7, #fbf3e4);
}

.ai-settings label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ai-settings select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

.ai-settings select:focus {
  border-color: rgba(224, 119, 11, 0.55);
  outline: 3px solid rgba(224, 119, 11, 0.18);
}

.ai-settings small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.health-section h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.health-section dl {
  display: grid;
  grid-template-columns: minmax(128px, 0.6fr) minmax(0, 1fr);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.health-section dt,
.health-section dd {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  font-size: 13px;
}

.health-section dt {
  color: var(--muted);
  font-weight: 800;
}

.health-section dd {
  font-weight: 750;
}

.health-section .health-warning {
  background: #fff4d6;
  color: #9a4d05;
}

.health-section dt:nth-last-of-type(1),
.health-section dd:nth-last-of-type(1) {
  border-bottom: 0;
}

.day-comparison {
  margin-bottom: 16px;
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

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

.comparison-head div {
  display: grid;
  gap: 4px;
}

.comparison-head span,
.comparison-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.comparison-head strong {
  font-size: 20px;
  line-height: 1.15;
}

.comparison-head small,
.comparison-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.comparison-grid article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: linear-gradient(180deg, #fffdf7, #fbf3e4);
  transition: transform 0.12s ease;
}

.comparison-grid article:hover {
  transform: translateY(-2px);
}

.comparison-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--font-rounded);
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
}

.comparison-grid .comparison-temp {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.comparison-grid .comparison-temp b {
  font: inherit;
}

.comparison-grid .comparison-temp time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.comparison-grid small {
  display: block;
  margin-top: 8px;
}

.year-extremes {
  margin-bottom: 16px;
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.year-extremes-head {
  margin-bottom: 12px;
}

.year-extremes-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.year-extremes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.year-extremes-grid article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: linear-gradient(180deg, #fffdf7, #fbf3e4);
}

.year-extremes-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.year-extremes-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--font-rounded);
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
}

.year-extremes-grid small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.year-extreme-hottest {
  border-left: 3px solid rgba(220, 47, 63, 0.5) !important;
}

.year-extreme-coldest {
  border-left: 3px solid rgba(33, 102, 172, 0.5) !important;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  min-height: 40px;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: auto 1fr;
  gap: 16px;
  align-items: start;
}

.chart-panel {
  grid-column: 1;
  grid-row: 1;
}

.milestones-panel {
  grid-column: 1;
  grid-row: 2;
}

.insights-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.chart-panel,
.milestones-panel,
.insights-panel,
.annual-panel {
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.section-head.compact {
  display: block;
}

.year-toggles label {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
}

.year-toggles input {
  min-width: 0;
  min-height: 0;
}

.compare-controls {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.compare-controls > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.chart-legend {
  min-height: 42px;
  padding: 10px 16px 0;
}

.chart-period {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 8px 16px 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #fbf3e4;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 0;
  flex-wrap: wrap;
}

.range-buttons {
  gap: 6px;
}

.period-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.previous-day-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: none;
}

.previous-day-toggle[hidden] {
  display: none;
}

.previous-day-toggle input {
  min-width: 0;
  min-height: 0;
  margin: 0;
}

.range-buttons button,
.period-nav button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease;
}

.range-buttons button:hover {
  transform: translateY(-1px);
}

.period-nav button {
  width: 38px;
  padding: 6px;
  font-size: 20px;
  line-height: 1;
}

.period-nav .period-today {
  width: auto;
  min-width: 64px;
  padding-right: 12px;
  padding-left: 12px;
  font-size: 12px;
}

.range-buttons button[aria-pressed="true"] {
  border-color: transparent;
  background: linear-gradient(135deg, #f59e0b, #e0770b);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(224, 119, 11, 0.3);
}

.period-nav button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.legend-item,
.legend-range {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.legend-range {
  color: var(--muted);
}

.legend-item-empty {
  color: var(--muted);
  opacity: 0.75;
}

.legend-swatch {
  width: 18px;
  height: 3px;
  border-radius: 999px;
}

.chart-wrap {
  position: relative;
  height: 500px;
  margin: 8px 14px 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 240, 210, 0.55), rgba(255, 255, 255, 0) 34%),
    #ffffff;
}

.chart-scroller {
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-color: #d8b483 #fbf3e4;
  scrollbar-width: thin;
}

.chart-scroller::-webkit-scrollbar {
  height: 10px;
}

.chart-scroller::-webkit-scrollbar-track {
  background: #fbf3e4;
}

.chart-scroller::-webkit-scrollbar-thumb {
  border: 2px solid #fbf3e4;
  border-radius: 999px;
  background: #d8b483;
}

#temperatureChart {
  display: block;
  min-width: 100%;
  height: 100%;
  touch-action: pan-x;
}

.axis {
  stroke: #9aa5b1;
  stroke-width: 1;
}

.grid {
  stroke: #e7edf4;
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  filter: drop-shadow(0 6px 7px rgba(224, 119, 11, 0.18));
}

.line-fill {
  opacity: 0.95;
  pointer-events: none;
}

.line.muted {
  stroke-width: 2;
  opacity: 0.6;
  filter: none;
}

.line.previous-day {
  stroke-dasharray: 7 6;
  opacity: 0.72;
}

.chart-cursor {
  pointer-events: none;
}

.cursor-line {
  stroke: #1d2430;
  stroke-dasharray: 4 5;
  stroke-opacity: 0.32;
  stroke-width: 1.3;
}

.cursor-dot {
  stroke: #ffffff;
  stroke-width: 2;
  filter: drop-shadow(0 3px 5px rgba(29, 36, 48, 0.25));
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 180px;
  max-width: min(280px, calc(100% - 20px));
  border: 1px solid rgba(29, 36, 48, 0.12);
  border-radius: 8px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 14px 34px rgba(29, 36, 48, 0.18);
  pointer-events: none;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.chart-tooltip div {
  display: grid;
  gap: 4px;
}

.chart-tooltip span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-tooltip i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.chart-tooltip b {
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.insight-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.insight {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: linear-gradient(180deg, #fffdf7, #fbf3e4);
  transition: transform 0.12s ease;
}

.insight:hover {
  transform: translateY(-2px);
}

.insight span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.insight strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-rounded);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.insight small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

/* --- Milestones & streaks --- */
.milestone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  padding: 16px;
}

.milestone {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 16px 20px;
  background: linear-gradient(180deg, #fffdf7, #fbf3e4);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.milestone::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent, var(--muted));
  border-radius: 999px;
}

.milestone:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent, var(--muted)) 45%, var(--line));
  box-shadow: 0 14px 28px rgba(224, 119, 11, 0.12);
}

.milestone-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 20px;
  line-height: 1;
  background: color-mix(in srgb, var(--accent, var(--muted)) 16%, transparent);
}

.milestone-body {
  min-width: 0;
}

.milestone-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.milestone-value {
  display: block;
  margin-top: 3px;
  font-family: var(--font-rounded);
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
  color: var(--ink);
}

.milestone-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.milestone.warm {
  --accent: var(--red);
}

.milestone.cool {
  --accent: var(--blue);
}

.milestone.green {
  --accent: var(--green);
}

.annual-panel {
  margin-top: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fbf3e4;
}

/* --- Climate almanac --- */
.stripes-panel,
.on-this-day,
.season-panel,
.calendar-panel {
  width: 100%;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
}

#warmingStripes {
  display: block;
  width: calc(100% - 32px);
  height: 56px;
  margin: 0 16px 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.onthisday-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
}

.insight.highlight {
  border-color: var(--red);
  background: linear-gradient(180deg, rgba(220, 47, 63, 0.12), rgba(220, 47, 63, 0.04));
}

.insight.highlight strong {
  color: var(--red);
}

.season-panel td:not(:first-child) {
  font-weight: 700;
  text-align: center;
}

.climatology-band {
  stroke: none;
}

.climatology-band.outer {
  fill: rgba(96, 112, 132, 0.12);
}

.climatology-band.inner {
  fill: rgba(96, 112, 132, 0.2);
}

.calendar-grid {
  display: grid;
  grid-template-columns: 34px repeat(31, minmax(14px, 1fr));
  gap: 2px;
  padding: 14px;
  overflow-x: auto;
}

.cal-month {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cal-cell {
  aspect-ratio: 1 / 1;
  min-width: 12px;
  border-radius: 5px;
  background: var(--soft);
}

.cal-missing {
  background: repeating-linear-gradient(45deg, #eef1f4, #eef1f4 2px, #f7f9fb 2px, #f7f9fb 4px);
}

.cal-empty {
  background: transparent;
}

.calendar-scale {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cal-gradient {
  display: inline-block;
  width: 120px;
  height: 10px;
  border-radius: 999px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #2a2030, #3a2a3a);
  color: #ffe9c2;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.warning {
  background: linear-gradient(135deg, #9a4d05, #7c3d05);
  color: #fff7e6;
}

@media (display-mode: standalone) {
  .topbar {
    margin-bottom: 14px;
  }

  .button,
  .pill,
  input,
  select {
    min-height: 44px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding:
      calc(16px + env(safe-area-inset-top))
      calc(16px + env(safe-area-inset-right))
      calc(18px + env(safe-area-inset-bottom))
      calc(16px + env(safe-area-inset-left));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .latest-reading {
    align-items: flex-start;
    flex-direction: column;
  }

  .trend-phrase {
    min-height: 86px;
    padding-right: 46px;
  }

  .yesterday-reading-card {
    width: 100%;
  }

  .latest-reading-meta {
    width: 100%;
  }

  .comparison-head {
    flex-direction: column;
  }

  .comparison-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .latest-reading time {
    width: fit-content;
    text-align: left;
  }

  .reading-timeline {
    width: 100%;
    justify-content: flex-start;
  }

  .workbench {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
  }

  .chart-panel,
  .milestones-panel,
  .insights-panel {
    grid-column: 1;
    grid-row: auto;
    min-width: 0;
  }

  .chart-wrap {
    height: 420px;
  }
}

@media (max-width: 600px) {
  .battery-alert {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .battery-alert-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 28px;
  }

  .status-strip {
    width: 100%;
  }

  .status-strip .button,
  .status-strip .pill {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }

  .latest-reading strong {
    font-size: 34px;
  }

  .weather-emoji {
    font-size: 38px;
  }

  .trend-phrase {
    align-items: flex-start;
    padding: 16px 42px 16px 16px;
    font-size: 18px;
    text-align: left;
  }

  .trend-phrase-inner {
    text-align: left;
  }

  .tide-schedule {
    justify-content: flex-start;
  }

  .pressure-pill {
    width: 100%;
    justify-content: center;
  }

  .status-dialog {
    width: calc(100vw - 20px);
  }

  .status-dialog-head,
  .ai-settings,
  .health-sections {
    padding: 14px;
  }

  .ai-settings {
    grid-template-columns: 1fr;
  }

  .ai-settings small {
    grid-column: 1;
  }

  .health-section dl {
    grid-template-columns: 1fr;
  }

  .health-section dt {
    border-bottom: 0;
    padding-bottom: 2px;
  }

  .health-section dd {
    padding-top: 2px;
  }

  .latest-reading,
  .day-comparison,
  .year-extremes,
  .toolbar,
  .chart-panel,
  .milestones-panel,
  .insights-panel,
  .annual-panel {
    border-radius: 7px;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .year-extremes-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar > * {
    flex: 1 1 100%;
  }

  .chart-legend,
  .chart-controls {
    padding-right: 12px;
    padding-left: 12px;
  }

  .chart-period {
    margin-right: 12px;
    margin-left: 12px;
  }

  .range-buttons {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .range-buttons::-webkit-scrollbar {
    display: none;
  }

  .range-buttons button {
    flex: 0 0 auto;
  }

  .previous-day-toggle {
    flex: 1 1 auto;
    justify-content: center;
  }

  .period-nav {
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }

  .chart-wrap {
    height: 360px;
    margin-right: 10px;
    margin-left: 10px;
  }

  .section-head {
    flex-direction: column;
  }

  .compare-controls {
    width: 100%;
    justify-items: start;
  }
}
