/* ==============================================================================
   Retkiluistelujäät - Google Material 3 (M3) Dark Ice Design System
   material_style.css - Tuotantovalmis M3-teematyylitiedosto
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&family=Roboto+Mono:wght@400;500;700&display=swap');

/* ==============================================================================
   1. M3 DESIGN TOKENS (DARK ICE SYSTEM)
   ============================================================================== */
:root {
  /* M3 Dark Ice Core Surface Tokens */
  --md-sys-color-surface: #0e1417;
  --md-sys-color-surface-dim: #090e10;
  --md-sys-color-surface-bright: #343a3e;
  --md-sys-color-surface-container-lowest: #080f12;
  --md-sys-color-surface-container-low: #131a1e;
  --md-sys-color-surface-container: #171f23;
  --md-sys-color-surface-container-high: #1c252a;
  --md-sys-color-surface-container-highest: #273036;

  /* Typography & On-Surface Tokens */
  --md-sys-color-on-surface: #deeeeb;
  --md-sys-color-on-surface-variant: #c0c8cc;
  --md-sys-color-outline: #8a9296;
  --md-sys-color-outline-variant: #40484c;

  /* Primary Palette (Jäänhohto syaaninsininen) */
  --md-sys-color-primary: #7cd0ff;
  --md-sys-color-on-primary: #00344b;
  --md-sys-color-primary-container: #004c6c;
  --md-sys-color-on-primary-container: #c8e6ff;

  /* Secondary Palette (Harmaansininen jääsumu) */
  --md-sys-color-secondary: #b5c9d5;
  --md-sys-color-on-secondary: #1f333c;
  --md-sys-color-secondary-container: #354a53;
  --md-sys-color-on-secondary-container: #d1e5f1;

  /* Tertiary Palette (Syvänsininen vesi) */
  --md-sys-color-tertiary: #86d2e1;
  --md-sys-color-on-tertiary: #00363f;
  --md-sys-color-tertiary-container: #004e5b;
  --md-sys-color-on-tertiary-container: #a3eeff;

  /* Semanttiset Jäänpaksuusvärit & Indikaattorit */
  --ice-safe: #79d799;               /* Kantava teräsjää >= 10 cm (M3 Green 80) */
  --ice-safe-container: rgba(121, 215, 153, 0.16);
  --ice-safe-on-container: #c7f8d6;
  --ice-safe-border: rgba(121, 215, 153, 0.45);

  --ice-mid: #7cd0ff;                /* Varoen luisteltava 5–10 cm (M3 Cyan 80) */
  --ice-mid-container: rgba(124, 208, 255, 0.16);
  --ice-mid-on-container: #c8e6ff;
  --ice-mid-border: rgba(124, 208, 255, 0.45);

  --ice-thin: #ffb4ab;               /* Ohut jää < 5 cm (M3 Soft Coral 80) */
  --ice-thin-container: rgba(255, 180, 171, 0.16);
  --ice-thin-on-container: #ffdad6;
  --ice-thin-border: rgba(255, 180, 171, 0.45);

  --ice-hazard: #ff5449;             /* Vaaranpaikka / virtapaikka / sula (M3 Bright Red 70) */
  --ice-hazard-container: rgba(255, 84, 73, 0.22);
  --ice-hazard-on-container: #ffffff;
  --ice-hazard-border: rgba(255, 84, 73, 0.6);

  /* M3 Shape Tokens */
  --md-shape-corner-none: 0px;
  --md-shape-corner-extra-small: 4px;
  --md-shape-corner-small: 8px;
  --md-shape-corner-medium: 12px;
  --md-shape-corner-large: 16px;
  --md-shape-corner-extra-large: 28px;
  --md-shape-corner-full: 9999px;

  /* Glassmorphism & Elevation */
  --glass-bg: rgba(23, 31, 35, 0.88);
  --glass-bg-high: rgba(28, 37, 42, 0.92);
  --glass-bg-low: rgba(14, 20, 23, 0.82);
  --glass-border: 1px solid rgba(124, 208, 255, 0.25);
  --glass-border-subtle: 1px solid rgba(255, 255, 255, 0.08);
  --glass-blur: blur(14px);
  --glass-blur-sm: blur(8px);

  /* M3 State Layer Opacities */
  --md-sys-state-hover-opacity: 0.08;
  --md-sys-state-focus-opacity: 0.12;
  --md-sys-state-pressed-opacity: 0.12;
  --md-sys-state-dragged-opacity: 0.16;

  /* M3 Tonal Elevations */
  --md-elevation-1: 0 1px 3px 1px rgba(0,0,0,0.35), 0 1px 2px 0 rgba(0,0,0,0.25);
  --md-elevation-2: 0 2px 6px 2px rgba(0,0,0,0.4), 0 1px 2px 0 rgba(0,0,0,0.3);
  --md-elevation-3: 0 4px 14px 3px rgba(0,0,0,0.45), 0 1px 3px 0 rgba(0,0,0,0.3);
  --md-elevation-4: 0 6px 20px 4px rgba(0,0,0,0.52), 0 2px 4px 0 rgba(0,0,0,0.35);
  --md-sys-elevation-level0: none;
  --md-sys-elevation-level1: var(--md-elevation-1);
  --md-sys-elevation-level2: var(--md-elevation-2);
  --md-sys-elevation-level3: var(--md-elevation-3);
  --md-sys-elevation-level4: var(--md-elevation-4);
  --md-sys-elevation-level5: 0 8px 24px 6px rgba(0,0,0,0.5), 0 4px 8px 0 rgba(0,0,0,0.35);

  /* M3 Motion & Transitions */
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0.0, 0, 1.0);
  --md-sys-motion-easing-emphasized: cubic-bezier(0.05, 0.7, 0.1, 1.0);
  --md-sys-motion-duration-short: 150ms;
  --md-sys-motion-duration-medium: 250ms;
  --md-sys-motion-duration-long: 350ms;

  /* Safe Area & Layout */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --m3-nav-height: 80px;
  --font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: 'Roboto Mono', monospace;
}

/* ==============================================================================
   2. GLOBAL RESET & BASE RULES
   ============================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Kosketusalueiden perussääntö (vähintään 48x48px esteettömyysstandardi) */
button, input, select, a, [role="button"] {
  font-family: inherit;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* ==============================================================================
   3. NÄKYMÄT JA PERUSRUNKO (.m3-view, #viewMap, #map)
   ============================================================================== */
.m3-view {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--m3-nav-height));
  height: calc(100dvh - var(--m3-nav-height));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--md-sys-color-surface);
}

#viewMap,
.m3-view-map {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--m3-nav-height));
  height: calc(100dvh - var(--m3-nav-height));
  overflow: hidden;
  background-color: var(--md-sys-color-surface-dim);
}

.m3-view-scroll-content {
  padding: 16px 16px calc(var(--m3-nav-height) + 36px) 16px;
  max-width: 920px;
  margin: 0 auto;
  min-height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: #0b1114;
}

/* Leaflet Karttapohjan Dark Ice -mukautukset */
.leaflet-container {
  background: #0b1114 !important;
  font-family: var(--font-family) !important;
}

.leaflet-bar {
  border: var(--glass-border) !important;
  border-radius: var(--md-shape-corner-medium) !important;
  overflow: hidden;
  box-shadow: var(--md-elevation-2) !important;
  background: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.leaflet-bar a {
  background-color: transparent !important;
  color: var(--md-sys-color-primary) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  width: 44px !important;
  height: 44px !important;
  line-height: 44px !important;
  font-size: 18px !important;
  transition: background-color var(--md-sys-motion-duration-short) ease;
}

.leaflet-bar a:hover {
  background-color: var(--md-sys-color-surface-container-high) !important;
  color: #fff !important;
}

/* Leaflet Popupit M3 Dark Ice -lasikorttina */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg-high) !important;
  backdrop-filter: var(--glass-blur) !important;
  -webkit-backdrop-filter: var(--glass-blur) !important;
  border: var(--glass-border) !important;
  border-radius: var(--md-shape-corner-large) !important;
  color: var(--md-sys-color-on-surface) !important;
  box-shadow: var(--md-elevation-3) !important;
  padding: 4px;
}

.leaflet-popup-tip {
  background: var(--md-sys-color-surface-container-high) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}

/* ==============================================================================
   4. KELLUVAT LÄPIKUULTAVAT LASIMAISET KOMPONENTIT
   ============================================================================== */

/* 4.0 KARTTAKERROKSET - PÄÄLLEKKÄISYYDEN ESTÄVÄT FLEX-PINOT */
.m3-map-top-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.m3-map-bottom-overlay {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 520px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

/* 4.1 TOP FLOATING SEARCH BAR (.m3-search-bar) */
.m3-search-bar {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 56px;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-shape-corner-extra-large);
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: var(--md-sys-elevation-level3);
  pointer-events: auto;
  transition: border-color var(--md-sys-motion-duration-medium) ease,
              box-shadow var(--md-sys-motion-duration-medium) ease,
              background-color var(--md-sys-motion-duration-medium) ease;
}

.m3-search-bar:focus-within {
  border-color: var(--md-sys-color-primary);
  background: rgba(23, 31, 35, 0.96);
  box-shadow: var(--md-sys-elevation-level4), 0 0 12px rgba(124, 208, 255, 0.25);
}

.m3-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--md-sys-color-primary);
  margin-right: 12px;
  flex-shrink: 0;
  user-select: none;
}

.m3-search-input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.1px;
}

.m3-search-input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.8;
}

.m3-search-clear,
.m3-search-layers {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 18px;
  border-radius: 50%;
  cursor: pointer;
  margin-right: -4px;
  position: relative;
  transition: color var(--md-sys-motion-duration-short) ease,
              background-color var(--md-sys-motion-duration-short) ease;
}

.m3-search-clear:hover,
.m3-search-layers:hover {
  color: #fff;
  background: rgba(255, 255, 255, var(--md-sys-state-hover-opacity));
}

.m3-search-clear:active,
.m3-search-layers:active {
  background: rgba(255, 255, 255, var(--md-sys-state-pressed-opacity));
}

/* Hakutulosten kelluva pudotusvalikko */
.m3-search-dropdown,
.m3-autocomplete-results {
  position: absolute;
  top: 62px;
  left: 0;
  right: 0;
  max-height: 380px;
  overflow-y: auto;
  background: rgba(20, 27, 31, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(124, 208, 255, 0.22);
  border-radius: var(--md-shape-corner-large);
  box-shadow: var(--md-sys-elevation-level4);
  padding: 6px;
  display: none;
  z-index: 1005;
}

.m3-search-dropdown.active,
.m3-autocomplete-results.active {
  display: block;
  animation: m3FadeDown 0.2s var(--md-sys-motion-easing-emphasized);
}

.m3-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  min-height: 48px;
  border-radius: var(--md-shape-corner-medium);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) ease;
}

.m3-search-item:hover,
.m3-search-item:focus {
  background: rgba(124, 208, 255, 0.12);
  color: #fff;
}

/* 4.2 TOIMINTOPALKKI (.m3-map-action-bar: Tyhjennä ja Laske) */
.m3-map-action-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: auto;
  user-select: none;
  margin-top: 2px;
  animation: m3FadeDown 0.2s var(--md-sys-motion-easing-emphasized);
}

/* Kompakti Tyhjennä-nollauspainike */
.m3-btn-compact-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  background: var(--glass-bg-high);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.2px;
  box-shadow: var(--md-sys-elevation-level2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.m3-btn-compact-clear:hover {
  background: rgba(30, 41, 48, 0.95);
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-level3);
  transform: translateY(-1px);
}

.m3-btn-compact-clear:active {
  transform: scale(0.97);
}

.m3-btn-compact-clear .material-symbols-outlined {
  font-size: 18px;
  color: var(--md-sys-color-primary);
}

/* Kompakti Laske-painike chip-rivin oikeassa reunassa */
.m3-btn-compact-analyze {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.2px;
  border: none;
  box-shadow: var(--md-sys-elevation-level2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.m3-btn-compact-analyze:hover {
  background: #005a80;
  box-shadow: var(--md-sys-elevation-level3);
  transform: translateY(-1px);
}

.m3-btn-compact-analyze:active {
  transform: scale(0.97);
}

.m3-btn-compact-analyze:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.m3-btn-compact-analyze .material-symbols-outlined {
  font-size: 18px;
}

/* Yksittäinen M3 Input Chip */
.m3-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 32px;
  min-height: 32px;
  border-radius: var(--md-shape-corner-small);
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  backdrop-filter: var(--glass-blur-sm);
  -webkit-backdrop-filter: var(--glass-blur-sm);
  box-shadow: var(--md-sys-elevation-level1);
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
  flex-shrink: 0;
}

.m3-chip:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-level2);
}

.m3-chip:active {
  transform: scale(0.98);
}

.m3-chip.active,
.m3-chip.selected {
  background: var(--md-sys-color-primary-container);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: 0 0 10px rgba(124, 208, 255, 0.25);
}

.m3-chip-icon {
  font-size: 16px;
  line-height: 1;
}

.m3-chip-close,
.m3-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: none;
  cursor: pointer;
  margin-left: 2px;
  font-size: 14px;
  transition: background-color var(--md-sys-motion-duration-short) ease, color var(--md-sys-motion-duration-short) ease;
}

/* Esteetön 48x48px kosketusalue sulkunapille */
.m3-chip-close::before,
.m3-chip-remove::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
}

.m3-chip-close:hover,
.m3-chip-remove:hover {
  background: rgba(255, 84, 73, 0.2);
  color: var(--ice-hazard);
}

/* 4.3 EXTENDED FLOATING ACTION BUTTON (.m3-fab-extended & .m3-fab) */
.m3-fab-extended,
.m3-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 56px;
  min-height: 56px;
  padding: 0 20px;
  border-radius: var(--md-shape-corner-large);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.1px;
  border: 1px solid rgba(124, 208, 255, 0.35);
  box-shadow: var(--md-sys-elevation-level3);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  transition: transform var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              background-color var(--md-sys-motion-duration-short) ease;
}

.m3-fab-extended:hover,
.m3-fab:hover {
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-level4);
  background: #005a80;
  color: #ffffff;
}

.m3-fab-extended:active,
.m3-fab:active {
  transform: scale(0.98);
  box-shadow: var(--md-sys-elevation-level2);
}

.m3-fab-extended .material-symbols-outlined,
.m3-fab .material-symbols-outlined {
  font-size: 24px;
}

.m3-fab-extended.loading .material-symbols-outlined,
.m3-fab.loading .material-symbols-outlined,
.m3-calc-spinner {
  animation: m3Spin 1.2s linear infinite;
}

/* 4.4 KELLUVA AIKAJANAPALKKI (.m3-time-pill - M3 Docked Floating Pill) */
.m3-time-pill {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 52px;
  z-index: 1000;
  pointer-events: auto;
  background: var(--glass-bg-high);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-shape-corner-extra-large);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  box-shadow: var(--md-sys-elevation-level3);
  user-select: none;
  transition: border-color var(--md-sys-motion-duration-short) ease,
              box-shadow var(--md-sys-motion-duration-short) ease;
}

.m3-time-pill:hover {
  border-color: rgba(124, 208, 255, 0.45);
  box-shadow: var(--md-sys-elevation-level4);
}

/* Toisto- ja siirtymänapit aikajanalla */
.m3-time-play,
.m3-play-btn,
.m3-time-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--md-sys-color-primary);
  border: none;
  font-size: 20px;
  cursor: pointer;
  position: relative;
  transition: transform var(--md-sys-motion-duration-short) ease,
              background-color var(--md-sys-motion-duration-short) ease;
  flex-shrink: 0;
}

.m3-time-play::before,
.m3-play-btn::before,
.m3-time-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
}

.m3-time-play,
.m3-play-btn {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-level1);
}

.m3-time-play:hover,
.m3-play-btn:hover {
  transform: scale(1.08);
  background: #a0e0ff;
}

.m3-time-btn:hover {
  background: rgba(124, 208, 255, var(--md-sys-state-hover-opacity));
  color: #fff;
}

.m3-time-play:active,
.m3-play-btn:active,
.m3-time-btn:active {
  transform: scale(0.92);
}

/* M3 Liukusäädin (.m3-slider) */
.m3-slider-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  min-height: 48px;
}

.m3-slider,
input[type="range"].m3-slider {
  width: 100%;
  flex: 1;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
  transition: background 0.2s ease;
}

.m3-slider:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 4px;
}

/* Liukusäätimen Webkit Thumb */
.m3-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.m3-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #b5e8ff;
  box-shadow: 0 0 0 10px rgba(124, 208, 255, 0.18);
}

/* Liukusäätimen Firefox Thumb */
.m3-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--md-sys-color-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.m3-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  background: #b5e8ff;
  box-shadow: 0 0 0 10px rgba(124, 208, 255, 0.18);
}

/* Päiväbadge ja jäänpaksuusinfo aikajanalla */
.m3-time-badge,
.m3-day-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(124, 208, 255, 0.16);
  color: var(--md-sys-color-primary);
  white-space: nowrap;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

.m3-time-ice-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 4.5 NON-BLOCKING TOAST-PILLERI (.m3-info-pill) */
.m3-info-pill {
  position: relative;
  z-index: 1000;
  background: rgba(14, 20, 23, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--md-sys-color-primary);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
              transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
  animation: m3ToastPop 0.3s var(--md-sys-motion-easing-emphasized);
}

.m3-info-pill.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Kelluva taustalaskennan tilapalkki */
.m3-calc-banner {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 998;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  background: var(--glass-bg-high);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(124, 208, 255, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--md-elevation-2);
}

/* 4.6 KELLUVA KARTTASELITE (.m3-map-legend - M3 Glass Legend Pill) */
.m3-map-legend {
  position: relative;
  z-index: 999;
  background: var(--glass-bg-high);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-shape-corner-large);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 14px;
  box-shadow: var(--md-sys-elevation-level2);
  user-select: none;
  max-width: calc(100% - 24px);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.m3-map-legend::-webkit-scrollbar {
  display: none;
}

.m3-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.m3-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.m3-swatch-open {
  background: transparent;
}

.m3-swatch-thin {
  background: #38bdf8;
  border-color: #7dd3fc;
}

.m3-swatch-steel {
  background: #2563eb;
  border-color: #60a5fa;
}

.m3-swatch-safe {
  background: #10b981;
  border-color: #34d399;
}

.m3-swatch-hazard {
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M 0,4.5 Q 3.5,1.5 7,4.5 T 14,4.5' fill='none' stroke='%23ff5449' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: repeat;
  border-color: rgba(255, 84, 73, 0.5);
}

/* ==============================================================================
   5. M3 BOTTOM NAVIGATION BAR (.m3-bottom-nav & .m3-nav-bar)
   ============================================================================== */
.m3-bottom-nav,
.m3-nav-bar {
  height: 80px;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--md-sys-color-surface-container);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1100;
  padding-bottom: var(--safe-bottom);
  user-select: none;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}

.m3-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--md-sys-color-secondary);
  cursor: pointer;
  padding: 8px 0;
  min-height: 48px;
  min-width: 48px;
  position: relative;
  text-decoration: none;
  transition: color var(--md-sys-motion-duration-short) ease;
}

.m3-nav-item:focus-visible {
  outline: none;
}

.m3-nav-item:focus-visible .m3-nav-indicator {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.m3-nav-item:hover {
  color: var(--md-sys-color-on-surface);
}

.m3-nav-item.active {
  color: var(--md-sys-color-primary);
}

/* Aktiivisen tabin soikiomainen pilleri-indikaattori (M3: 64x32px) */
.m3-nav-indicator {
  width: 64px;
  height: 32px;
  border-radius: 16px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
              width var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.m3-nav-item.active .m3-nav-indicator {
  background: rgba(124, 208, 255, 0.22);
  color: var(--md-sys-color-primary);
}

.m3-nav-item.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1;
}

.m3-nav-icon {
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m3-nav-label {
  font-size: 12px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.2px;
  transition: font-weight 0.15s ease;
}

.m3-nav-item.active .m3-nav-label {
  font-weight: 700;
}

/* ==============================================================================
   6. RAPORTIT & KORTIT -NÄKYMÄN TYYLIT (.m3-reports-container jne.)
   ============================================================================== */
.m3-reports-container {
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
  height: calc(100vh - 80px);
  height: calc(100dvh - 80px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* M3 Kortti (.m3-card) */
.m3-card {
  background: var(--md-sys-color-surface-container);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: border-color var(--md-sys-motion-duration-medium) ease,
              box-shadow var(--md-sys-motion-duration-medium) ease,
              transform var(--md-sys-motion-duration-medium) ease;
}

.m3-card:hover {
  border-color: rgba(124, 208, 255, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.38);
}

.m3-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.m3-card-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.1px;
}

.m3-card-subtitle {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
}

.m3-card-body {
  font-size: 14px;
  line-height: 1.5;
  color: #dde5e9;
}

.m3-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* 6.1 SEGMENTOITU ALLASTABIPURSOTUS (.m3-segmented-tabs) */
.m3-segmented-tabs-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  padding-bottom: 4px;
}

.m3-segmented-tabs {
  display: inline-flex;
  min-width: 100%;
  background: var(--md-sys-color-surface-container-high);
  border-radius: 24px;
  padding: 4px;
  gap: 6px;
  border: 1px solid rgba(124, 208, 255, 0.2);
  user-select: none;
}

.m3-tab-item,
.m3-tab-btn,
.m3-segmented-btn {
  flex: 1 0 auto;
  min-height: 44px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.m3-tab-item:hover,
.m3-tab-btn:hover,
.m3-segmented-btn:hover {
  color: #fff;
  background: rgba(124, 208, 255, 0.08);
}

.m3-tab-item.active,
.m3-tab-btn.active,
.m3-segmented-btn.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  font-weight: 700;
}

/* 6.1b KOLMITASOINEN RAPORTTISUODATUS (.m3-report-filters-card) */
.m3-report-filters-card {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.m3-filter-level {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m3-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--md-sys-color-on-surface-variant);
  user-select: none;
}

.m3-filter-label .filter-icon {
  font-size: 15px;
  color: var(--md-sys-color-primary);
}

.m3-filter-chips-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 6px 0;
  scrollbar-width: thin;
}

.m3-filter-chips-row::-webkit-scrollbar {
  height: 4px;
}

.m3-filter-chips-row::-webkit-scrollbar-thumb {
  background: rgba(124, 208, 255, 0.2);
  border-radius: 4px;
}

.m3-filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.m3-filter-chip:hover {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-primary);
}

.m3-filter-chip:active {
  transform: scale(0.97);
}

.m3-filter-chip.active {
  background: var(--md-sys-color-primary-container);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.m3-filter-chip .chip-count {
  font-size: 11px;
  opacity: 0.75;
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: 8px;
}

.m3-filter-chip.active .chip-count {
  background: rgba(0, 0, 0, 0.15);
}

/* 6.2 AKTIIVISEN LASKETUN ALTAAN OTSIKKOKORTTI (.m3-active-basin-card) */
.m3-active-basin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(23, 31, 35, 0.95), rgba(0, 76, 108, 0.35));
  border: 1px solid rgba(124, 208, 255, 0.3);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.m3-active-basin-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.m3-active-basin-icon {
  font-size: 32px;
  color: var(--md-sys-color-primary);
  background: rgba(124, 208, 255, 0.12);
  padding: 10px;
  border-radius: 16px;
}

.m3-active-basin-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  letter-spacing: 0.2px;
}

.m3-active-basin-subtitle {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  margin: 2px 0 0 0;
}

.m3-active-basin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 6.3 KPI-TILASTOLAATIKOT (.m3-kpi-grid & .m3-kpi-card) */
.m3-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.m3-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.m3-kpi-card:hover {
  border-color: rgba(124, 208, 255, 0.3);
  transform: translateY(-2px);
}

.m3-kpi-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.m3-kpi-icon {
  font-size: 24px;
}

.m3-kpi-icon.color-temp {
  color: #f97316;
}

.m3-kpi-icon.color-ice {
  color: #7cd0ff;
}

.m3-kpi-icon.color-condition {
  color: #79d799;
}

.m3-display-small {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #ffffff;
  letter-spacing: 0.2px;
}

/* 6.4 TILANNEKORTIT JA KUVAT (.m3-image-card) */
.m3-image-card {
  background: var(--md-sys-color-surface-container);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.m3-card-media-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(14, 20, 23, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m3-card-media {
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  display: block;
}

.m3-media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px 16px;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  font-size: 13px;
}

.m3-media-placeholder .placeholder-icon {
  font-size: 44px;
  color: var(--md-sys-color-primary);
  opacity: 0.6;
}

/* 6.5 SKELETON LOADING SHIMMER (.m3-skeleton) */
.m3-skeleton {
  background: linear-gradient(
    90deg,
    var(--md-sys-color-surface-container-high) 25%,
    var(--md-sys-color-surface-container-highest) 37%,
    var(--md-sys-color-surface-container-high) 63%
  );
  background-size: 400% 100%;
  animation: m3Shimmer 1.5s ease infinite;
  border-radius: var(--md-shape-corner-small);
}

@keyframes m3Shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* 6.6 ENNUSTETAULUKKO (.m3-table-card, .m3-data-table) */
.m3-table-card {
  background: var(--md-sys-color-surface-container);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.m3-table-responsive-container,
.m3-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.m3-data-table,
.m3-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.m3-data-table th,
.m3-table th {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-primary);
  padding: 10px 10px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  font-size: 12px;
}

.m3-data-table td,
.m3-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #e1e7ea;
  white-space: nowrap;
}

.m3-data-table tr:hover td,
.m3-table tr:hover td {
  background: rgba(124, 208, 255, 0.06);
}

/* Semanttiset jäämerkit taulukossa ja korteissa */
.m3-ice-badge,
.m3-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--md-shape-corner-small);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.1px;
  white-space: nowrap;
}

.m3-ice-badge.safe,
.m3-badge-safe {
  background: var(--ice-safe-container);
  color: var(--ice-safe);
  border: 1px solid var(--ice-safe-border);
}

.m3-ice-badge.mid,
.m3-badge-mid {
  background: var(--ice-mid-container);
  color: var(--ice-mid);
  border: 1px solid var(--ice-mid-border);
}

.m3-ice-badge.thin,
.m3-badge-thin {
  background: var(--ice-thin-container);
  color: var(--ice-thin);
  border: 1px solid var(--ice-thin-border);
}

.m3-ice-badge.hazard,
.m3-badge-hazard {
  background: var(--ice-hazard-container);
  color: var(--ice-hazard);
  border: 1px solid var(--ice-hazard-border);
}

/* Luisteltavuuden tähtiluokitus ennustetaulukossa */
.m3-table-stars {
  color: #facc15;
  font-size: 13px;
  letter-spacing: 1.2px;
  white-space: nowrap;
  font-weight: 600;
}

/* Kaksiriviset ennustetaulukon solut (PNG-vastaavuus) */
.m3-cell-2row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.25;
}

.m3-cell-primary {
  font-weight: 600;
  font-size: 13px;
  color: #ffffff;
  white-space: nowrap;
}

.m3-cell-sub {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 400;
  margin-top: 2px;
  white-space: nowrap;
}

.m3-temp-freeze {
  color: #60a5fa;
}

.m3-temp-thaw {
  color: #f87171;
}

.m3-bearing-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.m3-bearing-dot.safe { background-color: #10b981; }
.m3-bearing-dot.warning { background-color: #facc15; }
.m3-bearing-dot.danger { background-color: #ef4444; }
.m3-bearing-dot.open { background-color: #94a3b8; }

/* 6.6 TOIMINTOPAINIKKEET JA LIGHTBOX (.m3-action-buttons-row, .m3-lightbox-modal) */
.m3-action-buttons-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  margin-bottom: 24px;
}

.m3-btn-filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.m3-btn-filled:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(124, 208, 255, 0.3);
}

.m3-btn-outlined {
  background: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-primary);
  border-radius: 20px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
}

.m3-btn-outlined:hover {
  background: rgba(124, 208, 255, 0.1);
}

.m3-lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.m3-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.m3-lightbox-dialog-card {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 90vh;
  background: var(--md-sys-color-surface-container);
  border: 1px solid rgba(124, 208, 255, 0.25);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

.m3-lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--md-sys-color-surface-container-high);
}

.m3-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.m3-lightbox-body {
  padding: 12px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.m3-lightbox-image {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
}

/* WAVY HAZARD PATTERN OVERLAY FOR LEAFLET POLYGONS (BORDERLESS PNG STYLE) */
.hazard-wave-overlay {
  fill: url(#hazardWavePattern) !important;
  stroke: none !important;
  stroke-width: 0 !important;
  pointer-events: auto;
  cursor: pointer;
}

/* ==============================================================================
   7. MOBIILIKÄYTETTÄVYYS & ESTEETTÖMYYS (MIN 48PX KOSKETUSALUEET)
   ============================================================================== */
.m3-touch-target,
.m3-btn-icon,
.m3-icon-btn {
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  border-radius: 50%;
  transition: background-color 0.15s ease;
}

.m3-touch-target:hover,
.m3-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Painikkeiden tyylitelty perusluokka */
.m3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1px;
  border: none;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short) ease;
}

.m3-btn-primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.m3-btn-primary:hover {
  background: #a0e0ff;
  box-shadow: 0 4px 12px rgba(124, 208, 255, 0.3);
}

.m3-btn-tonal {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.m3-btn-tonal:hover {
  background: #415863;
}

.m3-btn-outlined {
  background: transparent;
  border: 1px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-primary);
}

.m3-btn-outlined:hover {
  background: rgba(124, 208, 255, 0.08);
  border-color: var(--md-sys-color-primary);
}

/* ==============================================================================
   8. ANIMAATIOT & SIIRTYMÄT
   ============================================================================== */
@keyframes m3FadeDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes m3ToastPop {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

/* ==============================================================================
   9. RESPONSIIVISUUS (KÄNNYKÄT & TABLETIT)
   ============================================================================== */
@media (max-width: 600px) {
  .m3-map-top-overlay {
    top: 8px;
    width: calc(100% - 16px);
  }

  .m3-map-bottom-overlay {
    bottom: 12px;
    width: calc(100% - 16px);
  }

  .m3-search-bar {
    height: 48px;
    padding: 0 12px;
  }

  .m3-time-pill {
    height: 46px;
    padding: 0 10px;
    gap: 6px;
  }

  .m3-info-pill {
    font-size: 11px;
    padding: 5px 12px;
  }

  .m3-bottom-nav,
  .m3-nav-bar {
    height: 72px;
  }

  .m3-reports-container {
    padding: 12px 10px;
    height: calc(100vh - 72px);
    height: calc(100dvh - 72px);
  }

  .m3-view-scroll-content {
    padding: 12px 10px calc(var(--m3-nav-height) + 24px) 10px;
  }

  .m3-card {
    padding: 14px;
    margin-bottom: 12px;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  .m3-map-top-overlay,
  .m3-map-bottom-overlay {
    max-width: 580px;
  }

  .m3-reports-container {
    max-width: 720px;
  }
}

@media (min-width: 1025px) {
  .m3-map-top-overlay {
    top: 16px;
    max-width: 620px;
  }

  .m3-map-bottom-overlay {
    bottom: 24px;
    max-width: 580px;
  }

  .m3-reports-container {
    max-width: 860px;
    padding: 24px;
  }
}

/* ==============================================================================
   10. TOAST-ILMOITUKSET, ANIMAATIOT JA ERIKOISKOMPONENTIT
   ============================================================================== */
.m3-toast-container {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}

.m3-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(23, 31, 35, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(124, 208, 255, 0.25);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: m3ToastPop 0.25s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.m3-toast.fade-out {
  opacity: 0;
  transform: translateY(10px);
}

.m3-toast.success {
  border-color: #79d799;
}

.m3-toast.success .m3-toast-icon {
  color: #79d799;
}

.m3-toast.warning {
  border-color: #ffb4ab;
}

.m3-toast.warning .m3-toast-icon {
  color: #ffb4ab;
}

.m3-toast.danger {
  border-color: #ff5449;
}

.m3-toast.danger .m3-toast-icon {
  color: #ff5449;
}

.m3-toast.info .m3-toast-icon {
  color: #7cd0ff;
}

.m3-toast-icon {
  font-size: 20px;
}

.m3-toast-text {
  flex: 1;
}

.m3-toast-action {
  background: transparent;
  border: none;
  color: var(--md-sys-color-primary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.m3-toast-action:hover {
  background: rgba(124, 208, 255, 0.15);
}

.m3-toast-close {
  background: transparent;
  border: none;
  color: var(--md-sys-color-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.m3-toast-close::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
}

.m3-toast-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Kartan laskentaindikaattori */
.m3-calc-indicator {
  background: transparent !important;
  border: none !important;
}

.m3-calc-marker-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 20, 23, 0.92);
  border: 1px solid var(--md-sys-color-primary);
  border-radius: 20px;
  padding: 6px 14px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.m3-calc-marker-inner.queued {
  background: rgba(14, 20, 23, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #cbd5e1;
}

.m3-calc-spinner {
  color: var(--md-sys-color-primary);
  font-size: 18px;
  animation: m3Spin 2s linear infinite;
}

.m3-calc-static {
  color: #94a3b8;
  font-size: 18px;
  animation: none;
}

@keyframes m3Spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.m3-badge-ice {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: rgba(124, 208, 255, 0.16);
  color: var(--md-sys-color-primary);
}

.m3-favorite-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.m3-favorite-card .m3-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* --- Linear Progress Indicator --- */
.m3-linear-progress {
  position: absolute;
  top: 116px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 520px;
  height: 4px;
  background: rgba(124, 208, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  z-index: 1000;
}

.m3-linear-progress-indicator.indeterminate {
  width: 100%;
  height: 100%;
  background: var(--md-sys-color-primary, #7cd0ff);
  animation: m3ProgressIndeterminate 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  transform-origin: 0% 50%;
}

@keyframes m3ProgressIndeterminate {
  0% { transform: translateX(-100%) scaleX(0.2); }
  50% { transform: translateX(0%) scaleX(0.7); }
  100% { transform: translateX(100%) scaleX(0.2); }
}

/* --- WCAG 2.1 AA Touch Target (min 48x48px) & Icon Button Accessibility --- */
.m3-touch-target {
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.m3-icon-btn {
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short) ease, color var(--md-sys-motion-duration-short) ease;
}

.m3-icon-btn:hover {
  background: rgba(124, 208, 255, 0.12);
  color: #ffffff;
}

.m3-chip-close.m3-touch-target {
  min-width: 48px;
  min-height: 48px;
}

/* --- M3 Status & Condition Badges --- */
.m3-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.m3-badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.m3-badge-chip .chip-icon {
  font-size: 18px;
}

.m3-chip-skating {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
}

.m3-chip-temp {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.m3-chip-snow {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(148, 163, 184, 0.4);
  color: #cbd5e1;
}

.m3-chip-hazards {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

/* ==============================================================================
   7. KAUSITILASTOT & KAUSIKARTTATILA (.m3-season-banner, #viewStats)
   ============================================================================== */

/* Kelluva Kausitilan banneri kartalla */
.m3-season-banner {
  width: 100%;
  max-width: 520px;
  background: rgba(14, 20, 23, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(124, 208, 255, 0.35);
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  gap: 12px;
  pointer-events: auto;
  user-select: none;
  animation: m3FadeDown 0.25s var(--md-sys-motion-easing-emphasized);
}

.m3-season-banner-leading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.m3-season-banner-icon {
  font-size: 24px;
  color: var(--md-sys-color-primary);
}

.m3-season-banner-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m3-season-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.1px;
}

.m3-season-banner-subtitle {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m3-season-banner-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.m3-season-badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}

.m3-season-badge-chip .material-symbols-outlined {
  font-size: 14px;
}

.m3-season-badge-chip.temp-freeze {
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.3);
}

.m3-season-badge-chip.temp-thaw {
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.3);
}

.m3-star-badge-marker {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.8));
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
  background: transparent;
  border: none;
}

.m3-star-badge-marker:hover {
  transform: scale(1.2);
}

.m3-season-banner-trailing {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* Tilastot-näkymän korttiruudukko ja järvikortti */
.m3-season-lakes-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.m3-season-card {
  background: var(--md-sys-color-surface-container);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.m3-season-card:hover {
  border-color: rgba(124, 208, 255, 0.3);
}

.m3-season-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.m3-season-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.m3-season-card-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.m3-season-card-meta {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Kausitilastojen KPI-ruudukko kortin sisällä */
.m3-season-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.m3-season-kpi-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.m3-season-kpi-label {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.m3-season-kpi-label .material-symbols-outlined {
  font-size: 14px;
  color: var(--md-sys-color-primary);
}

.m3-season-kpi-value {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #ffffff;
}

.m3-season-kpi-sub {
  font-size: 11px;
  color: var(--md-sys-color-outline);
}

.m3-season-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Mobiilisovitus alapalkille 4 tabin kanssa */
@media (max-width: 400px) {
  .m3-nav-indicator {
    width: 52px;
    height: 28px;
  }
  .m3-nav-label {
    font-size: 11px;
  }
  .m3-season-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

