:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efeae2;
  --text: #1f1a14;
  --muted: #776d62;
  --line: #e2dbd0;
  --accent: #d9541e;
  --accent-ink: #ffffff;
  --cold: #3b7dd8;
  --ok: #2f8f5b;
  --warn: #c27c00;
  --err: #c0392b;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 16px rgba(40, 30, 20, .06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --surface: #221e19;
    --surface-2: #2c2721;
    --text: #f3ede5;
    --muted: #a99d90;
    --line: #3a332b;
    --accent: #f07a3e;
    --accent-ink: #1a120c;
    --cold: #6ea6f0;
    --ok: #5cc28a;
    --warn: #e2a640;
    --err: #f0705f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.error { color: var(--err); margin: 8px 0; }

button { font: inherit; color: inherit; }
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 550;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.wide { width: 100%; padding: 14px; font-size: 17px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 40px; height: 40px;
  border: 0; border-radius: 12px;
  background: transparent; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

input {
  font: inherit; color: var(--text);
  width: 100%; margin-top: 6px;
  padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
}
label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }

/* prihlásenie */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border-radius: 24px; padding: 28px 24px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.login-card h1 { margin-top: 12px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-logo { width: 56px; height: 56px; }

/* hlavička */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px; max-width: 1100px; margin: 0 auto;
}
.top h1 { font-size: 26px; }
.top-actions { display: flex; gap: 4px; }

.tabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 6px 16px; max-width: 1100px; margin: 0 auto;
  scrollbar-width: none;
}
.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dot.err { background: var(--err); }

.site-status { padding: 4px 16px 10px; font-size: 13px; color: var(--muted); max-width: 1100px; margin: 0 auto; }
.site-status .error { margin: 4px 0 0; }

/* miestnosti */
.rooms {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  padding: 0 16px; max-width: 1100px; margin: 0 auto;
}
.room {
  text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
}
.room:active { transform: scale(.99); }
.room-name { font-weight: 650; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-set { grid-row: span 2; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--accent); }
.room-set.cold { color: var(--cold); }
.room-set.off { color: var(--muted); font-size: 24px; }
.room-set small { font-size: 18px; font-weight: 600; }
.room-meta { font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.room.dead { opacity: .7; }
.chip {
  display: inline-block; font-size: 12px; font-weight: 650;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text);
}
.chip.manual { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.chip.boost { background: var(--accent); color: var(--accent-ink); }
.chip.vacation { background: color-mix(in srgb, var(--cold) 18%, transparent); color: var(--cold); }
.chip.err { background: color-mix(in srgb, var(--err) 16%, transparent); color: var(--err); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.valve { display: inline-flex; align-items: center; gap: 5px; }
.valve i { display: inline-block; width: 34px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.valve i b { display: block; height: 100%; background: var(--accent); }

.panel { padding: 22px 16px 8px; max-width: 1100px; margin: 0 auto; }
.panel h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.bulk-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

.skeleton { height: 76px; border-radius: var(--radius); background: var(--surface-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

/* spodný panel */
.sheet {
  border: 0; padding: 0; margin: auto auto 0;
  width: 100%; max-width: 560px; max-height: 92dvh;
  background: var(--surface); color: var(--text);
  border-radius: 24px 24px 0 0;
}
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 24px; } }
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-inner { padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sheet-head h2 { font-size: 22px; }
.sheet-head p { margin: 2px 0 0; font-size: 14px; }

.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; margin: 16px 0 6px; }
.modes button { border: 0; background: transparent; border-radius: 10px; padding: 9px 4px; font-weight: 600; font-size: 14px; cursor: pointer; }
.modes button[aria-checked="true"] { background: var(--surface); box-shadow: var(--shadow); }

.dial { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 12px 0 4px; }
.step {
  width: 60px; height: 60px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 30px; line-height: 1; cursor: pointer; user-select: none;
}
.step:active { background: var(--line); }
.temp-big { font-size: 60px; font-weight: 700; min-width: 170px; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -.03em; color: var(--accent); }
.temp-big.cold { color: var(--cold); }
.temp-big.off { color: var(--muted); }
.dial.disabled .temp-big { color: var(--muted); }
.dial.disabled .step { visibility: hidden; }
.presets { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.presets button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.hint { font-size: 13.5px; text-align: center; min-height: 1.4em; margin: 8px 0 12px; }
.vac label { margin-top: 4px; }

.program { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.program summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.day { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; margin: 7px 0; font-size: 13px; }
.day.today .day-name { color: var(--accent); font-weight: 700; }
.bar { position: relative; display: flex; height: 22px; border-radius: 6px; overflow: hidden; }
.bar span { height: 100%; font-size: 10.5px; display: grid; place-items: center; color: #fff; overflow: hidden; white-space: nowrap; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.bar .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); }
.hours { display: grid; grid-template-columns: 30px 1fr; gap: 8px; font-size: 10.5px; color: var(--muted); }
.hours div { display: flex; justify-content: space-between; }
.dev-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 14px; }
.dev-list li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dev-list li:last-child { border: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; z-index: 10; max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.toast.err { background: var(--err); color: #fff; }

/* --- doplnky: záložky, formuláre, program, správa, aplikácia --- */
body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.small { font-size: 13px; }
.app-link { display: block; text-align: center; margin-top: 16px; color: var(--muted); font-size: 14px; }
.in-app [data-hide-in-app] { display: none !important; }

.sheet-tabs { display: flex; gap: 4px; overflow-x: auto; margin: 14px 0 4px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.sheet-tabs button { border: 0; background: none; padding: 9px 12px; font-weight: 600; font-size: 15px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.sheet-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid label { margin: 8px 0; }
.form-grid .full { grid-column: 1 / -1; }
select {
  font: inherit; color: var(--text); width: 100%; margin-top: 6px;
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
}
.section-title { font-size: 15px; font-weight: 650; margin: 18px 0 2px; }
.help { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.btn.small-btn { padding: 7px 12px; font-size: 14px; }

.day-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 6px; }
.day-chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-weight: 650; cursor: pointer; }
.day-chips button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.day-chips button.dirty::after { content: " •"; color: var(--accent); }
.slot { display: grid; grid-template-columns: 80px 1fr 1fr 40px; gap: 8px; align-items: center; margin: 6px 0; }
.slot .from { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.slot input, .slot select { margin: 0; padding: 9px; }
.slot .icon-btn { width: 36px; height: 36px; }

.dev-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dev-row:last-child { border: 0; }
.dev-row .dev-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.pair-anim { width: 64px; height: 64px; margin: 18px auto; border-radius: 50%; border: 4px solid var(--surface-2); border-top-color: var(--accent); animation: spin 1s linear infinite; }

.app-card-body { display: flex; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.app-card-body p { margin: 0 0 10px; }
.app-card-body > div { min-width: 0; }
.app-card-body .btn { display: inline-block; text-decoration: none; margin-bottom: 10px; }
#apkInfo { margin: 0; overflow-wrap: anywhere; }
.qr { flex: 0 0 auto; background: #fff; padding: 8px; border-radius: 12px; line-height: 0; }
.qr img { width: 132px; height: 132px; image-rendering: pixelated; }
@media (max-width: 480px) { .qr { display: none; } }
.menu-list { display: grid; gap: 8px; margin-top: 12px; }
.menu-list .btn { text-align: left; }
code.hash { display: block; word-break: break-all; background: var(--surface-2); padding: 10px; border-radius: 10px; font-size: 13px; user-select: all; }

/* predvoľby */
.presets-bar { max-width: 1100px; margin: 0 auto; padding: 22px 16px 0; }
.presets-head { display: flex; justify-content: space-between; align-items: baseline; }
.presets-head h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px 0; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 8px; }
.preset-chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  border-radius: 14px; padding: 11px 16px; font-weight: 650; font-size: 15px; cursor: pointer; max-width: 70vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preset-chip:active { transform: scale(.97); }
.preset-chip.busy { opacity: .55; }
.preset-chip.add { color: var(--muted); border-style: dashed; box-shadow: none; }
.preset-chip .vac { color: var(--cold); }
.plist { list-style: none; padding: 0; margin: 8px 0; }
.plist li { display: flex; align-items: center; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plist li > div { flex: 1; min-width: 0; }
.plist li small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plist .icon-btn { width: 36px; height: 36px; flex: 0 0 auto; }
.item-row { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.item-row select { margin: 0; padding: 9px; font-size: 14px; }
.item-row .icon-btn { width: 36px; height: 36px; }
.check { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 15px; }
.check input { width: auto; margin: 0; }
.plan { list-style: none; padding: 0; margin: 10px 0; font-size: 14px; }
.plan li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.plan li span:last-child { font-weight: 650; }
.plan .site-h { font-weight: 650; color: var(--muted); border-bottom: 0; padding-top: 12px; }
