@font-face { font-family: "Nokia Sans"; src: url(/fonts/nosnr.ttf); font-weight: 400; }
@font-face { font-family: "Nokia Sans"; src: url(/fonts/nosns.ttf); font-weight: 600; }
@font-face { font-family: "Nokia Sans"; src: url(/fonts/nosnb.ttf); font-weight: 700; }

:root {
  --bg: #0a0a0a;
  --tile: #141414;
  --tile-on: #1b1b1b;
  --fg: #ebebeb;
  --dim: #686868;
  --faint: #242424;
  --accent: #ff8a00;
  --gap: 2.5vw;
  --cell: calc((100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 3 * var(--gap)) / 2);
  --u: calc(var(--cell) / 2);
  --r: calc(var(--cell) * 0.1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Nokia Sans", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + var(--gap)) calc(env(safe-area-inset-right) + var(--gap))
    calc(env(safe-area-inset-bottom) + var(--gap)) calc(env(safe-area-inset-left) + var(--gap));
}

#grid {
  display: grid;
  grid-template-columns: repeat(2, var(--cell));
  grid-auto-rows: var(--cell);
  gap: var(--gap);
}

#hero { grid-row: 2; grid-column: 1 / -1; }
body[data-view="appliances"] #hero { display: none; }
.tile { grid-row: var(--pr); grid-column: var(--pc) / span var(--w); }

@media (orientation: landscape) {
  :root {
    --gap: 1.6vmin;
    --cell: min(
      (100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 7 * var(--gap)) / 6,
      (100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 5 * var(--gap)) / 4
    );
    --u: var(--cell);
  }
  html, body { height: 100dvh; overflow: hidden; }
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    display: grid;
    place-content: center;
  }
  #grid { grid-template-columns: repeat(6, var(--cell)); grid-template-rows: repeat(4, var(--cell)); }
  #hero { grid-row: 2 / 4; grid-column: 2 / 6; }
  .tile { grid-row: var(--lr); grid-column: var(--lc) / span var(--w); }
  .tile.phone-only { display: none; }
}

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

#hero {
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas: "date weather" "time weather" "tz weather" "status status";
  padding: calc(var(--u) * 0.1) calc(var(--u) * 0.14);
  font-size: calc(var(--u) * 0.2);
  background: var(--tile);
  border-radius: var(--r);
  border: 1px solid rgba(255,255,255,0.05);
  /* jemný vnitřní odlesk nahoře */
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

#date {
  grid-area: date;
  color: var(--dim);
  letter-spacing: 0.025em;
  font-size: calc(var(--u) * 0.19);
}
#time {
  grid-area: time;
  font-weight: 700;
  font-size: calc(var(--u) * 0.95);
  line-height: 1;
  align-self: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}
#tz {
  grid-area: tz;
  color: var(--dim);
  font-size: calc(var(--u) * 0.12);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
#weather { grid-area: weather; text-align: right; align-self: start; }
#weather svg { width: calc(var(--u) * 0.55); height: calc(var(--u) * 0.55); display: block; margin-left: auto; }
#weather .t { font-size: calc(var(--u) * 0.38); font-weight: 600; line-height: 1.1; }
#weather .mm { color: var(--dim); font-size: calc(var(--u) * 0.175); }
#status {
  grid-area: status;
  color: var(--dim);
  font-size: calc(var(--u) * 0.135);
  letter-spacing: 0.02em;
  display: flex;
  gap: 1em;
  align-items: center;
  min-height: 1.6em;
}

/* ---------------------------------------------------------------- dlaždice */

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--tile);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
  color: var(--dim);
  border-radius: var(--r);
  padding: calc(var(--cell) * 0.11) calc(var(--cell) * 0.1);
  font-size: calc(var(--cell) * 0.13);
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s, opacity 0.3s;
}

/* subtilní vnitřní přechod pro hloubku */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(170deg, rgba(255,255,255,0.025) 0%, transparent 55%);
  pointer-events: none;
}

.tile svg { width: calc(var(--cell) * 0.34); height: calc(var(--cell) * 0.34); }

.tile .value {
  font-size: calc(var(--cell) * 0.155);
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile .label {
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}
.tile .value:empty { display: none; }
.tile:active { transform: scale(0.97); }

.tile.on {
  background: var(--tile-on);
  color: var(--fg);
  border-color: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.tile.warn { color: var(--accent); }

/* podržení: oranžová se plní odshora dolů, po dokončení krátce blikne */
.tile .hold {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,138,0,0.55), rgba(255,138,0,0.3));
  border-bottom: 2px solid var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  pointer-events: none;
  transition: transform 0.18s ease-out, opacity 0.18s;
}
.tile:has(.hold) > :not(.hold) { position: relative; }
/* garáž: zespodu nahoru jako otevírání vrat; zapínání zásuvky jako jistič; trouba jako teplo */
.tile.garage .hold, .tile.switch:not(.on) .hold, .tile.oven .hold, .tile.washer .hold {
  transform-origin: bottom;
  background: linear-gradient(0deg, rgba(255,138,0,0.55), rgba(255,138,0,0.3));
  border-bottom: none;
  border-top: 2px solid var(--accent);
}
.tile.pressing .hold { transform: scaleY(1); transition: transform var(--hold) linear; }
.tile.held .hold { transform: scaleY(1); animation: held 0.4s ease-out forwards; }
@keyframes held { 0% { opacity: 1; background: var(--accent); } 100% { opacity: 0; } }
.tile.idle svg { color: var(--dim); }
/* oranžový proužek nahoře = upozornění (vrata otevřená, kotel bez odběru, signál pryč…) */
.tile.warn::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r) var(--r) 0 0;
}
.tile.confirm {
  background: var(--accent);
  color: #000;
  border-color: rgba(255,138,0,0.3);
  box-shadow: none;
}
.tile.confirm .value { color: #000; }
.tile.confirm::before, .tile.confirm::after { display: none; }
.tile.pending { animation: pulse 0.8s ease-in-out infinite alternate; }
.tile.stale, body.offline .tile:not(.link), body.offline #weather { opacity: 0.28; }
.tile.disabled { pointer-events: none; }
.tile.link { color: var(--dim); }

@keyframes pulse { to { opacity: 0.45; } }
@keyframes ring-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.1; } }

/* ---------------------------------------------------------------- stopky a časovače */

.tile .row { display: flex; justify-content: space-between; align-items: flex-start; }
.tile .big {
  font-size: calc(var(--cell) * 0.3);
  font-weight: 700;
  line-height: 1.05;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.tile button {
  font: inherit;
  font-weight: 600;
  color: var(--fg);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: calc(var(--cell) * 0.06);
  min-width: calc(var(--cell) * 0.36);
  height: calc(var(--cell) * 0.3);
  padding: 0 0.6em;
  transition: background 0.12s;
}
.tile button:active { background: rgba(255,255,255,0.14); }
.tile .adjust { display: flex; gap: calc(var(--cell) * 0.06); }
.tile .adjust button { font-size: calc(var(--cell) * 0.2); }
.tile [hidden] { display: none; }
.tile.back { color: var(--fg); }
.tile.ringing {
  background: var(--accent);
  color: #000;
  border-color: transparent;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px rgba(255,138,0,0.25);
  animation: ring-flash 0.45s ease-in-out infinite;
}
.tile.ringing .big, .tile.ringing .label { color: #000; }
.tile.ringing::before, .tile.ringing::after { display: none; }

/* ---------------------------------------------------------------- MHD */

.tile.thermometer .dist { font-size: calc(var(--cell) * 0.13); color: var(--fg); }
.tile .dist.warn { color: var(--accent); }
/* teploměr, šalina a rack mají ikonu šedou (rack oranžovou, když neodpovídá) */
.tile.thermometer svg, .tile.departures svg, .tile.switch:not(.warn) svg { color: var(--dim); }
/* sekačka: šedá ikona v klidu, bílá když jede, oranžová při problému */
.tile.mower .dist { font-size: calc(var(--cell) * 0.13); color: var(--dim); }
.tile.mower:not(.on):not(.warn) svg, .tile.mower:not(.on):not(.warn) .value { color: var(--dim); }
.tile.mower .next { font-size: calc(var(--cell) * 0.11); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.mower .next.warn { color: var(--accent); }
/* trouba: šedá, když nejede, bílá při programu, oranžová při poruše */
.tile.oven .dist { font-size: calc(var(--cell) * 0.13); color: var(--dim); }
.tile.oven:not(.on):not(.warn) svg, .tile.oven:not(.on):not(.warn) .value { color: var(--dim); }
.tile.oven .next { font-size: calc(var(--cell) * 0.11); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.oven .next.warn { color: var(--accent); }

.tile.washer .dist { font-size: calc(var(--cell) * 0.13); color: var(--dim); }
.tile.washer:not(.on):not(.warn) svg, .tile.washer:not(.on):not(.warn) .value { color: var(--dim); }
.tile.washer .next { font-size: calc(var(--cell) * 0.11); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.washer .next.warn { color: var(--accent); }

/* vchod: zavřené šedě, otevřené oranžově (.warn) */
.tile.door .dist { font-size: calc(var(--cell) * 0.13); color: var(--dim); }
.tile.door .dist.warn { color: var(--accent); }
.tile.door:not(.warn) svg, .tile.door:not(.warn) .value { color: var(--dim); }
.tile.door .next { font-size: calc(var(--cell) * 0.11); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.thermometer .next {
  font-size: calc(var(--cell) * 0.11);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* číslo linky ve čtverečku */
b.line {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.7em; height: 1.7em; padding: 0 0.25em;
  border-radius: 0.22em;
  border: 1.5px solid currentColor; color: inherit;
  font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
}

/* 2 × 1 jako kalendář: vlevo ikona, vpravo nejbližší spoje, které ještě stihnu */
.tile.departures { flex-direction: row; gap: calc(var(--cell) * 0.1); }
.tile.departures .mhd-left {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; width: calc(var(--cell) * 0.5);
  border-right: 1px solid var(--faint);
}
.tile.departures .mhd-left svg { width: calc(var(--cell) * 0.34); height: calc(var(--cell) * 0.34); }
.tile.departures .mhd-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-around; }
.tile.departures .mhd-l {
  display: flex; align-items: center; gap: 0.5em;
  font-size: calc(var(--cell) * 0.105);
  color: var(--dim); white-space: nowrap;
}
.tile.departures .mhd-l .min { font-variant-numeric: tabular-nums; }
/* bíle jen rezerva n v „5 + n min“ */
.mhd-l .n, #mhd-table .n { color: var(--fg); font-weight: 700; }
.tile.departures .mhd-l .hm { margin-left: auto; color: var(--dim); font-variant-numeric: tabular-nums; }
.tile.departures .mhd-none { color: var(--dim); font-size: calc(var(--cell) * 0.155); }

/* ---------------------------------------------------------------- kalendář */

.tile.calendar { flex-direction: row; gap: calc(var(--cell) * 0.1); cursor: pointer; }
.tile.calendar .cal-left {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(var(--cell) * 0.04); flex-shrink: 0; width: calc(var(--cell) * 0.5);
  border-right: 1px solid var(--faint);
}
.tile.calendar .cal-left svg { width: calc(var(--cell) * 0.3); height: calc(var(--cell) * 0.3); }
.tile.calendar .cal-day { font-size: calc(var(--cell) * 0.22); font-weight: 700; color: var(--fg); line-height: 1; }
.tile.calendar .cal-events {
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-around;
}
.tile.calendar .cal-ev {
  font-size: calc(var(--cell) * 0.105);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}
.tile.calendar .cal-ev .w { color: var(--dim); }
.tile.calendar .cal-ev-more { color: var(--dim); font-style: italic; }

/* nástěnka: vlevo ikona nahoře a název dole jako u ostatních dlaždic (ve stejné výšce jako jejich), vpravo první řádky textu */
.tile.board { flex-direction: row; gap: calc(var(--cell) * 0.1); cursor: pointer; }
.tile.board .cal-left {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  flex-shrink: 0; width: calc(var(--cell) * 0.6); border-right: 1px solid var(--faint);
}
.tile.board .bd-label { color: var(--dim); white-space: nowrap; letter-spacing: 0.01em; } /* jako .tile .label */
.tile.board .bd-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 0.25em; }
.tile.board .cal-ev { font-size: calc(var(--cell) * 0.105); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.tile.board.warn .cal-ev { color: var(--accent); }
/* nepřečtená změna jako rozdíl: přidané oranžově, smazané šedě přeškrtnuté, zbytek řádku normálně */
.tile.board.warn .cal-ev.bd-diff { color: var(--fg); }
.tile.board .bd-ins { color: var(--accent); }
.tile.board .bd-del { color: var(--dim); text-decoration: line-through; }

/* ---------------------------------------------------------------- detail teploměru */

#th-overlay, #ts-overlay, #mhd-overlay, #mw-overlay, #ov-overlay, #lt-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--cell) 1fr;
  grid-template-rows: var(--cell) 1fr;
  gap: var(--gap);
  padding: calc(env(safe-area-inset-top) + var(--gap))
           calc(env(safe-area-inset-right) + var(--gap))
           calc(env(safe-area-inset-bottom) + var(--gap))
           calc(env(safe-area-inset-left) + var(--gap));
  z-index: 100;
}
#th-overlay[hidden], #ts-overlay[hidden], #mhd-overlay[hidden], #mw-overlay[hidden], #ov-overlay[hidden], #lt-overlay[hidden] { display: none; }

#th-back, #ts-back, #mhd-back, #mhd-maps, #mw-back, #ov-back, #lt-back {
  grid-column: 1; grid-row: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--tile);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
  border-radius: var(--r);
  padding: calc(var(--cell) * 0.11) calc(var(--cell) * 0.1);
  color: var(--fg);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
#th-back::before, #ts-back::before, #mhd-back::before, #mhd-maps::before, #mw-back::before, #ov-back::before, #lt-back::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(170deg, rgba(255,255,255,0.025) 0%, transparent 55%);
  pointer-events: none;
}
#th-back:active, #ts-back:active, #mhd-back:active, #mhd-maps:active, #mw-back:active, #ov-back:active, #lt-back:active { transform: scale(0.97); }
#th-back svg, #ts-back svg, #mhd-back svg, #mhd-maps svg, #mw-back svg, #ov-back svg, #lt-back svg { width: calc(var(--cell) * 0.34); height: calc(var(--cell) * 0.34); }
#th-back span, #ts-back span, #mhd-back span, #mhd-maps span, #mw-back span, #ov-back span, #lt-back span { color: var(--dim); font-size: calc(var(--cell) * 0.13); letter-spacing: 0.01em; }

#th-content, #ts-content, #mhd-content, #mw-content, #ov-content, #lt-content {
  position: relative;
  grid-column: 2; grid-row: 1 / 3;
  background: var(--tile);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#th-header-row {
  padding: calc(var(--cell) * 0.09) calc(var(--cell) * 0.1) calc(var(--cell) * 0.04);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
#th-title { font-weight: 700; font-size: calc(var(--cell) * 0.155); color: var(--fg); }

#th-stats {
  display: flex;
  gap: 0.6em;
  align-items: baseline;
  padding: calc(var(--cell) * 0.07) calc(var(--cell) * 0.1) calc(var(--cell) * 0.04);
  flex-shrink: 0;
}
#th-temp { font-size: calc(var(--cell) * 0.55); font-weight: 700; color: var(--fg); line-height: 1; }
#th-hum, #th-min { font-size: calc(var(--cell) * 0.175); color: var(--dim); }
#th-hum:empty, #th-min:empty { display: none; }

#th-chart {
  flex: 1;
  min-height: calc(var(--cell) * 0.8);
  padding: 0 calc(var(--cell) * 0.08) calc(var(--cell) * 0.06);
  display: flex;
  align-items: stretch;
}
#th-chart { position: relative; }
#th-chart svg { width: 100%; flex: 1; display: block; min-height: 0; touch-action: none; cursor: crosshair; }
/* detail bodu po dotyku: čára přes výšku grafu, bod a popisek nad grafem */
.th-tip { position: absolute; inset: 0; pointer-events: none; }
.th-tip[hidden] { display: none; }
.th-cursor { position: absolute; left: var(--x); top: var(--top); height: var(--h); width: 1px; background: rgba(255, 255, 255, 0.35); }
.th-dot {
  position: absolute; left: var(--x); top: var(--y); width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg, #000);
}
.th-tip span {
  position: absolute; left: var(--x); top: var(--top); transform: translateX(8px);
  padding: 0.25em 0.55em; border-radius: 0.4em; background: rgba(0, 0, 0, 0.75); color: var(--fg);
  font-size: calc(var(--cell) * 0.12); white-space: nowrap;
}
.th-tip.left span { transform: translateX(calc(-100% - 8px)); }
/* legenda grafu u hlavice: teplota, nastavená teplota, otevření ventilu */
#th-chart:has(.th-legend) { flex-direction: column; }
.th-legend { display: flex; gap: 1.2em; justify-content: flex-end; color: var(--dim); font-size: calc(var(--cell) * 0.1); padding-top: 0.3em; }
.th-legend span::before { content: ""; display: inline-block; width: 1.4em; height: 0; margin-right: 0.4em; vertical-align: middle; border-top: 2px solid var(--accent); }
.th-legend .s::before {
  border: 0; height: 1.5px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.6) 0 6px, transparent 6px 9px, rgba(255, 255, 255, 0.6) 9px 10.5px, transparent 10.5px 13.5px);
}
.th-legend .v::before { height: 0.7em; border: 0; background: rgba(232, 85, 58, 0.45); }
#th-chart .loading { color: var(--dim); font-size: calc(var(--cell) * 0.13); padding: 0.8em 0; }

/* na výšku: Zpět 1 × 1 vlevo nahoře, obsah přes celou šířku pod ním */
@media (orientation: portrait) {
  #th-overlay, #ts-overlay, #mhd-overlay, #mw-overlay, #ov-overlay, #lt-overlay {
    grid-template-columns: repeat(2, var(--cell));
    grid-template-rows: var(--cell) 1fr;
  }
  #th-back, #ts-back, #mhd-back, #mhd-maps, #mw-back, #ov-back, #lt-back { grid-column: 1; grid-row: 1; }
  #th-content, #ts-content, #mw-content, #ov-content, #lt-content { grid-column: 1 / 3; grid-row: 2; }
}

/* ---------------------------------------------------------------- detail sekačky */

.mw-header {
  padding: calc(var(--cell) * 0.09) calc(var(--cell) * 0.1) calc(var(--cell) * 0.04);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
#mw-title, #ov-title, #lt-title { font-weight: 700; font-size: calc(var(--cell) * 0.155); color: var(--fg); }
#mw-stats, #ov-stats {
  display: flex; gap: 0.6em; align-items: baseline;
  padding: calc(var(--cell) * 0.07) calc(var(--cell) * 0.1) calc(var(--cell) * 0.02);
  flex-shrink: 0;
}
#mw-mode, #ov-mode { font-size: calc(var(--cell) * 0.4); font-weight: 700; color: var(--fg); line-height: 1; }
#mw-mode.idle, #ov-mode.idle { color: var(--dim); }
#mw-mode.warn, #ov-mode.warn { color: var(--accent); }
#mw-bat, #ov-temp { font-size: calc(var(--cell) * 0.175); color: var(--dim); }
#mw-info, #mw-sum, #ov-info {
  display: flex; flex-wrap: wrap; gap: 0.3em 1.4em;
  padding: calc(var(--cell) * 0.03) calc(var(--cell) * 0.1);
  font-size: calc(var(--cell) * 0.12); color: var(--dim);
  flex-shrink: 0;
}
#mw-info b, #mw-sum b, #ov-info b { font-weight: 600; color: var(--fg); }
#mw-info .warn b, #ov-info .warn b { color: var(--accent); }
#mw-chart {
  flex: 1;
  min-height: calc(var(--cell) * 0.8);
  padding: calc(var(--cell) * 0.04) calc(var(--cell) * 0.08) calc(var(--cell) * 0.06);
  display: flex; flex-direction: column; align-items: stretch;
}
#mw-chart svg { width: 100%; flex: 1; display: block; min-height: 0; }
.mw-legend { display: flex; flex-wrap: wrap; gap: 0.2em 1.2em; padding-top: 0.5em; font-size: calc(var(--cell) * 0.1); color: var(--dim); flex-shrink: 0; }
.mw-legend i { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 2px; margin-right: 0.4em; vertical-align: -0.05em; }
#mw-chart .loading { color: var(--dim); font-size: calc(var(--cell) * 0.13); padding: 0.8em 0; }

/* ---------------------------------------------------------------- detail odjezdů */

#mhd-overlay { grid-template-rows: var(--cell) var(--cell) 1fr; }
#mhd-maps { grid-column: 1; grid-row: 2; text-decoration: none; }
#mhd-content { grid-row: 1 / 4; }
#mhd-content.warn::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); border-radius: var(--r) var(--r) 0 0;
}
#mhd-header-row {
  padding: calc(var(--cell) * 0.09) calc(var(--cell) * 0.1) calc(var(--cell) * 0.04);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
#mhd-title { font-weight: 700; font-size: calc(var(--cell) * 0.155); color: var(--fg); }
#mhd-table {
  border-collapse: collapse;
  margin: calc(var(--cell) * 0.04) calc(var(--cell) * 0.1);
  font-size: calc(var(--cell) * 0.11);
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}
#mhd-table th { color: var(--dim); font-weight: 400; text-align: left; padding: 0.4em 0.5em; }
#mhd-table td { padding: 0.3em 0.5em; vertical-align: middle; white-space: nowrap; }
#mhd-table .r { text-align: right; }
#mhd-table tr.first td { border-top: 1px solid var(--faint); }
#mhd-table tr.late { opacity: 0.5; }
#mhd-table td.dest { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
#mhd-table td.dest small { color: var(--dim); font-size: 0.8em; }
#mhd-table .empty { color: var(--dim); }

@media (orientation: portrait) {
  #mhd-overlay { grid-template-rows: var(--cell) 1fr; }
  #mhd-maps { grid-column: 2; grid-row: 1; }
  #mhd-content { grid-column: 1 / 3; grid-row: 2; overflow-y: auto; }
  #mhd-table { font-size: calc(var(--cell) * 0.13); }
}

/* ---------------------------------------------------------------- termostat */

.tile.thermostat .dist, .tile.thermostat .next { font-size: calc(var(--cell) * 0.11); }
.tile.thermostat .dist { font-size: calc(var(--cell) * 0.13); color: var(--fg); }
.tile.thermostat svg { transition: color 0.3s; }
.tile.thermostat.heating svg { color: var(--fg); }
.tile.thermostat .label:empty { display: none; }
.tile.thermostat .next { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#ts-body {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: calc(var(--cell) * 0.15);
  align-items: center;
  padding: calc(var(--cell) * 0.08) calc(var(--cell) * 0.12);
}
#ts-control {
  flex: 1.3;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cell) * 0.06);
}
#ts-dial {
  /* čtverec, co se vejde: výška panelu minus tlačítka, nebo šířka */
  width: min(100%, calc(100dvh - var(--cell) * 1.25));
  max-width: calc(var(--cell) * 2.6);
  aspect-ratio: 1;
  touch-action: none;
  cursor: grab;
  border-radius: 50%;
  transition: filter 0.2s;
}
#ts-dial.dragging { cursor: grabbing; }
#ts-dial.readonly, #ts-dial.off { cursor: default; }
#ts-dial.stale { opacity: 0.35; }
#ts-dial svg { width: 100%; height: 100%; display: block; font-family: "Nokia Sans", system-ui, sans-serif; }
#ts-dial .rim { fill: none; stroke: rgba(255,255,255,0.07); stroke-width: 1.5; }
#ts-dial .disc { fill: url(#ts-idle); transition: fill 0.4s; }
#ts-dial.heating .disc { fill: url(#ts-heat); }
#ts-dial.off .disc { fill: #0e0e0e; }
#ts-dial .tick { stroke: rgba(255,255,255,0.22); stroke-width: 1.4; stroke-linecap: round; }
#ts-dial .tick.hi { stroke: rgba(255,255,255,0.85); }
#ts-dial.heating .tick { stroke: rgba(255,255,255,0.35); }
#ts-dial.heating .tick.hi { stroke: #fff; }
#ts-dial .set { stroke: #fff; stroke-width: 3.2; stroke-linecap: round; }
#ts-dial .knob { fill: #fff; }
#ts-dial .cur { stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
#ts-dial.heating .cur { stroke: #3a1500; }
#ts-dial .cur-label { fill: rgba(255,255,255,0.7); font-size: 9px; font-weight: 600; }
#ts-dial .big { fill: #fff; font-size: 56px; font-weight: 700; letter-spacing: -0.03em; }
#ts-dial .big .half { font-size: 22px; }
#ts-dial .off-text { fill: var(--dim); font-size: 34px; }
#ts-dial .small { fill: rgba(255,255,255,0.65); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; }

#ts-buttons { display: flex; gap: calc(var(--cell) * 0.12); }
#ts-buttons button {
  font: inherit;
  font-size: calc(var(--cell) * 0.2);
  font-weight: 600;
  color: var(--fg);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: calc(var(--cell) * 0.06);
  width: calc(var(--cell) * 0.5);
  height: calc(var(--cell) * 0.3);
  cursor: pointer;
}
#ts-buttons button:active { background: rgba(255,255,255,0.14); }
#ts-buttons button:disabled { opacity: 0.3; cursor: default; }

#ts-list {
  flex: 1;
  min-width: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  align-self: center;
}
#ts-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6em;
  padding: calc(var(--cell) * 0.07) 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: calc(var(--cell) * 0.15);
  color: var(--dim);
}
#ts-list li:last-child { border-bottom: none; }
#ts-list li b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
#ts-list li.stale b { opacity: 0.35; }
#ts-list li span { flex: 1; }
#ts-list li i { font-style: normal; font-size: 0.75em; }
#ts-list li i.warn { color: var(--accent); }
#ts-list li.room { cursor: pointer; }
#ts-list li.room span::after { content: " ›"; opacity: 0.5; }
/* graf teploměru se otevírá z detailu termostatu, musí být nad ním */
#th-overlay { z-index: 101; }

@media (orientation: portrait) {
  #ts-content { overflow-y: auto; }
  /* tělo roste podle obsahu, scrolluje celý panel (jinak seznam teploměrů pod kolečkem přetekl mimo) */
  #ts-body { flex: none; flex-direction: column; align-items: stretch; }
  #ts-control { height: auto; flex: none; }
  #ts-dial { width: min(100%, calc(var(--cell) * 1.35)); }
  #ts-list li { padding: calc(var(--cell) * 0.045) 0; }
  #ts-list { align-self: stretch; flex: none; }
}

/* ---------------------------------------------------------------- nákupní seznam */

/* něco je na seznamu → bílá ikona */
.tile.shopping.has-items svg { color: var(--fg); }

#sh-overlay, #ono-overlay, #wl-overlay, #bd-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--cell) 1fr;
  grid-template-rows: var(--cell) 1fr;
  gap: var(--gap);
  padding: calc(env(safe-area-inset-top) + var(--gap))
           calc(env(safe-area-inset-right) + var(--gap))
           calc(env(safe-area-inset-bottom) + var(--gap))
           calc(env(safe-area-inset-left) + var(--gap));
  z-index: 100;
}
#sh-overlay[hidden], #ono-overlay[hidden], #wl-overlay[hidden], #bd-overlay[hidden] { display: none; }

/* 1×1 tile se Zpět */
#sh-back, #ono-back, #wl-back, #bd-back {
  grid-column: 1; grid-row: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--tile);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
  border-radius: var(--r);
  padding: calc(var(--cell) * 0.11) calc(var(--cell) * 0.1);
  color: var(--fg);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
#sh-back::before, #ono-back::before, #wl-back::before, #bd-back::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(170deg, rgba(255,255,255,0.025) 0%, transparent 55%);
  pointer-events: none;
}
#sh-back:active, #ono-back:active, #wl-back:active, #bd-back:active { transform: scale(0.97); }
#sh-back svg, #ono-back svg, #wl-back svg, #bd-back svg { width: calc(var(--cell) * 0.34); height: calc(var(--cell) * 0.34); }
#sh-back span, #ono-back span, #wl-back span, #bd-back span { color: var(--dim); font-size: calc(var(--cell) * 0.13); letter-spacing: 0.01em; }

/* pravý panel – poznámkový blok, plná výška */
#sh-content, #ono-content, #wl-content, #bd-content {
  grid-column: 2; grid-row: 1 / 3;
  background: var(--tile);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sh-header-row, #ono-header-row, #wl-header-row, #bd-header-row {
  padding: calc(var(--cell) * 0.09) calc(var(--cell) * 0.1) calc(var(--cell) * 0.07);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
#sh-title, #ono-title, #wl-title, #bd-title { font-weight: 700; font-size: calc(var(--cell) * 0.3); color: var(--fg); line-height: 1; }

/* editační input – pinnutý pod nadpisem, viditelný nad klávesnicí */
#sh-edit-row {
  height: calc(var(--cell) * 0.32);
  display: flex;
  align-items: center;
  padding: 0 calc(var(--cell) * 0.1);
  border-bottom: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
  background: rgba(255,255,255,0.025);
}
#sh-edit-row[hidden] { display: none; }
#sh-edit-input {
  flex: 1;
  font: inherit;
  font-size: calc(var(--cell) * 0.175);
  font-weight: 600;
  background: transparent;
  color: var(--fg);
  border: none;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  letter-spacing: 0.01em;
}
#sh-edit-input::placeholder { color: var(--dim); opacity: 0.4; font-weight: 400; }

/* nabídka – selectbox styl, pod editačním inputem (viditelné nad klávesnicí) */
#sh-suggestions {
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 45%;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
#sh-suggestions[hidden] { display: none; }

.sh-sugg-item {
  display: flex;
  width: 100%;
  height: calc(var(--cell) * 0.32);
  align-items: center;
  padding: 0 calc(var(--cell) * 0.1);
  font: inherit;
  font-size: calc(var(--cell) * 0.155);
  color: var(--dim);
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  text-align: left;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.sh-sugg-item:last-child { border-bottom: none; }
.sh-sugg-item:active { background: rgba(255,255,255,0.06); color: var(--fg); }

/* seznam řádků – pevná výška pro konzistenci */
#sh-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.sh-item {
  height: calc(var(--cell) * 0.32);
  display: flex;
  align-items: center;
  padding: 0 calc(var(--cell) * 0.1);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
}
.sh-item.active { background: rgba(255,255,255,0.03); }
.sh-name {
  flex: 1;
  font-size: calc(var(--cell) * 0.175);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.01em;
}

@media (orientation: portrait) {
  #sh-overlay, #ono-overlay, #wl-overlay, #bd-overlay { grid-template-columns: repeat(2, var(--cell)); grid-template-rows: var(--cell) 1fr; }
  #sh-content, #ono-content, #wl-content, #bd-content { grid-column: 1 / 3; grid-row: 2; }
}

/* ---------------------------------------------------------------- nástěnka */

#bd-header-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1em; }
#bd-status { color: var(--dim); font-size: calc(var(--cell) * 0.1); white-space: nowrap; }
#bd-text {
  flex: 1; min-height: 0; resize: none; border: none; outline: none;
  background: transparent; color: var(--fg); font: inherit;
  font-size: calc(var(--cell) * 0.15); line-height: 1.4;
  padding: calc(var(--cell) * 0.08) calc(var(--cell) * 0.1);
}
#bd-text::placeholder { color: var(--dim); opacity: 0.4; }
#bd-text[hidden], #bd-signin[hidden] { display: none; }
#bd-signin {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 1em;
  padding: calc(var(--cell) * 0.1); color: var(--dim); font-size: calc(var(--cell) * 0.12);
}
#bd-signin p { margin: 0; }

/* ---------------------------------------------------------------- wishlist */

#wl-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: calc(var(--cell) * 0.05); }
/* filtr podle osoby: profilovky vedle „+“, vybraná s oranžovým kroužkem */
#wl-people { display: flex; align-items: center; gap: 0.3em; margin-left: auto; }
#wl-people button {
  width: calc(var(--cell) * 0.2); height: calc(var(--cell) * 0.2); padding: 0; overflow: hidden; cursor: pointer;
  border-radius: 50%; border: 2px solid transparent; background: rgba(255,255,255,0.06); color: var(--dim);
  font: inherit; font-size: calc(var(--cell) * 0.075); opacity: 0.55;
}
#wl-people button.all { width: auto; padding: 0 0.6em; border-radius: 1em; }
#wl-people button.on { border-color: var(--accent); opacity: 1; color: var(--fg); }
#wl-people img { width: 100%; height: 100%; object-fit: cover; display: block; }
#wl-add {
  font: inherit; font-size: calc(var(--cell) * 0.22); line-height: 1;
  width: calc(var(--cell) * 0.3); height: calc(var(--cell) * 0.3);
  background: rgba(255,255,255,0.06); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.08); border-radius: calc(var(--r) * 0.6); cursor: pointer;
}
#wl-add[hidden] { display: none; }
#wl-list { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.wl-group {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: calc(var(--cell) * 0.11); font-weight: 600;
  color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em;
  padding: calc(var(--cell) * 0.1) calc(var(--cell) * 0.1) calc(var(--cell) * 0.04);
  background: none; border: none;
}
.wl-fold { cursor: pointer; margin-top: calc(var(--cell) * 0.06); border-top: 1px solid rgba(255,255,255,0.05); }
.wl-fold::before { content: "▸ "; }
.wl-fold.open::before { content: "▾ "; }
.wl-item {
  display: flex; align-items: center; gap: calc(var(--cell) * 0.07);
  min-height: calc(var(--cell) * 0.32);
  padding: calc(var(--cell) * 0.04) calc(var(--cell) * 0.1);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.wl-item.editing { background: rgba(255,255,255,0.03); }
.wl-for {
  flex-shrink: 0; width: calc(var(--cell) * 0.2); text-align: center;
  font-size: calc(var(--cell) * 0.1); font-weight: 600; color: var(--dim);
}
.wl-for img { width: calc(var(--cell) * 0.17); height: calc(var(--cell) * 0.17); border-radius: 50%; object-fit: cover; display: block; margin: auto; }
.wl-main { flex: 1; min-width: 0; cursor: pointer; }
.wl-name { font-size: calc(var(--cell) * 0.14); font-weight: 600; color: var(--fg); }
.wl-note {
  font-size: calc(var(--cell) * 0.1); color: var(--dim); margin-top: 0.15em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wl-item.maybe .wl-name { color: var(--dim); }
.wl-item.bought .wl-name { color: var(--dim); text-decoration: line-through; }
.wl-badge {
  flex-shrink: 0; font: inherit; font-size: calc(var(--cell) * 0.09); white-space: nowrap;
  padding: 0.3em 0.7em; border-radius: 1em; cursor: pointer;
  background: none; color: var(--accent); border: 1px solid var(--accent);
}
.wl-item.maybe .wl-badge { color: var(--dim); border-color: rgba(255,255,255,0.12); }
/* „určitě ano“ a „možná“ bez štítku (je to vidět ze sekce), důležitost jde změnit v detailu */
.wl-item.unset .wl-badge, .wl-item.sure .wl-badge { display: none; }
.wl-badge:disabled { cursor: default; }
/* e-shop vpravo, pevná šířka, aby štítky důležitosti lícovaly */
.wl-shop {
  flex-shrink: 0; width: calc(var(--cell) * 0.5); box-sizing: border-box;
  font-size: calc(var(--cell) * 0.09); text-align: center; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0.3em 0.6em; border-radius: 1em;
  color: var(--fg); background: rgba(255,255,255,0.07);
}
.wl-shop.empty { background: none; }
.wl-shop svg { height: 1.3em; width: auto; vertical-align: middle; color: var(--dim); }
/* „spíš ne“ a koupené: logo e-shopu a štítek důležitosti tlumeně, šedě */
.wl-item.maybe .wl-shop img, .wl-item.bought .wl-shop img { filter: grayscale(1); opacity: 0.45; }
.wl-item.bought .wl-badge { color: var(--dim); border-color: rgba(255,255,255,0.12); }
.wl-shop img { height: 1.6em; width: auto; vertical-align: middle; border-radius: 0.3em; margin: -0.3em 0; }

/* úzký displej (mobil na výšku): název přes celou šířku, pro koho / štítek / e-shop na řádku pod ním */
@media (orientation: portrait) {
  .wl-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas: "main main main main" "for . badge shop";
    row-gap: calc(var(--cell) * 0.04);
    padding-top: calc(var(--cell) * 0.07); padding-bottom: calc(var(--cell) * 0.07);
  }
  .wl-main { grid-area: main; }
  .wl-for { grid-area: for; width: auto; text-align: left; align-self: center; }
  .wl-badge { grid-area: badge; }
  .wl-shop { grid-area: shop; width: calc(var(--cell) * 0.36); }
  .wl-shop.empty { display: none; }
  .wl-for:empty { display: none; }
  .wl-for img { width: 1.8em; height: 1.8em; }
}

#wl-form {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: calc(var(--cell) * 0.05);
  padding: calc(var(--cell) * 0.06) calc(var(--cell) * 0.1) calc(var(--cell) * 0.1);
  background: rgba(255,255,255,0.03); border-bottom: 1px solid rgba(255,255,255,0.08);
}
#wl-form[hidden] { display: none; }
#wl-form input, #wl-form textarea {
  font: inherit; font-size: calc(var(--cell) * 0.12); color: var(--fg);
  background: var(--bg); border: 1px solid rgba(255,255,255,0.1); border-radius: calc(var(--r) * 0.5);
  padding: 0.45em 0.6em; outline: none; resize: vertical; min-width: 0;
  -webkit-user-select: text; user-select: text;
}
#wl-form input:focus, #wl-form textarea:focus { border-color: var(--accent); }
#wl-form input::placeholder, #wl-form textarea::placeholder { color: var(--dim); }
#wl-links { font-size: calc(var(--cell) * 0.1); color: var(--dim); -webkit-user-select: text; user-select: text; }
#wl-links:empty, #wl-meta:empty { display: none; }
#wl-meta { font-size: calc(var(--cell) * 0.09); color: var(--dim); align-self: center; }
#wl-links a { color: var(--fg); }
#wl-form button {
  font: inherit; font-size: calc(var(--cell) * 0.11); padding: 0.55em 0; min-width: 0;
  background: rgba(255,255,255,0.06); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.08); border-radius: calc(var(--r) * 0.5); cursor: pointer;
}
#wl-form button:active { background: rgba(255,255,255,0.14); }
#wl-form button[hidden] { display: none; }
#wl-form :disabled { opacity: 0.5; }
#wl-form .wl-want { display: flex; gap: calc(var(--cell) * 0.05); }
#wl-form .wl-want button { flex: 1; }
#wl-form .wl-want button.on { border-color: var(--accent); color: var(--accent); }
#wl-save { background: var(--accent) !important; color: #000 !important; border-color: transparent !important; }


/* rozmístění v mřížce 6 sloupců */
#wl-url { grid-area: url; } #wl-name { grid-area: name; } #wl-note { grid-area: note; } #wl-links { grid-area: links; }
#wl-form .wl-want { grid-area: want; } #wl-meta { grid-area: meta; }
#wl-save { grid-area: save; } #wl-bought { grid-area: bought; }
#wl-cancel { grid-area: cancel; }

/* jen to hlavní: Uložit | Koupeno | koš (smazat / zahodit novou) */
#wl-form { grid-template-areas:
  "img img img img img img" "url url url url url url" "name name name name name name" "note note note note note note" "links links links links links links"
  "want want want want want want" "save save save bought bought cancel" "meta meta meta meta meta meta"; }
#wl-cancel svg { width: 1.2em; height: 1.2em; vertical-align: middle; color: var(--dim); }

/* posun v řádku upravované položky (místo štítku důležitosti) */
.wl-rowmove { flex-shrink: 0; display: flex; gap: 0.3em; grid-row: 2; grid-column: 3 / 5; justify-self: end; }
.wl-rowmove button {
  font: inherit; font-size: calc(var(--cell) * 0.11); width: 2.2em; height: 2em; padding: 0; cursor: pointer;
  background: rgba(255,255,255,0.06); color: var(--fg); border: 1px solid rgba(255,255,255,0.1); border-radius: 1em;
}
.wl-rowmove button:active { background: rgba(255,255,255,0.14); }

/* ---------------------------------------------------------------- wishlist: náhledy produktů */

/* náhled v detailu */
#wl-img { grid-area: img; justify-self: center; max-width: 100%; max-height: calc(var(--cell) * 0.9); object-fit: contain; border-radius: calc(var(--r) * 0.5); background: #fff; }
#wl-img[hidden] { display: none; }

/* náhled v seznamu: čtverec na konci řádku */
.wl-thumb { flex-shrink: 0; overflow: hidden; border-radius: calc(var(--r) * 0.4); background: #fff; cursor: pointer; width: calc(var(--cell) * 0.42); height: calc(var(--cell) * 0.42); order: 9; }
.wl-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.wl-thumb.empty { background: rgba(255,255,255,0.04); }
.wl-item.bought .wl-thumb, .wl-item.maybe .wl-thumb { opacity: 0.55; }

@media (orientation: portrait) {
  .wl-item { grid-template-columns: auto 1fr auto auto auto; grid-template-areas: "main main main main thumb" "for . badge shop thumb"; }
  .wl-thumb { grid-area: thumb; align-self: center; width: calc(var(--cell) * 0.5); height: calc(var(--cell) * 0.5); }
  .wl-rowmove { grid-row: 2; grid-column: 3 / 5; }
}

/* ---------------------------------------------------------------- odkazy */

#ln-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + var(--gap))
           calc(env(safe-area-inset-right) + var(--gap))
           calc(env(safe-area-inset-bottom) + var(--gap))
           calc(env(safe-area-inset-left) + var(--gap));
}
#ln-overlay[hidden] { display: none; }
#ln-grid {
  display: grid;
  grid-template-columns: repeat(2, var(--cell));
  grid-auto-rows: var(--cell);
  gap: var(--gap);
  justify-content: center;
}
@media (orientation: landscape) {
  #ln-grid { grid-template-columns: repeat(6, var(--cell)); }
}
#ln-grid .tile { grid-row: auto; grid-column: auto; -webkit-touch-callout: none; }
#ln-grid .tile.back, #ln-grid .tile.link { color: var(--fg); }
#ln-grid .tile.add { color: var(--dim); }
#ln-grid .tile.editing { border-color: var(--accent); color: var(--accent); }

#ln-form {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: calc(var(--cell) * 0.06);
  padding: calc(var(--cell) * 0.08) calc(var(--cell) * 0.1);
  background: var(--tile);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--r);
  font-size: calc(var(--cell) * 0.12);
}
#ln-form[hidden] { display: none; }
#ln-form input {
  flex: 1 1 14em;
  min-width: 0;
  font: inherit;
  color: var(--fg);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: calc(var(--cell) * 0.05);
  padding: 0.45em 0.6em;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
#ln-form input:focus { border-color: var(--accent); }
#ln-form input::placeholder { color: var(--dim); }
#ln-form .ln-buttons { display: flex; gap: calc(var(--cell) * 0.06); width: 100%; }
#ln-form button {
  font: inherit;
  font-weight: 600;
  color: var(--fg);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: calc(var(--cell) * 0.05);
  padding: 0.45em 0.9em;
}
#ln-form button:active { background: rgba(255,255,255,0.14); }
#ln-form button[type="submit"] { background: var(--accent); color: #000; border-color: transparent; }
#ln-form button[hidden] { display: none; }

/* ---------------------------------------------------------------- Ono (asistent) */

#ono-header-row { display: flex; align-items: center; gap: calc(var(--cell) * 0.08); }
#ono-status { flex: 1; color: var(--dim); font-size: calc(var(--cell) * 0.12); }
#ono-mute, #ono-mic, #ono-send {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  color: var(--dim);
  padding: 0;
  cursor: pointer;
}
#ono-mute { width: calc(var(--cell) * 0.3); height: calc(var(--cell) * 0.3); }
#ono-mute svg { width: 70%; height: 70%; }
#ono-mute.off { color: var(--accent); }

#ono-chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: calc(var(--cell) * 0.05);
  padding: calc(var(--cell) * 0.08) calc(var(--cell) * 0.1);
  -webkit-user-select: text;
  user-select: text;
}
.ono-msg {
  max-width: 82%;
  padding: calc(var(--cell) * 0.05) calc(var(--cell) * 0.08);
  border-radius: calc(var(--cell) * 0.08);
  font-size: calc(var(--cell) * 0.135);
  line-height: 1.3;
  white-space: pre-wrap;
}
.ono-msg.user { align-self: flex-end; background: #2a2a2a; color: var(--fg); border-bottom-right-radius: calc(var(--cell) * 0.02); }
.ono-msg.ono { align-self: flex-start; background: rgba(255,138,0,0.12); color: var(--fg); border-bottom-left-radius: calc(var(--cell) * 0.02); }
.ono-chip, .ono-note {
  align-self: center;
  font-size: calc(var(--cell) * 0.1);
  color: var(--dim);
}
.ono-chip { border: 1px solid rgba(255,255,255,0.08); border-radius: 999px; padding: 0.15em 0.7em; }
.ono-chip.err { color: var(--accent); border-color: rgba(255,138,0,0.3); }
.ono-confirm {
  align-self: flex-start;
  font: inherit;
  font-weight: 600;
  font-size: calc(var(--cell) * 0.14);
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: calc(var(--cell) * 0.06);
  padding: calc(var(--cell) * 0.06) calc(var(--cell) * 0.12);
  cursor: pointer;
}
.ono-confirm:disabled { background: var(--faint); color: var(--dim); }

#ono-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: calc(var(--cell) * 0.06);
  padding: calc(var(--cell) * 0.06) calc(var(--cell) * 0.08);
  border-top: 1px solid rgba(255,255,255,0.05);
}
#ono-mic {
  --lvl: 0;
  width: calc(var(--cell) * 0.42);
  height: calc(var(--cell) * 0.42);
  border-radius: 50%;
  background: var(--faint);
  color: var(--fg);
  transition: background 0.2s, box-shadow 0.08s;
}
#ono-mic svg { width: 50%; height: 50%; }
#ono-mic.on {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 0 calc(var(--lvl) * var(--cell) * 0.06) rgba(255,138,0,0.35);
}
#ono-overlay.speaking #ono-mic.on { background: var(--fg); }
#ono-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: calc(var(--cell) * 0.14);
  background: rgba(255,255,255,0.04);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: calc(var(--cell) * 0.06);
  padding: calc(var(--cell) * 0.05) calc(var(--cell) * 0.07);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
#ono-input::placeholder { color: var(--dim); opacity: 0.5; }
#ono-send { width: calc(var(--cell) * 0.3); height: calc(var(--cell) * 0.3); }
#ono-send svg { width: 75%; height: 75%; }

/* ---------------------------------------------------------------- barevná žárovka */

@keyframes disco { 0% { color: #f00; background-color: #f00; } 17% { color: #ff0; background-color: #ff0; } 33% { color: #0f0; background-color: #0f0; }
  50% { color: #0ff; background-color: #0ff; } 67% { color: #00f; background-color: #00f; } 83% { color: #f0f; background-color: #f0f; } 100% { color: #f00; background-color: #f00; } }
.tile.light svg.disco { animation: disco 3s linear infinite; background-color: transparent !important; }
.tile.light svg { transition: color 0.6s; }

#lt-content { overflow-y: auto; }
#lt-stats {
  display: flex; gap: 0.6em; align-items: center;
  padding: calc(var(--cell) * 0.07) calc(var(--cell) * 0.1) calc(var(--cell) * 0.04);
  flex-shrink: 0;
}
#lt-lamp {
  width: calc(var(--cell) * 0.3); height: calc(var(--cell) * 0.3); border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 calc(var(--cell) * 0.15) currentColor;
  transition: background 0.6s;
}
#lt-lamp.off { background: var(--faint); box-shadow: none; }
#lt-lamp.disco { animation: disco 3s linear infinite; }
#lt-state { font-size: calc(var(--cell) * 0.3); font-weight: 700; color: var(--fg); line-height: 1; }
#lt-state.idle { color: var(--dim); }
#lt-power-w { font-size: calc(var(--cell) * 0.13); color: var(--dim); flex: 1; }
#lt-content button {
  font: inherit; font-weight: 600; color: var(--fg);
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.08);
  border-radius: calc(var(--cell) * 0.05); cursor: pointer;
}
#lt-content button:active { background: rgba(255,255,255,0.14); }
#lt-content button:disabled { opacity: 0.3; cursor: default; }
#lt-power { font-size: calc(var(--cell) * 0.12); padding: 0.5em 1em; }
#lt-modes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--cell) * 0.55), 1fr)); gap: calc(var(--cell) * 0.05);
  padding: calc(var(--cell) * 0.04) calc(var(--cell) * 0.1);
}
#lt-modes button { font-size: calc(var(--cell) * 0.12); padding: 0.7em 0.3em; display: flex; flex-direction: column; align-items: center; gap: 0.2em; }
#lt-modes button i { font-style: normal; font-weight: 400; font-size: 0.7em; color: var(--dim); }
#lt-modes button.sel { background: var(--fg); color: #000; }
#lt-modes button.sel.idle { background: transparent; color: var(--fg); border: 2px solid var(--fg); }
#lt-modes button.sel i { color: #444; }
#lt-modes button:disabled { opacity: 0.35; }
#lt-info { padding: 0 calc(var(--cell) * 0.1); font-size: calc(var(--cell) * 0.1); color: var(--dim); min-height: 1.2em; }
.lt-row {
  display: flex; align-items: center; gap: calc(var(--cell) * 0.06);
  padding: calc(var(--cell) * 0.05) calc(var(--cell) * 0.1);
  font-size: calc(var(--cell) * 0.12); color: var(--dim);
}
.lt-row > span { width: 2.6em; flex-shrink: 0; }
#lt-colors, #lt-whites { display: flex; flex-wrap: wrap; gap: calc(var(--cell) * 0.04); }
#lt-colors button { width: calc(var(--cell) * 0.2); height: calc(var(--cell) * 0.2); border-radius: 50%; }
#lt-whites button { color: #000; font-size: calc(var(--cell) * 0.1); padding: 0.6em 0.7em; }
#lt-colors button.sel, #lt-whites button.sel { outline: 3px solid var(--fg); outline-offset: 2px; }
#lt-bright { flex: 1; accent-color: var(--fg); }
#lt-bright-v { color: var(--fg); font-weight: 600; width: 3em; text-align: right; }
