/* =========================================================
   LuFi Meteo - Czysty Glassmorphism z Atmosferycznym Tłem
   ========================================================= */
:root {
  --bgTop: #080e1a;
  --bgBot: #0b1220;

  --glow1: rgba(88, 176, 227, 0.14);
  --glow2: rgba(240, 168, 93, 0.10);
  --glow3: rgba(142, 120, 255, 0.10);

  --card: rgba(255, 255, 255, 0.035);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke2: rgba(255, 255, 255, 0.14);

  --txt: rgba(255, 255, 255, 0.94);
  --muted: rgba(255, 255, 255, 0.70);
  --muted2: rgba(255, 255, 255, 0.50);

  --accent: #58b0e3;
  --accent2: #f0a85d;
  
  --online: #42c27d;
  --warn: #f0a85d;
  --alarm: #df4848;

  --shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
  --r: 20px;
  --gap: 16px;
  --blur: blur(16px);

  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  --fx-rain-op: 0; --fx-rain-speed: 1;
  --fx-snow-op: 0; --fx-snow-speed: 1;
  --fx-fog-op: 0;  --fx-storm-op: 0;
}

html[data-theme="clear-day"] {
  --bgTop: #3a82f7; --bgBot: #1d54b8; 
  --glow1: rgba(255, 210, 80, 0.4); --glow2: rgba(255, 255, 255, 0.2); --glow3: rgba(130, 200, 255, 0.3);
  --card: rgba(0, 15, 40, 0.18); --stroke: rgba(255, 255, 255, 0.25); --stroke2: rgba(255, 255, 255, 0.4);
  --accent: #5ce1e6; --accent2: #ffe066; --muted: rgba(255, 255, 255, 0.85); 
}

html[data-theme="cloudy-day"] {
  --bgTop: #5c7b9c; --bgBot: #2a4158;
  --glow1: rgba(200, 220, 240, 0.25); --glow2: rgba(255, 255, 255, 0.15); --glow3: rgba(130, 170, 210, 0.2);
  --card: rgba(0, 15, 40, 0.15); --stroke: rgba(255, 255, 255, 0.2); --stroke2: rgba(255, 255, 255, 0.3);
  --accent: #86cbf2; --accent2: #f5cc7f; --muted: rgba(255, 255, 255, 0.85);
}

html[data-theme="rain-day"], html[data-theme="thunder-day"] {
  --bgTop: #2c4a6b; --bgBot: #122538;
  --glow1: rgba(90, 160, 230, 0.28); --glow2: rgba(120, 180, 220, 0.18);
  --card: rgba(0, 10, 25, 0.2); --stroke: rgba(255, 255, 255, 0.15);
  --accent: #63bceb; --accent2: #84bae3;
}

html[data-theme="snow-day"], html[data-theme="fog-day"] {
  --bgTop: #5a7d9e; --bgBot: #264460;
  --glow1: rgba(200, 230, 255, 0.30); --card: rgba(0, 15, 40, 0.15);
  --stroke: rgba(255, 255, 255, 0.2); --accent: #7dd3f8; --accent2: #bfeaff;
}

html[data-theme="clear-night"], html[data-theme="cloudy-night"],
html[data-theme="rain-night"], html[data-theme="thunder-night"],
html[data-theme="snow-night"], html[data-theme="fog-night"] {
  --bgTop: #080e1a; --bgBot: #0b1220;
  --glow1: rgba(142, 120, 255, 0.15); --glow2: rgba(88, 176, 227, 0.10); --glow3: rgba(100, 80, 200, 0.12);
  --card: rgba(255, 255, 255, 0.035); --stroke: rgba(255, 255, 255, 0.08); --stroke2: rgba(255, 255, 255, 0.14);
  --accent: #a38ff5; --accent2: #63bceb;
}

html[data-theme="rain-night"], html[data-theme="thunder-night"] {
  --glow1: rgba(60, 130, 210, 0.22); --accent: #58b0e3; --accent2: #84bae3;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--bgBot); }
body {
  font-family: var(--font); color: var(--txt); background: transparent;
  overflow-x: hidden; min-height: 100vh;
}

.app-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 20% 10%, var(--glow1), transparent 65%),
    radial-gradient(900px 600px at 80% 25%, var(--glow2), transparent 60%),
    radial-gradient(1000px 800px at 50% 90%, var(--glow3), transparent 65%),
    linear-gradient(180deg, var(--bgTop) 0%, var(--bgBot) 100%);
  transition: background 1.2s ease-in-out;
}

.fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.fx > div { 
  position: absolute; 
  top: -50%; left: -50%; width: 200%; height: 200%;
  transition: opacity 0.8s ease; 
  will-change: transform;
}
.fx > div::before, .fx > div::after { 
  content: ""; position: absolute; inset: 0; background-repeat: repeat; will-change: transform;
}

.fx .rain { opacity: var(--fx-rain-op); }
.fx .rain {
  background-image: radial-gradient(1px 7px at 15% 25%, rgba(120,220,255,.25) 50%, transparent);
  background-size: 100px 100px;
  animation: fall1 calc(1.2s * var(--fx-rain-speed)) linear infinite;
}
.fx .rain::before {
  background-image: radial-gradient(1.5px 12px at 20% 10%, rgba(120,220,255,.4) 50%, transparent);
  background-size: 150px 150px;
  animation: fall2 calc(1.0s * var(--fx-rain-speed)) linear infinite;
}
@keyframes fall1 { 0% { transform: translate3d(0,0,0); } 100% { transform: translate3d(-100px, 300px, 0); } }
@keyframes fall2 { 0% { transform: translate3d(0,0,0); } 100% { transform: translate3d(-150px, 450px, 0); } }

.fx .snow { opacity: var(--fx-snow-op); }
.fx .snow {
  background-image: radial-gradient(2px 2px at 15% 25%, rgba(255,255,255,.4) 50%, transparent);
  background-size: 100px 100px;
  animation: snowFall1 calc(8s * var(--fx-snow-speed)) linear infinite;
}
@keyframes snowFall1 { 0% { transform: translate3d(0,0,0); } 100% { transform: translate3d(-100px, 200px, 0); } }

.fx .fog { opacity: var(--fx-fog-op); }
.fx .fog {
  background: radial-gradient(circle at 30% 50%, rgba(255,255,255,.06) 0%, transparent 60%);
  background-size: 400px 400px;
  animation: fogMove1 20s ease-in-out infinite alternate;
  filter: blur(8px);
}
@keyframes fogMove1 { 0% { transform: translate3d(0, 0, 0) scale(1); } 100% { transform: translate3d(50px, 20px, 0) scale(1.1); } }

.flash { 
  position: fixed; inset: 0; background: rgba(255,255,255,0); 
  pointer-events: none; z-index: 2; transition: background .1s linear; 
}

.canvasTooltip {
  position: fixed; z-index: 1000; pointer-events: none;
  background: rgba(8, 14, 26, 0.92); border: 1px solid var(--accent);
  padding: 8px 12px; border-radius: 12px; font-size: 12px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); backdrop-filter: blur(8px);
  transform: translate(-50%, -130%); transition: opacity 0.15s ease;
}

.wrap { position: relative; z-index: 10; max-width: 1180px; margin: 0 auto; padding: 20px 16px 30px; }

/* NAGŁÓWEK NA KOMPUTERY - ZERO RAMEK */
#mainHeader {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "logo wea pills";
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
}

.h-logo { grid-area: logo; justify-self: start; display: flex; align-items: center; }
.h-logo img { height: 42px; width: auto; display: block; object-fit: contain; }

.h-weather {
  grid-area: wea; justify-self: center; display: flex; align-items: center; gap: 16px; padding: 12px 24px;
}
.h-weather .hw-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }
.h-weather .hw-icon svg { width: 100%; height: 100%; }

.h-weather .hw-temp { font-size: 48px; line-height: 48px; font-weight: 850; letter-spacing: -1px; margin: 0; padding: 0; display: flex; align-items: center; }

.h-weather .hw-desc { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.h-weather .hw-divider { width: 1px; height: 36px; background: var(--stroke); }
.h-weather .hw-trend { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; }

.h-pills { grid-area: pills; justify-self: end; display: flex; gap: 10px; }

.topPill {
  padding: 0 14px; 
  font-size: 13px; 
  color: var(--muted);
  height: 34px;
  display: flex; align-items: center; justify-content: center;
}
.topPill span { color: var(--txt); font-weight: 700; margin-left: 6px; }
.topPill i { color: var(--accent); }

/* PRZYCISK ODŚWIEŻANIA MA RAMKĘ */
.topPill button {
  all: unset; cursor: pointer; color: var(--txt); padding: 4px 8px; margin-left: 8px;
  border-radius: 8px; border: 1px solid var(--stroke2); background: rgba(255, 255, 255, 0.05);
}

.card {
  border: 1px solid var(--stroke); background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  overflow: hidden; position: relative; 
}

.cardHead {
  padding: 16px 18px 12px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06); flex-wrap: wrap; gap: 10px;
}
.cardTitle { margin: 0; font-size: 15px; letter-spacing: 0.5px; color: var(--muted); font-weight: 750; text-transform: uppercase; }
.cardTitle i, .mini .k i, .metric .k i, .airTile .k i, .ltKpi .k i, .riverItem .name i { color: var(--accent); margin-right: 8px; font-size: 1.1em; }
.cardBody { padding: 18px; }

.stack { display: flex; flex-direction: column; gap: var(--gap); margin-top: var(--gap); }
.triple { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.double { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }

.hero { display: flex; flex-direction: column; gap: var(--gap); }

/* PLATY UI - SIATKA 7 KOLUMN DLA METRYK */
.hero7col { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; }

.mini { padding: 8px 4px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.mini .k { font-size: 13px; color: var(--muted2); display: flex; align-items: center; gap: 6px; }
.mini .v { font-size: 16px; font-weight: 800; color: var(--txt); }

.metric { padding: 8px 4px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.metric .k { font-size: 13px; color: var(--muted2); display: flex; align-items: center; gap: 6px; font-weight: 600; }
.metric .v { font-size: 18px; font-weight: 850; color: var(--txt); }
.metric .s { font-size: 12px; font-weight: 700; margin-top: -2px; min-height: 14px; }

.insightRow { padding: 16px 4px; border-bottom: 1px dashed var(--stroke); display: flex; flex-direction: column; justify-content: flex-start; gap: 8px; }
.insightRow:last-child { border-bottom: none; }

.btn, .segBtn { all: unset; cursor: pointer; font-weight: 700; font-size: 13px; padding: 7px 12px; border-radius: 12px; border: 1px solid var(--stroke2); background: rgba(255, 255, 255, 0.04); color: var(--muted); }
.segBtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #080e1a; font-weight: 800; }

.alertBox { display: flex; flex-direction: column; gap: 12px; }
.alertList { display: flex; flex-direction: column; gap: 10px; }

details.alertItem { padding: 12px 4px; border-bottom: 1px dashed var(--stroke); margin: 0; }
details.alertItem:last-child { border-bottom: none; }
details.alertItem summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details.alertItem summary::-webkit-details-marker { display: none; }
.alertTitle { font-weight: 800; font-size: 14px; color: var(--txt); }

/* USUNIĘTE RAMKI Z ETYKIET */
.sev { padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.sev.s-1, .sev.s0 { background: rgba(66, 194, 125, 0.15); color: var(--online); } 
.sev.s1 { background: rgba(240, 168, 93, 0.15); color: var(--warn); }
.sev.s2 { background: rgba(235, 123, 48, 0.15); color: #f0965d; }
.sev.s3 { background: rgba(223, 72, 72, 0.18); color: var(--alarm); }

.alertMeta { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--stroke); font-size: 13px; color: var(--muted); line-height: 1.5; }

.airGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.airTile { padding: 8px 4px; display: flex; flex-direction: column; gap: 6px; justify-content: space-between; }
.airTile .k { font-size: 13px; color: var(--muted2); display: flex; align-items: center; gap: 6px; }
.airTile .v { font-size: 18px; font-weight: 850; }

.airRec { margin-top: 12px; padding: 12px 4px; border-top: 1px dashed var(--stroke); font-size: 13px; line-height: 1.5; color: var(--txt); }

/* W WYŁADOWANIACH - KONTROLKI W JEDNEJ LINII, BEZ UCINANIA */
.ltControls { 
  display: flex; gap: 8px; flex-wrap: nowrap; 
  align-items: center; margin-bottom: 12px; justify-content: flex-start; 
}
.field { 
  display: flex; align-items: center; gap: 6px; 
  border: 1px solid var(--stroke); background: rgba(255, 255, 255, 0.03); 
  border-radius: 12px; padding: 6px 10px; font-size: 13px; color: var(--muted); 
  white-space: nowrap; flex-shrink: 1; 
}

/* Ukrywamy strzałeczki systemowe i zwężamy input (by się nie ucinało) */
.field input { 
  width: 38px; background: transparent; border: none; outline: none; 
  color: var(--txt); font-weight: 800; font-size: 14px; text-align: center; padding: 0; 
}
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type=number] { -moz-appearance: textfield; }

#btnLtReconnect { flex-shrink: 0; padding: 6px 12px; }

.ltKpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ltKpi { padding: 8px 4px; display: flex; flex-direction: column; gap: 6px; }
.ltKpi .k { font-size: 13px; color: var(--muted2); }
.ltKpi .v { font-size: 19px; font-weight: 850; }
.ltStatus { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dotLive { width: 8px; height: 8px; border-radius: 50%; background: var(--muted2); }

.bar { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }

.pollenList { display: flex; flex-direction: column; gap: 12px; }
.pollenRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.pollenName { width: 75px; font-weight: 700; color: var(--txt); }
.pollenBarWrap { flex: 1; height: 6px; background: rgba(255, 255, 255, 0.06); border-radius: 4px; overflow: hidden; }
.pollenBar { height: 100%; border-radius: 4px; }
.pollenVal { width: 45px; text-align: right; font-weight: 800; }

.riverList { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.riverItem { padding: 12px 4px; border-bottom: 1px dashed var(--stroke); display: flex; flex-direction: column; gap: 6px; }
.riverItem:last-child { border-bottom: none; }

.chartBox { padding: 14px 4px; height: 260px; position: relative; display: flex; flex-direction: column; justify-content: center; cursor: crosshair; }
.chartBox canvas { width: 100% !important; height: 220px !important; }
.chartLegend { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 12px; font-size: 12px; font-weight: 700; background: rgba(8, 14, 26, 0.6); padding: 6px 12px; border-radius: 8px; pointer-events: none; }
.legendDot { width: 8px; height: 8px; border-radius: 50%; background: #78dcff; display: inline-block; margin-right: 4px; }
.legendDot.b { background: #ffbe78; }

.hourWrap { display: flex; flex-direction: column; gap: 12px; }
.hourGrid, .days { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.hTile, .dTile { padding: 8px 4px; display: flex; flex-direction: column; gap: 8px; }
.hTop, .dTop { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 14px; }
.hIcon, .dIcon { width: 24px; height: 24px; color: var(--accent2); }
.hTemp, .dMax { font-size: 23px; font-weight: 850; }
.dMin { font-size: 15px; color: var(--muted2); font-weight: 700; margin-left: 6px; }
.hLine, .dLine { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.dDesc { font-size: 12px; color: var(--accent); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.08) 25%, rgba(255,255,255,0.18) 50%, rgba(255,255,255,0.08) 75%); background-size: 200% 100%; animation: skelLoad 1.5s infinite; border-radius: 6px; display: inline-block; }
@keyframes skelLoad { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.card, .h-weather { transition: background-color 0.8s ease, border-color 0.8s ease, box-shadow 0.8s ease !important; }
.dDesc, .hIcon, .dIcon { transition: color 0.8s ease !important; }

.fade-in {
  display: inline-block;
  animation: smoothFadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes smoothFadeIn {
  0% { 
    opacity: 0; 
    transform: translateY(4px); 
    filter: blur(3px); 
  }
  100% { 
    opacity: 1; 
    transform: translateY(0); 
    filter: blur(0); 
  }
}

@media (max-width: 980px) {
  #mainHeader { grid-template-columns: 1fr; grid-template-areas: "loc" "logo" "time" "wea"; justify-items: center; }
  .h-logo { grid-area: logo; }
  .h-weather { grid-area: wea; gap: 12px; padding: 10px 16px; }
  .h-pills { grid-area: time; flex-direction: column; align-items: center; }
  .topPill { grid-area: unset; }
  
  .hero7col { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; justify-items: center; text-align: center; }
  .hero7col .mini, .hero7col .metric { width: 100%; align-items: center; }
  .hero7col .mini .k, .hero7col .metric .k { justify-content: center; }
  
  .riverList { grid-template-columns: 1fr; }
  .airGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* GŁÓWNA NAPRAWA KART NA MOBILE */
  .triple, .double { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  #mainHeader {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: 
      "loc logo time"
      "wea wea wea";
    gap: 12px;
    padding: 12px 14px;
    align-items: center;
  }
  .h-logo { grid-area: logo; justify-self: center; }
  .h-logo img { height: 26px; } 

  .h-pills { display: contents; } 
  
  .topPill { 
    padding: 0 10px; 
    font-size: 12px; 
    height: 32px; 
    display: flex; align-items: center; justify-content: center;
    box-sizing: border-box; white-space: nowrap;
  }
  #locPill { grid-area: loc; justify-self: start; margin: 0; }
  #timePill { grid-area: time; justify-self: end; margin: 0; }
  #timePill button { padding: 4px 6px; margin-left: 4px; border-radius: 8px; }
  
  .h-weather { 
    grid-area: wea; justify-self: center;
    width: 100%; max-width: 100%;
    gap: 8px; padding: 10px 14px; 
    display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: space-between; align-items: center; 
  }
  
  .h-weather .hw-icon { width: 36px; height: 36px; }
  .h-weather .hw-temp { font-size: 36px; line-height: 36px; width: auto; min-width: unset; text-align: left; }
  
  .h-weather .hw-desc { width: auto; flex: 1; min-width: 0; text-align: left; font-size: 14px; }
  .h-weather .hw-divider { display: block !important; height: 30px; margin: 0 4px; }
  .h-weather .hw-trend { width: auto; flex-direction: column; align-items: center; justify-content: center; }
  
  .airGrid, .ltKpis { grid-template-columns: 1fr; }
}