:root {
  --bg: #131a2a; --card: #1c2538; --text: #e8ecf5; --muted: #9aa6bd; --line: #3a4763;
  --accent: #f2b84b; --blue: #7fb2ff; --past: #4a5a7d; --window: #2a3550; --on-accent: #131a2a;
}
body.day {
  --bg: #dfe8f3; --card: #ffffff; --text: #172033; --muted: #4f5b73; --line: #aebbd0;
  --accent: #8a5200; --blue: #1c56ad; --past: #9aa9c2; --window: #c5d6ec; --on-accent: #ffffff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 650; letter-spacing: -0.01em; }
h2 { margin: 28px 0 8px; font-size: 17px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }

main { margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
main.home { max-width: 460px; display: flex; flex-direction: column; gap: 16px; }
main.narrow { max-width: 420px; }
main.narrow h1 { margin-bottom: 12px; }

.top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; }
.brand { font-weight: 650; font-size: 15px; color: var(--text); }
.sub { margin: 6px 0 0; }
.notice { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--accent); font-size: 14px; }
main.narrow .notice { margin-bottom: 16px; }

.totals { display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap; }
.totals div { display: flex; flex-direction: column; gap: 2px; }
.totals strong { font-size: 34px; line-height: 1; font-weight: 650; }
.totals .small strong { font-size: 20px; color: var(--accent); }
.totals span { font-size: 12px; color: var(--muted); }

#house svg, #timeline svg { display: block; width: 100%; height: auto; }
.card { background: var(--card); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; }
.card-head .now { color: var(--accent); }
.card small { font-size: 12px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile.wide { grid-column: 1 / -1; }
.tile.alert { outline: 2px solid var(--accent); }
.tile span { font-size: 12px; color: var(--muted); }
.tile strong { font-size: 20px; font-weight: 650; line-height: 1.2; }
.tile.wide strong { font-size: 22px; }

.cams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cams h2 { grid-column: 1 / -1; margin: 8px 0 0; font-size: 13px; }
.cams .button { grid-column: 1 / -1; margin-top: 0; justify-self: start; }
.cam { margin: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.cam-open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.cam img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--window); }
.cam .noimg { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; background: var(--window); color: var(--muted); font-size: 12px; }
.cam figcaption { padding: 8px 10px; font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.cam figcaption em { font-style: normal; color: var(--accent); font-weight: 600; }

.foot { text-align: center; padding: 8px 0; font-size: 14px; }
.foot a { display: inline-block; padding: 12px 16px; }

#lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; text-align: center; }
#lightbox::backdrop { background: rgba(0, 0, 0, 0.88); }
#lightbox img { display: block; max-width: 96vw; max-height: 82vh; border-radius: 8px; cursor: zoom-out; }
#lightbox .button { margin: 12px auto 0; color: #e8ecf5; border-color: #9aa6bd; }

/* Energi */
.small { font-size: 12px; margin-top: 12px; }
.scroll { overflow-x: auto; background: var(--card); border-radius: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child { text-align: left; }
thead th { font-weight: 600; color: var(--muted); font-size: 12px; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody th { font-weight: 500; }

/* Husvyn */
.h-line { stroke: var(--text); stroke-width: 1.5; fill: var(--card); stroke-linejoin: round; }
.h-ground { stroke: var(--line); stroke-width: 2; }
.h-floor { stroke: var(--line); stroke-width: 1; }
.h-win { fill: var(--window); }
.h-win.lit { fill: var(--accent); }
.h-panel { stroke: var(--past); stroke-width: 5; stroke-linecap: round; }
.h-panel.live { stroke: var(--accent); }
.h-box { fill: var(--window); stroke: var(--muted); stroke-width: 1; }
.h-box.live { stroke: var(--accent); stroke-width: 2; }
.h-flow { fill: none; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 2 5; stroke: var(--blue); animation: flow 1.2s linear infinite; }
.h-flow.out { stroke: var(--accent); animation-direction: reverse; }
.h-flow.idle { stroke: var(--muted); animation: none; }
.h-label { font: 600 11px system-ui, sans-serif; fill: var(--text); }
.h-label.blue { fill: var(--blue); }
.h-label.accent { fill: var(--accent); }
.h-note { font: 11px system-ui, sans-serif; fill: var(--muted); }
.h-sky { fill: var(--muted); }
.h-sun { fill: var(--accent); }
.h-moon { fill: var(--text); }
.h-bg { fill: var(--bg); }
@keyframes flow { to { stroke-dashoffset: -14; } }
@media (prefers-reduced-motion: reduce) { .h-flow { animation: none; } }

/* Tidslinjen */
.t-past { fill: var(--past); }
.t-now { fill: var(--accent); }
.t-next { fill: var(--blue); }
.t-use { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linejoin: round; }
.t-axis { font: 10px system-ui, sans-serif; fill: var(--muted); }
.t-axis.now { fill: var(--accent); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.legend .l-use { height: 2px; vertical-align: 3px; background: var(--text); }

/* Formulär */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; }
.form input:not([type=checkbox]) {
  min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; width: 100%;
}
.form input[type=checkbox] { width: 20px; height: 20px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.button {
  min-height: 46px; padding: 0 20px; border: 0; border-radius: 23px; background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 600; cursor: pointer; align-self: flex-start;
}
.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); margin-top: 24px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.status { padding-left: 18px; margin: 0; }
.status li { margin-bottom: 6px; }
pre { background: var(--card); padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 13px; margin: 0; }
