:root {
  --bg: #f3f5f4; --card: #fff; --text: #17201d; --muted: #66726d; --line: #e2e7e4;
  --brand: #0e3a2f; --accent: #2f8f6b; --accent-ink: #fff;
  --ok: #1f8a4c; --warn: #b7791f; --err: #c0392b;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --card: #19201d; --text: #e7ece9; --muted: #95a29c; --line: #2a3430;
    --brand: #0b2a22; --accent: #4fb88f; --accent-ink: #06140f;
    --ok: #4cc27c; --warn: #e0a64a; --err: #ef6b5b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

.top { background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; gap: 1rem; flex-wrap: wrap; }
.top a, .top .link { color: #d7efe5; }
.brand { font-weight: 700; font-size: 1.15rem; color: #fff !important; }
.top nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.narrow { max-width: 560px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; overflow-x: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid .card { margin-bottom: 0; }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.row-head h1, .row-head h2 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

.tile { color: inherit; display: block; text-decoration: none !important; transition: border-color .15s; }
.tile:hover { border-color: var(--accent); }
.tile-head { display: flex; justify-content: space-between; gap: .5rem; }
.render { width: 140px; height: auto; object-fit: contain; margin: -.5rem -.5rem 0 0; }
.stats { display: flex; gap: 1.5rem; margin: .75rem 0; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 1.35rem; }
.stats span { color: var(--muted); font-size: .8rem; }
.next { border-top: 1px solid var(--line); padding-top: .6rem; font-size: .9rem; }
.soon { opacity: .6; }
.empty { text-align: center; padding: 2rem; }
.big { font-size: 2rem; font-weight: 700; margin: 0 0 .5rem; }
.hours { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; }
.hours div { min-width: 38px; text-align: center; background: var(--bg); border-radius: 8px; padding: .3rem 0; display: flex; flex-direction: column; font-size: .85rem; }
.hours span { color: var(--muted); font-size: .75rem; }
.hours i { font-style: normal; font-size: .7rem; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

label { display: block; margin-bottom: .85rem; font-weight: 500; font-size: .9rem; }
input, select { display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: var(--bg); color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { display: inline; width: auto; margin: 0 .4rem 0 0; }
label small { display: block; font-weight: 400; margin-top: .2rem; }
label.check { font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 1rem; padding: .75rem 1rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }
.controls .two, .controls { margin-bottom: .5rem; }
.controls label { display: inline-block; width: 120px; margin-right: .5rem; }

.days { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip input { display: none; }
.chip span { display: inline-block; padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-weight: 500; }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.btn { display: inline-block; padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.link.danger { color: var(--err); }
form.inline { display: inline; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { color: var(--ok); border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.flash.warn { color: var(--warn); border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.flash.err { color: var(--err); border-color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
tr.disabled { opacity: .5; }
table.preview { margin: .25rem 0; }
table.preview td, table.preview th { text-align: center; padding: .3rem; }
.inline-edit input { margin: 0; padding: .3rem .5rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge.planned { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge.started { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.failed, .badge.missed { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.log .ok { color: var(--ok); } .log .err { color: var(--err); }

.auth { max-width: 400px; margin: 8vh auto 0; }
.auth h1 { font-size: 1.8rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.add-passkey { display: flex; gap: .5rem; margin-top: 1rem; }
.add-passkey input { margin: 0; }
.add-passkey .btn { white-space: nowrap; }
.live { display: inline-block; margin-top: .25rem; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; vertical-align: middle;
  background: color-mix(in srgb, #e8590c 15%, transparent); color: #e8590c; animation: pulse 2s ease-in-out infinite; }
h1 .live { margin: 0 0 0 .5rem; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .live { animation: none; } }
.live .countdown { font-variant-numeric: tabular-nums; }
.live .until { font-weight: 400; opacity: .8; }
h2.section { margin: 1.5rem 0 .75rem; }
.err-text { color: var(--err); }
.stepper { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.stepper .btn { width: 3rem; font-size: 1.3rem; padding: .3rem 0; }
.stepper div { display: flex; flex-direction: column; align-items: center; min-width: 4rem; }
.stepper b { font-size: 2rem; line-height: 1.1; }
.modes { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.modes .btn { padding: .45rem .7rem; font-size: .9rem; }
.fan select { max-width: 220px; }
.chart { width: 100%; height: 220px; display: block; }
.chart polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .t { stroke: #e8590c; }
.chart .h { stroke: #3b82f6; opacity: .6; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-x { display: flex; justify-content: space-between; }
.legend { display: flex; align-items: center; gap: .4rem; margin-bottom: .5rem; flex-wrap: wrap; }
.legend .sw { width: 14px; height: 3px; display: inline-block; border-radius: 2px; margin-left: .5rem; }
.legend .sw.t { background: #e8590c; } .legend .sw.h { background: #3b82f6; }
/* Whole tile clickable via the name link; power button sits above it */
.room-tile { position: relative; }
.room-tile h2 a { color: inherit; }
.stretched::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.room-tile .power { position: relative; z-index: 1; }
.room-tile .power .btn { padding: .4rem .9rem; }
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.live.timer { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); animation: none; }
.chart-wrap { display: grid; grid-template-columns: 2.4rem 1fr 2.6rem; gap: .4rem; }
.plot { position: relative; padding-bottom: 1.4rem; }
.y-axis { position: relative; height: 220px; color: var(--muted); }
.y-axis span { position: absolute; transform: translateY(-50%); line-height: 1; }
.y-axis.left span { right: 0; color: #e8590c; }
.y-axis.right span { left: 0; color: #3b82f6; }
.x-axis { position: absolute; left: 0; right: 0; bottom: 0; height: 1.2rem; color: var(--muted); }
.x-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.chart .grid-line.v { stroke-dasharray: 3 4; }
@media (max-width: 520px) { .x-axis span:nth-child(even) { display: none; } }
.weather .now { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.weather .big { margin: 0; line-height: 1; }
.wx-icon { font-size: 2.8rem; line-height: 1; }
.wx-meta { display: flex; gap: 1.25rem; margin: 0 0 0 auto; }
.wx-meta dt { color: var(--muted); }
.wx-meta dd { margin: 0; font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(7, minmax(64px, 1fr)); gap: .4rem; margin-top: 1rem; overflow-x: auto; }
.day { background: var(--bg); border-radius: 10px; padding: .5rem .3rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; text-align: center; }
.dname { font-size: .8rem; color: var(--muted); }
.dicon { font-size: 1.5rem; }
.precip { color: #3b82f6; min-height: 1.2em; }
.wx-loc { margin-top: .6rem; }
@media (max-width: 520px) { .wx-meta { margin-left: 0; width: 100%; } }
.stats .outside { padding-left: 1.5rem; border-left: 1px solid var(--line); }
.stats .outside b { color: var(--muted); }
