/* Svitlo — app dashboard. Uses only tokens.css variables. */

:root {
  --accent-fg: var(--accent);          /* accent used as icon/stroke on surfaces */
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --glass: color-mix(in srgb, var(--bg) 78%, transparent);
}
[data-theme="light"] { --accent-fg: var(--amber-600); }

body { min-height: 100vh; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
[hidden] { display: none !important; }

.skip {
  position: fixed; left: var(--s-4); top: var(--s-4); z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  font-weight: 600; text-decoration: none; transform: translateY(-200%); transition: transform var(--t-fast) var(--ease);
}
.skip:focus { transform: none; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s-6);
  padding: var(--s-5) var(--s-4); border-right: 1px solid var(--border); background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: var(--s-3); text-decoration: none; padding: var(--s-1) var(--s-2); min-height: 44px; border-radius: var(--r-md); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 24px var(--accent-soft);
}
.brand-mark .ic { width: 20px; height: 20px; stroke-width: 2; }
.brand-name { font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 0 var(--s-3);
  border-radius: var(--r-md); text-decoration: none; color: var(--text-muted); font-weight: 500; font-size: var(--fs-sm);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link:active { transform: scale(0.99); }
.nav-link[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.nav-link[aria-current="page"] .ic { color: var(--accent-fg); }

.side-foot { margin-top: auto; }
.addr {
  position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.addr:hover { border-color: var(--border-strong); }
.addr:focus-within { box-shadow: var(--focus); border-color: var(--accent); }
.addr-icon { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); flex: none; }
.addr-icon .ic { width: 18px; height: 18px; }
.addr-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: var(--lh-snug); }
.addr-label { font-size: var(--fs-xs); color: var(--text-muted); }
.addr-value { font-size: var(--fs-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.addr-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; }
.addr-select:focus-visible { box-shadow: none; }
.addr-chev { color: var(--text-muted); width: 16px; height: 16px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--gutter); background: var(--glass); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand-mobile, .addr-mobile { display: none; }
.search {
  position: relative; display: flex; align-items: center; flex: 1; max-width: 420px; height: 40px;
  border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); padding: 0 var(--s-3);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.search:hover { border-color: var(--border-strong); }
.search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.search > .ic { color: var(--text-muted); width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; padding: 0 var(--s-2); font-size: var(--fs-sm); }
.search input::placeholder { color: var(--text-muted); }
.search input:focus-visible { box-shadow: none; }
.search input::-webkit-calendar-picker-indicator { display: none !important; }
kbd { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 6px; line-height: 20px; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-1); }
.icon-btn {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--r-full);
  background: transparent; color: var(--text-muted); transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { border-radius: var(--r-full); }
.icon-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.icon-btn-sm .ic { width: 16px; height: 16px; }
.dot-badge { position: absolute; top: 11px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.ic-moon { display: none; }
[data-theme="light"] .ic-sun { display: none; }
[data-theme="light"] .ic-moon { display: block; }
.avatar {
  width: 36px; height: 36px; margin-left: var(--s-2); border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700;
  background: linear-gradient(135deg, var(--amber-300), var(--amber-600)); color: var(--accent-ink);
}

.pop { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: var(--s-2); animation: pop-in var(--t-med) var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-3); }
.pop-head h2 { font-size: var(--fs-sm); font-weight: 600; }
.notif { display: flex; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-md); }
.notif:hover { background: var(--surface-2); }
.notif p { font-size: var(--fs-sm); line-height: var(--lh-snug); }
.notif span { font-size: var(--fs-xs); color: var(--text-muted); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: transparent; }
.notif.is-unread .notif-dot { background: var(--accent); }
.notif.is-unread p { font-weight: 600; }

.link-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-2); border: 0; background: none;
  color: var(--text); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; border-radius: var(--r-sm);
  text-decoration-line: underline; text-decoration-color: transparent; text-underline-offset: 3px;
  transition: text-decoration-color var(--t-fast) var(--ease), opacity var(--t-fast);
}
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn:disabled { color: var(--text-muted); cursor: not-allowed; text-decoration: none; }

/* ---------- content ---------- */
.content { width: 100%; max-width: 1320px; margin: 0 auto; padding: var(--s-8) var(--gutter) var(--s-16); }
.view { animation: view-in var(--t-med) var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.view-head h1 { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.025em; line-height: var(--lh-tight); }
.view-head h1:focus { outline: none; box-shadow: none; }
.eyebrow { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--s-2); }
.live-pill {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3); border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--on); box-shadow: 0 0 0 0 var(--on); animation: live 2s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--on) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-6); box-shadow: var(--shadow-1);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.card-title { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; line-height: var(--lh-snug); }
.card-sub { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; line-height: var(--lh-snug); }

.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: var(--s-5); align-items: start; }
.ov-main, .ov-side { display: grid; gap: var(--s-5); min-width: 0; }

/* ---------- hero ---------- */
.hero { --hc: var(--on); overflow: hidden; padding: var(--s-8); min-height: 280px; display: flex; flex-direction: column; gap: var(--s-6); border-color: var(--border-strong); }
.hero[data-state="off"] { --hc: var(--off); }
.hero[data-state="maybe"] { --hc: var(--maybe); }
.hero-glow {
  position: absolute; inset: 0; pointer-events: none; transition: opacity var(--t-slow) var(--ease);
  background:
    radial-gradient(60% 90% at 88% 0%, var(--accent-soft), transparent 70%),
    radial-gradient(40% 60% at 100% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
}
.hero[data-state="off"] .hero-glow { background: radial-gradient(60% 90% at 88% 0%, color-mix(in srgb, var(--off) 14%, transparent), transparent 70%); }
.hero[data-state="maybe"] .hero-glow { background: radial-gradient(60% 90% at 88% 0%, color-mix(in srgb, var(--maybe) 14%, transparent), transparent 70%); }
.hero > *:not(.hero-glow) { position: relative; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.status-chip {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 30px; padding: 0 var(--s-3); border-radius: var(--r-full);
  background: color-mix(in srgb, var(--hc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--hc) 30%, transparent);
  font-size: var(--fs-xs); font-weight: 600;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hc); box-shadow: 0 0 10px var(--hc); }
.hero-addr { font-size: var(--fs-sm); color: var(--text-muted); }
.hero-body { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-6); flex-wrap: wrap; margin-top: auto; }
.hero-state { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.04em; line-height: var(--lh-tight); }
.hero-sub { margin-top: var(--s-3); color: var(--text-muted); font-size: var(--fs-md); }
.countdown { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-1); }
.cd-label { font-size: var(--fs-sm); color: var(--text-muted); }
.cd-value { font-family: var(--mono); font-size: var(--fs-2xl); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1; }
.hero-progress { height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.hero-progress span { display: block; height: 100%; background: var(--hc); transform-origin: left; transform: scaleX(0); transition: transform 1s linear; border-radius: inherit; }
.hero-foot { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.hf-item {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 28px; padding: 0 var(--s-3); border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border); font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-muted);
}
.hf-item.is-now { color: var(--text); border-color: var(--border-strong); }
.hf-sep { opacity: 0.6; }

/* ---------- legend / status swatches ---------- */
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg-on { background: var(--on); }
.lg-off { background: var(--off); }
.lg-maybe { background: var(--maybe); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: var(--fs-xs); color: var(--text-muted); }
.legend li { display: inline-flex; align-items: center; gap: var(--s-2); }

/* ---------- segmented ---------- */
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.seg-btn {
  min-height: 38px; padding: 0 var(--s-4); border: 0; border-radius: var(--r-full); background: none; color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: 500; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }
.seg-btn:focus-visible { border-radius: var(--r-full); }

/* ---------- ring ---------- */
.ring-wrap { display: flex; gap: var(--s-8); align-items: center; }
.ring-box { position: relative; width: 260px; flex: none; }
.ring { width: 100%; height: auto; overflow: visible; }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 20; }
.ring-tick { stroke: var(--border-strong); stroke-width: 1.5; stroke-linecap: round; }
.ring-tick.major { stroke: var(--text-muted); }
.ring-label { fill: var(--text-muted); font-family: var(--mono); font-size: 10px; }
.ring-seg { fill: none; stroke-width: 20; cursor: pointer; outline: none; transition: stroke-width var(--t-fast) var(--ease), filter var(--t-fast) var(--ease); }
.ring-seg.s-on { stroke: var(--on); }
.ring-seg.s-off { stroke: var(--off); }
.ring-seg.s-maybe { stroke: var(--maybe); }
.ring-seg:hover, .ring-seg.is-hl { stroke-width: 26; }
.ring-seg:focus-visible { stroke-width: 26; box-shadow: none; filter: drop-shadow(0 0 0 var(--accent)) drop-shadow(0 0 4px var(--accent)); }
.ring-past { fill: none; stroke: var(--surface); stroke-width: 27; opacity: 0.55; pointer-events: none; }
.now-mark line { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.now-mark circle { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.rc-time { font-family: var(--mono); font-size: var(--fs-xl); font-weight: 500; font-variant-numeric: tabular-nums; }
.rc-label { font-size: var(--fs-xs); color: var(--text-muted); }
.ring-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.intervals { display: flex; flex-direction: column; gap: 2px; }
.iv {
  display: grid; grid-template-columns: 10px 96px 1fr auto; align-items: center; gap: var(--s-3);
  min-height: 40px; padding: 0 var(--s-3); border-radius: var(--r-sm); font-size: var(--fs-sm); transition: background var(--t-fast) var(--ease);
}
.iv:hover, .iv.is-hl { background: var(--surface-2); }
.iv.is-now { background: var(--surface-3); }
.iv.is-past { color: var(--text-muted); }
.iv.is-past .lg { opacity: 0.4; }
.iv-time { font-family: var(--mono); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.iv-dur { color: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.badge { display: inline-block; margin-left: var(--s-1); padding: 0 6px; border-radius: var(--r-full); background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; line-height: 18px; vertical-align: 1px; }

/* ---------- tooltip ---------- */
.tip {
  position: absolute; z-index: 5; transform: translate(-50%, calc(-100% - 10px)); pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  background: var(--text); color: var(--bg); font-size: var(--fs-xs); white-space: nowrap; box-shadow: var(--shadow-2);
  animation: tip-in var(--t-fast) var(--ease);
}
.tip strong { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.tip span { display: flex; align-items: center; gap: 6px; }
@keyframes tip-in { from { opacity: 0; } }

/* ---------- charts ---------- */
.chart-box { position: relative; }
.week-chart { width: 100%; height: auto; overflow: visible; }
.week-chart .grid { stroke: var(--border); stroke-width: 1; }
.week-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.week-chart .tick { fill: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.week-chart .val { fill: var(--text); font-family: var(--mono); font-size: 11px; font-weight: 500; }
.bar { cursor: default; outline: none; }
.bar .hit { fill: transparent; rx: 8; transition: fill var(--t-fast) var(--ease); }
.bar:hover .hit { fill: var(--surface-2); }
.bar:focus-visible { box-shadow: none; }
.bar:focus-visible .hit { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.b-off { fill: var(--off); }
.b-maybe { fill: var(--maybe); }
.bar.is-today .day { fill: var(--text); font-weight: 600; }
.band-off { fill: color-mix(in srgb, var(--off) 10%, transparent); }
.area { fill: color-mix(in srgb, var(--battery) 18%, transparent); }
.line { fill: none; stroke: var(--battery); stroke-width: 2; stroke-linejoin: round; }
.now-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }

/* ---------- battery ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 var(--s-3); border-radius: var(--r-full); flex: none;
  font-size: var(--fs-xs); font-weight: 600; background: var(--surface-3);
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--on); }
.tag[data-mode="off"]::before { background: var(--battery); }
.bat-row { display: flex; align-items: center; gap: var(--s-5); margin-bottom: var(--s-5); }
.bat-gauge { position: relative; flex: 1; height: 56px; padding: 4px; border: 2px solid var(--border-strong); border-radius: 14px; margin-right: 8px; }
.bat-gauge-lg { height: 80px; border-radius: 18px; }
.bat-cap { position: absolute; right: -9px; top: 50%; width: 5px; height: 40%; transform: translateY(-50%); border-radius: 0 3px 3px 0; background: var(--border-strong); }
.bat-fill {
  position: relative; height: 100%; width: 0; border-radius: 9px; overflow: hidden;
  background: linear-gradient(90deg, color-mix(in srgb, var(--battery) 70%, var(--surface)), var(--battery));
  transition: width 1.2s var(--ease);
}
.bat-fill::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  animation: sheen 3.2s 1.4s infinite var(--ease);
}
@keyframes sheen { 60%, 100% { transform: translateX(100%); } }
.bat-num { display: flex; align-items: baseline; }
.bat-pct { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.bat-pct-unit { font-size: var(--fs-xl); color: var(--text-muted); font-weight: 600; margin-left: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); padding: var(--s-4) 0; border-block: 1px solid var(--border); }
.stats dt { font-size: var(--fs-xs); color: var(--text-muted); }
.stats dd { font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; border-radius: var(--r-sm); }
.bat-note { margin-top: var(--s-4); font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-snug); padding-left: var(--s-4); position: relative; }
.bat-note::before { content: ""; position: absolute; left: 0; top: 0.45em; width: 6px; height: 6px; border-radius: 50%; background: var(--on); }
.bat-note[data-warn="true"] { color: var(--text); }
.bat-note[data-warn="true"]::before { background: var(--off); }
.pulse { animation: pulse 700ms var(--ease); }
@keyframes pulse { 0% { background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 4px transparent; } }

/* ---------- switch ---------- */
.switch {
  position: relative; width: 52px; height: 44px; flex: none; border: 0; background: none; padding: 0; border-radius: var(--r-full);
}
.switch::before {
  content: ""; position: absolute; left: 6px; top: 10px; width: 40px; height: 24px; border-radius: var(--r-full);
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-strong); transition: background var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
.switch::after {
  content: ""; position: absolute; left: 9px; top: 13px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-muted); box-shadow: var(--shadow-1); transition: transform var(--t-med) var(--ease), background var(--t-med) var(--ease);
}
.switch:hover::before { box-shadow: inset 0 0 0 1px var(--text-muted); }
.switch[aria-checked="true"]::before { background: var(--accent); box-shadow: none; }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--accent-ink); }
.switch:active::after { width: 22px; }
.switch[aria-checked="true"]:active::after { transform: translateX(12px); }
.switch:focus-visible { box-shadow: none; }
.switch:focus-visible::before { box-shadow: var(--focus); }
.switch:disabled { cursor: not-allowed; opacity: 0.45; }
.switch:disabled:hover::before { box-shadow: inset 0 0 0 1px var(--border-strong); }

/* ---------- devices (overview list) ---------- */
.dev-list { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--s-2)); }
.dev { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-1) var(--s-2); border-radius: var(--r-md); transition: background var(--t-fast) var(--ease); }
.dev:hover { background: var(--surface-2); }
.dev-ic { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface-2); color: var(--text-muted); flex: none; transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease); }
.dev:hover .dev-ic { background: var(--surface-3); }
.dev:has([aria-checked="true"]) .dev-ic { background: var(--accent-soft); color: var(--accent-fg); }
.dev-ic .ic { width: 18px; height: 18px; }
.dev-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: var(--lh-snug); }
.dev-name { font-size: var(--fs-sm); font-weight: 500; }
.dev-w { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev.is-disabled .dev-name { color: var(--text-muted); }

/* ---------- tips ---------- */
.tips { display: flex; flex-direction: column; gap: var(--s-2); }
.tip-card {
  display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-2) var(--s-3) var(--s-3); border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), height var(--t-med) var(--ease), padding var(--t-med) var(--ease), margin var(--t-med) var(--ease);
}
.tip-card.is-accent { background: linear-gradient(135deg, var(--accent-soft), transparent 80%), var(--surface-2); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.tip-card.is-leaving { opacity: 0; transform: translateX(24px); height: 0 !important; padding-block: 0; margin-bottom: calc(-1 * var(--s-2)); border-width: 0; }
.tip-ic { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-3); color: var(--text-muted); flex: none; margin-top: 2px; }
.is-accent .tip-ic { background: var(--accent); color: var(--accent-ink); }
.tip-ic .ic { width: 16px; height: 16px; }
.tip-txt { flex: 1; min-width: 0; padding-top: 2px; }
.tip-title { font-size: var(--fs-sm); font-weight: 600; line-height: var(--lh-snug); }
.tip-body { font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-snug); margin-top: 2px; }
.tip-card .icon-btn { margin: -6px 0 -6px 0; }
.empty { font-size: var(--fs-sm); color: var(--text-muted); padding: var(--s-4); text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--r-md); }

/* ---------- schedule grid ---------- */
.week-scroll { overflow-x: auto; margin: 0 calc(-1 * var(--s-2)); padding: var(--s-2); border-radius: var(--r-md); }
.week-grid { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 760px; table-layout: fixed; }
.week-grid th { font-weight: 500; font-size: var(--fs-xs); color: var(--text-muted); }
.week-grid .g-h { font-family: var(--mono); text-align: left; padding-bottom: var(--s-1); font-weight: 400; }
.week-grid .g-day { width: 64px; text-align: left; white-space: nowrap; font-size: var(--fs-sm); color: var(--text); padding-right: var(--s-2); }
.g-date { color: var(--text-muted); font-family: var(--mono); font-size: var(--fs-xs); }
.week-grid .g-tot { width: 44px; text-align: right; font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-muted); }
.c { height: 36px; border-radius: 5px; transition: transform var(--t-fast) var(--ease), filter var(--t-fast); }
.c:hover { transform: scaleY(1.12); filter: brightness(1.15); }
.c-on { background: color-mix(in srgb, var(--on) 32%, transparent); }
.c-maybe { background: color-mix(in srgb, var(--maybe) 55%, transparent); }
.c-off { background: var(--off); }
.week-grid tr.is-past td.c { opacity: 0.45; }
.week-grid tr.is-today .g-day { font-weight: 700; }
.week-grid tr.is-today .g-day::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 2px; }
.c.is-now { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.grid-note { margin-top: var(--s-4); max-width: 70ch; }

/* ---------- device cards ---------- */
.dev-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-4); }
.dev-card { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-5); transition: border-color var(--t-med) var(--ease), transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease); }
.dev-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.dev-card.is-on { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.dev-card.is-on .dev-ic { background: var(--accent-soft); color: var(--accent-fg); }
.dev-card.is-disabled { border-style: dashed; box-shadow: none; }
.dev-card.is-disabled:hover { transform: none; box-shadow: none; }
.dc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s-2); }
.dev-ic-lg { width: 44px; height: 44px; }
.dev-ic-lg .ic { width: 22px; height: 22px; }
.dc-name { font-size: var(--fs-md); font-weight: 600; }
.dc-note { font-size: var(--fs-sm); color: var(--text-muted); }
.dc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--border); }
.dc-stats dt { font-size: var(--fs-xs); color: var(--text-muted); }
.dc-stats dd { font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- battery view ---------- */
.bat-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s-5); }
.bat-grid > :nth-child(2) { grid-column: 1 / -1; order: 3; }
.bat-big .bat-pct { font-size: var(--fs-display); }
.bat-big .field { margin-top: var(--s-5); }
.kv > div { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.field label, .field-row label { font-size: var(--fs-sm); font-weight: 500; }
.field-row { display: flex; justify-content: space-between; align-items: center; }
.field-row output { font-family: var(--mono); font-size: var(--fs-sm); }
.hint { display: block; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 400; line-height: var(--lh-snug); }
.hint:empty, .form-err:empty { display: none; }
.form-err { font-size: var(--fs-sm); color: var(--text); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: color-mix(in srgb, var(--off) 14%, transparent); border: 1px solid color-mix(in srgb, var(--off) 40%, transparent); margin-bottom: var(--s-4); }
#cap-err:not(:empty) { color: var(--text); }
.input {
  width: 100%; min-height: 44px; padding: 0 var(--s-3); border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface-2); font-size: var(--fs-sm); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input:hover { border-color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input[aria-invalid] { border-color: var(--off); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }
.input::placeholder { color: var(--text-muted); }
select.input {
  appearance: none; padding-right: var(--s-10); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
select option { background: var(--surface); color: var(--text); }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 44px; margin: 0; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; font-size: var(--fs-sm); cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-5);
  border-radius: var(--r-full); border: 1px solid transparent; font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { border-radius: var(--r-full); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .ic { width: 18px; height: 18px; stroke-width: 2.2; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px var(--accent-soft); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s-3); flex-wrap: wrap; }

.settings { max-width: 720px; padding: var(--s-2) var(--s-6) var(--s-6); }
.settings fieldset { border: 0; margin: 0; padding: var(--s-5) 0; border-bottom: 1px solid var(--border); min-width: 0; }
.settings legend { float: left; width: 100%; padding: 0; margin-bottom: var(--s-4); font-size: var(--fs-md); font-weight: 600; }
.settings legend + * { clear: both; }
.settings .form-actions { padding-top: var(--s-5); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: 52px; font-size: var(--fs-sm); font-weight: 500; }
.switch-row .hint { margin-top: 2px; }
.switch-row + .field { margin-top: var(--s-4); }
.radio-row { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.radio {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4) 0 var(--s-3); border-radius: var(--r-md);
  border: 1px solid var(--border-strong); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
}
.radio:hover { background: var(--surface-2); }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio:has(input:focus-visible) { box-shadow: var(--focus); }
.radio input:focus-visible { box-shadow: none; }

/* ---------- modal ---------- */
.modal {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: var(--s-6); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2);
}
.modal[open] { animation: modal-in var(--t-med) var(--ease); }
.modal::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin: calc(-1 * var(--s-2)) calc(-1 * var(--s-2)) var(--s-4) 0; }
.modal-head h2 { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.02em; }
.modal .form-actions { margin-top: var(--s-4); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: var(--s-6); z-index: 60; display: flex; align-items: center; gap: var(--s-4);
  min-height: 48px; padding: 0 var(--s-2) 0 var(--s-5); border-radius: var(--r-full); background: var(--text); color: var(--bg);
  font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--shadow-2); max-width: calc(100vw - 32px);
  transform: translate(-50%, 16px); opacity: 0; transition: transform var(--t-med) var(--ease), opacity var(--t-med) var(--ease);
}
.toast.is-in { transform: translate(-50%, 0); opacity: 1; }
.toast:not(:has(.link-btn:not([hidden]))) { padding-right: var(--s-5); }
.toast .link-btn { color: inherit; text-decoration-color: currentColor; padding: 0 var(--s-3); }
.toast .link-btn:focus-visible { box-shadow: 0 0 0 3px var(--accent); }

/* ---------- skeleton ---------- */
.skeleton { display: none; }
.is-loading .skeleton { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: var(--s-5); }
.sk-col { display: grid; gap: var(--s-5); align-content: start; }
.sk {
  border-radius: var(--r-lg); border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 30%, var(--surface-3) 50%, var(--surface) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.2s infinite linear;
}
.sk-hero { height: 280px; margin-top: 76px; }
.sk-ring { height: 340px; }
.sk-bat { height: 260px; margin-top: 76px; }
.sk-dev { height: 420px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- tab bar (mobile) ---------- */
.tabbar { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .ov-grid, .is-loading .skeleton { grid-template-columns: minmax(0, 1fr); }
  .ov-side { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
  .sk-bat { margin-top: 0; }
}
@media (max-width: 1023px) {
  :root { --sidebar-w: 76px; }
  .sidebar { padding-inline: var(--s-3); align-items: center; }
  .brand-name, .nav-link span, .side-foot { display: none; }
  .nav-link { width: 48px; justify-content: center; padding: 0; }
  .addr-mobile { display: flex; max-width: 300px; min-height: 44px; padding: var(--s-1) var(--s-2); }
  .addr-mobile .addr-value { -webkit-line-clamp: 1; }
  .addr-mobile .addr-icon { width: 28px; height: 28px; }
  .search { max-width: 280px; }
  .bat-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  :root { --topbar-h: 60px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .search, .avatar { display: none; }
  .brand-mobile { display: inline-flex; padding: 0; margin-right: calc(-1 * var(--s-1)); }
  .topbar { gap: var(--s-2); padding: 0 var(--s-4); }
  .addr-mobile { flex: 1; min-width: 0; max-width: none; border-color: transparent; background: transparent; padding-inline: var(--s-1); }
  .addr-mobile .addr-icon { display: none; }
  .content { padding: var(--s-5) var(--s-4) calc(96px + env(safe-area-inset-bottom)); }
  .view-head { margin-bottom: var(--s-5); align-items: flex-start; }
  .card { padding: var(--s-5); }
  .hero { padding: var(--s-5); min-height: 0; gap: var(--s-5); }
  .hero-addr { display: none; }
  .hero-body { flex-direction: column; align-items: flex-start; gap: var(--s-4); }
  .countdown { align-items: flex-start; }
  .ov-side { grid-template-columns: minmax(0, 1fr); }
  .card-head { flex-wrap: wrap; }
  .ring-wrap { flex-direction: column; gap: var(--s-5); align-items: stretch; }
  .ring-box { width: min(260px, 100%); margin: 0 auto; }
  .iv { grid-template-columns: 10px 88px 1fr auto; padding: 0 var(--s-2); }
  .stats dd { font-size: var(--fs-md); }
  .dev-cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-3); }
  .dev-card { padding: var(--s-4); }
  .dc-stats { grid-template-columns: 1fr; gap: var(--s-1); }
  .settings { padding: 0 var(--s-5) var(--s-5); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .is-loading .skeleton .sk-col:last-child { display: none; }
  .sk-hero { margin-top: 64px; height: 300px; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: var(--s-1) var(--s-2) calc(var(--s-1) + env(safe-area-inset-bottom));
    background: var(--glass); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--border);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px;
    text-decoration: none; color: var(--text-muted); font-size: 11px; font-weight: 500; border-radius: var(--r-md);
    transition: color var(--t-fast) var(--ease);
  }
  .tab .ic { width: 22px; height: 22px; transition: transform var(--t-fast) var(--ease); }
  .tab:active .ic { transform: scale(0.9); }
  .tab[aria-current="page"] { color: var(--text); }
  .tab[aria-current="page"] .ic { color: var(--accent-fg); }
}
@media (max-width: 359px) {
  .dev-cards { grid-template-columns: minmax(0, 1fr); }
  .seg-btn { padding: 0 var(--s-3); }
}
