:root {
  --text: #f4f6fb;
  --text-dim: rgba(244, 246, 251, 0.66);
  --text-faint: rgba(244, 246, 251, 0.42);
  --glass: rgba(18, 22, 32, 0.42);
  --glass-strong: rgba(14, 17, 26, 0.78);
  --glass-hover: rgba(30, 36, 52, 0.52);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #7cc4ff;
  --warm: #ffb36b;
  --cool: #7cc4ff;
  --hum: #76e4c3;
  --danger: #ff7a7a;
  --radius: 26px;
  --gap: 18px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: #0b0f17;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- background ---------- */
#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-layer {
  position: absolute; left: -2%; top: -2%; width: 104%; height: 104%;
  object-fit: cover; object-position: center;
  opacity: 0; transition: opacity 2.5s ease;
}
.bg-layer.show { opacity: 1; }
#bg-dim {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,calc(var(--dim, .45) * .6)) 0%, rgba(0,0,0,var(--dim, .45)) 70%, rgba(0,0,0,calc(var(--dim, .45) + .2)) 100%),
    linear-gradient(180deg, rgba(5,8,14,.15), rgba(5,8,14,.35));
}

/* ---------- home grid ---------- */
#home {
  position: relative; z-index: 1;
  height: 100dvh;
  padding: calc(var(--gap) + env(safe-area-inset-top)) var(--gap) calc(var(--gap) + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto;
  grid-template-areas:
    "weather clock sensors"
    "weather clock todos"
    "links   links links";
  gap: var(--gap);
}
#card-weather { grid-area: weather; }
#card-clock { grid-area: clock; }
#card-sensors { grid-area: sensors; }
#card-todos { grid-area: todos; }
#bottom { grid-area: links; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }

.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: flex; flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, background .25s ease, border-color .25s ease;
  animation: rise .6s cubic-bezier(.2,.8,.2,1) both;
}
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card:active { transform: scale(.985); background: var(--glass-hover); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); }
.card-sub { font-size: 13px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.skeleton {
  flex: 1; border-radius: 16px;
  background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.09), rgba(255,255,255,.04));
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.error { color: var(--text-faint); font-size: 14px; margin: auto; text-align: center; padding: 10px; }

/* ---------- clock ---------- */
.card-clock { container-type: inline-size; background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; justify-content: center; }
.card-clock:active { background: rgba(255,255,255,.04); }
.clock-wrap { text-align: center; }
.clock {
  font-family: var(--font-display);
  font-weight: 200;
  font-size: clamp(60px, 29cqi, 220px);
  line-height: .95;
  letter-spacing: -.03em;
  text-shadow: 0 4px 40px rgba(0,0,0,.45);
  display: inline-flex; align-items: flex-start;
}
.clock-sec { font-size: .24em; font-weight: 300; margin-left: .2em; margin-top: .35em; color: var(--text-dim); letter-spacing: 0; min-width: 1.3em; text-align: left; }
.clock-date { margin-top: 14px; font-size: clamp(18px, 2.3vw, 28px); font-weight: 300; color: var(--text-dim); text-transform: capitalize; text-shadow: 0 2px 20px rgba(0,0,0,.5); }
.clock-extra { margin-top: 22px; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; font-size: 15px; color: var(--text-dim); }
.clock-extra span { display: inline-flex; align-items: center; gap: 7px; }
.clock-extra svg { opacity: .8; }

/* ---------- weather card ---------- */
.w-now { display: flex; align-items: center; gap: 10px; }
.w-now img { width: 96px; height: 96px; flex: none; filter: drop-shadow(0 6px 18px rgba(0,0,0,.35)); }
.w-temp { font-family: var(--font-display); font-size: 72px; font-weight: 300; line-height: 1; letter-spacing: -.03em; }
.w-temp sup { font-size: .4em; font-weight: 300; vertical-align: top; position: relative; top: .25em; color: var(--text-dim); }
.w-desc { font-size: 17px; color: var(--text); margin-top: 4px; }
.w-feels { font-size: 14px; color: var(--text-dim); margin-top: 2px; }
.w-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 12px; }
.stat { background: rgba(255,255,255,.06); border-radius: 14px; padding: 9px 10px; min-width: 0; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }
.stat-value { font-size: 17px; font-weight: 500; margin-top: 2px; white-space: nowrap; }
.stat-value small { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.w-hours { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 10px 0; border-top: 1px solid var(--border); }
.w-hour { text-align: center; font-size: 13px; color: var(--text-dim); }
.w-hour img { width: 34px; height: 34px; display: block; margin: 3px auto; }
.w-hour b { display: block; color: var(--text); font-weight: 500; font-size: 15px; }
.w-hour .rain { color: var(--cool); font-size: 11px; height: 14px; }
/* column-wrap: rows that don't fit wrap into an off-screen column instead of being cut in half */
.w-days { border-top: 1px solid var(--border); padding-top: 6px; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; flex-wrap: wrap; justify-content: space-around; column-gap: 40px; }
.w-day { width: 100%; }
.w-day { display: grid; grid-template-columns: 52px 34px 1fr auto; align-items: center; gap: 8px; font-size: 15px; padding: 3px 0; }
.w-day img { width: 32px; height: 32px; }
.w-day .dn { color: var(--text-dim); text-transform: capitalize; }
.w-day .lo { color: var(--text-faint); }
.range-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.08); position: relative; }
.range-bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--cool), var(--warm)); }
.w-day .rng { display: flex; gap: 10px; justify-content: flex-end; min-width: 76px; }

/* ---------- sensors card ---------- */
.sensors { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; min-height: 0; }
.sensor { background: rgba(255,255,255,.06); border-radius: 18px; padding: 12px 14px; display: flex; flex-direction: column; min-width: 0; position: relative; overflow: hidden; }
.sensor-name { font-size: 14px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sensor-temp { font-family: var(--font-display); font-size: 44px; font-weight: 300; line-height: 1.05; margin-top: 4px; letter-spacing: -.02em; }
.sensor-temp small { font-size: .45em; color: var(--text-dim); }
.sensor-hum { font-size: 17px; color: var(--hum); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.sensor-trend { font-size: 13px; color: var(--text-faint); margin-left: 4px; }
.sensor-spark { margin-top: 8px; flex: 1; min-height: 34px; max-height: 120px; width: 100%; }
.sensor.stale .sensor-temp { color: var(--text-dim); }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: rgba(255,122,122,.18); color: var(--danger); margin-left: 6px; vertical-align: middle; }

/* ---------- todos card ---------- */
.todo-list { list-style: none; margin: 0; padding: 0; overflow: hidden; flex: 1; min-height: 0; }
.todo-list li { display: flex; align-items: center; gap: 12px; padding: 8px 2px; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.06); min-width: 0; }
.todo-list li:last-child { border-bottom: none; }
.todo-list li span.txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.todo-list li.done span.txt { text-decoration: line-through; color: var(--text-faint); }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--text-dim); flex: none; }
.dot.pri { border-color: var(--warm); background: var(--warm); }
.todo-quote { margin: auto; padding: 0 12px; text-align: center; max-width: 440px; }
.todo-quote blockquote { margin: 0; font-family: var(--font-display); font-size: clamp(19px, 2.3vw, 24px); font-weight: 300; line-height: 1.35; color: var(--text); }
.todo-quote blockquote::before { content: '“'; display: block; font-size: 2.4em; line-height: .6; height: .45em; color: var(--warm); opacity: .7; }
.todo-quote figcaption { margin-top: 10px; font-size: 14px; color: var(--text-dim); }
.todo-quote-hint { margin-top: 16px; font-size: 12px; color: var(--text-faint); }
.empty { color: var(--text-faint); font-size: 15px; margin: auto; text-align: center; line-height: 1.5; }
.more { font-size: 13px; color: var(--text-faint); padding-top: 6px; }

/* ---------- quick links ---------- */
#links { flex: none; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: nowrap; }
.link {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  background: var(--glass); border: 1px solid var(--border); border-radius: 12px;
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: transform .15s ease, background .2s;
}
.link:active { transform: scale(.95); background: var(--glass-hover); }
.link .ico { width: 24px; height: 24px; display: grid; place-items: center; font-size: 19px; }
.link .ico img { width: 20px; height: 20px; }
.link .ext { position: absolute; top: 2px; right: 2px; opacity: .5; }

/* ---------- overlays ---------- */
#overlay, #browser {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  background: var(--glass-strong);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  animation: zoomIn .32s cubic-bezier(.2,.8,.2,1);
}
#browser { background: #0b0f17; z-index: 20; }
#overlay.closing, #browser.closing { animation: zoomOut .22s ease forwards; }
@keyframes zoomIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes zoomOut { to { opacity: 0; transform: scale(.97); } }
.overlay-bar {
  flex: none; display: flex; align-items: center; gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid var(--border);
}
.overlay-bar h1 { margin: 0; font-size: 24px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay-actions { display: flex; gap: 10px; align-items: center; }
.btn-round {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong); background: rgba(255,255,255,.08);
  cursor: pointer; transition: transform .12s, background .2s;
}
.btn-round:active { transform: scale(.92); background: rgba(255,255,255,.16); }
.overlay-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px calc(28px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
#browser-frame { flex: 1; width: 100%; border: 0; background: #fff; }

.seg { display: inline-flex; background: rgba(255,255,255,.07); border-radius: 14px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 10px 16px; border-radius: 10px; cursor: pointer; font-size: 15px; color: var(--text-dim); min-width: 52px; }
.seg button.on { background: rgba(255,255,255,.16); color: var(--text); }

.panel { background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 20px; padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .panel { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* weather detail */
.wd-hero { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.wd-hero img { width: 150px; height: 150px; }
.wd-hero .w-temp { font-size: 110px; }
.wd-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; flex: 1; min-width: 300px; }
.wd-stats .stat { padding: 12px 14px; }
.wd-stats .stat-value { font-size: 20px; }
.hour-strip { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 6px; scrollbar-width: thin; }
.hour-strip .w-hour { flex: 0 0 64px; background: rgba(255,255,255,.04); border-radius: 14px; padding: 8px 0; }
.hour-strip .w-hour .wind { font-size: 11px; color: var(--text-faint); }
.day-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.day-table td { padding: 10px 6px; border-bottom: 1px solid rgba(255,255,255,.06); }
.day-table tr:last-child td { border-bottom: none; }
.day-table img { width: 38px; height: 38px; vertical-align: middle; }
.day-table .dn { text-transform: capitalize; color: var(--text-dim); width: 110px; }
.day-table .num { text-align: right; white-space: nowrap; }
.day-table .rain { color: var(--cool); }
.day-table .rbar { width: 32%; }

/* charts */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--text-faint); font-size: 12px; font-family: var(--font); }
.chart .grid line { stroke: rgba(255,255,255,.07); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-dim); text-transform: none; letter-spacing: 0; font-weight: 400; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* sensor detail */
.sd-head { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; margin-bottom: 8px; }
.sd-big { font-family: var(--font-display); font-size: 64px; font-weight: 300; line-height: 1; }
.sd-big small { font-size: .4em; color: var(--text-dim); }
.sd-hum { font-size: 28px; color: var(--hum); }
.sd-mm { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 16px; font-size: 14px; color: var(--text-dim); margin-left: auto; text-align: right; }
.sd-mm b { color: var(--text); font-weight: 500; }
.comfort { font-size: 14px; padding: 4px 10px; border-radius: 999px; background: rgba(118,228,195,.14); color: var(--hum); }
.comfort.dry, .comfort.humid { background: rgba(255,179,107,.15); color: var(--warm); }

/* todo detail */
.todo-add { display: flex; gap: 12px; margin-bottom: 18px; }
.todo-add input {
  flex: 1; min-width: 0; height: 60px; padding: 0 20px; font-size: 18px;
  border-radius: 18px; border: 1px solid var(--border-strong); background: rgba(255,255,255,.07); color: var(--text);
  outline: none; user-select: text; -webkit-user-select: text;
}
.todo-add input:focus { border-color: var(--accent); background: rgba(255,255,255,.1); }
.btn {
  height: 60px; padding: 0 24px; border-radius: 18px; border: 1px solid var(--border-strong);
  background: rgba(124,196,255,.22); font-size: 17px; font-weight: 600; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: scale(.96); }
.btn.ghost { background: rgba(255,255,255,.07); font-weight: 500; height: 48px; font-size: 15px; padding: 0 18px; border-radius: 14px; }
.btn.toggle.on { background: rgba(255,179,107,.25); border-color: rgba(255,179,107,.5); }
.todo-full { list-style: none; margin: 0; padding: 0; }
.todo-full li {
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,.06); font-size: 19px; min-height: 68px;
  animation: rise .3s ease both;
}
.todo-full .grip { flex: none; width: 32px; height: 48px; margin-right: -8px; display: grid; place-items: center; color: var(--text-faint); touch-action: none; cursor: grab; }
.todo-full li.placeholder { animation: none; outline: 1px dashed rgba(255,255,255,.35); outline-offset: -3px; border-radius: 14px; }
.todo-full li.placeholder > * { visibility: hidden; }
.todo-ghost { position: fixed; z-index: 50; pointer-events: none; margin: 0; }
.todo-ghost li { animation: none; background: var(--glass-strong); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.55); transform: scale(1.03); }
.todo-ghost.settling { transition: top .15s ease; }
.todo-ghost.settling li { transform: none; transition: transform .15s ease; }
.todo-full li .txt { flex: 1; min-width: 0; word-break: break-word; line-height: 1.35; }
.todo-full li .when { font-size: 12px; color: var(--text-faint); display: block; margin-top: 2px; }
.todo-full li.done .txt > span:first-child { text-decoration: line-through; color: var(--text-faint); }
.check {
  width: 48px; height: 48px; flex: none; border-radius: 50%; border: 2px solid var(--text-dim); background: transparent;
  display: grid; place-items: center; cursor: pointer; transition: background .2s, border-color .2s;
}
.check svg { opacity: 0; transition: opacity .2s; }
li.done .check { background: var(--hum); border-color: var(--hum); color: #0b0f17; }
li.done .check svg { opacity: 1; }
.icon-btn { width: 52px; height: 52px; border-radius: 14px; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn.star.on { color: var(--warm); }
.icon-btn.del:active { color: var(--danger); }
.section-label { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-faint); margin: 22px 0 6px; display: flex; justify-content: space-between; align-items: center; }

/* clock detail */
.cd { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; gap: 30px; text-align: center; }
.cd .clock { font-size: clamp(120px, 20vw, 300px); }
.cd { container-type: normal; }
.cd-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; width: min(920px, 100%); }
.cd-cards .stat {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 16px 10px 14px; border-radius: 18px; border: 1px solid var(--border); background: rgba(255,255,255,.05);
}
.cd-cards .stat-label { font-size: 11px; letter-spacing: .14em; }
.cd-cards .stat-value {
  margin: 0; height: 34px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-size: 26px; font-weight: 400; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.cd-cards .stat-value .moon-icon { flex: none; }
.cd-cards .stat-value span { font-size: 22px; color: var(--text-dim); }
.cd-cards .stat-sub { margin: 0; font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.daylight { width: min(900px, 100%); }
.stat-sub { font-size: 13px; color: var(--text-faint); margin-top: 2px; }

/* system strip under the clock + System panel */
.clock-sys { flex: 1 1 auto; min-width: 0; display: flex; gap: 6px 16px; flex-wrap: wrap; justify-content: flex-start; font-size: 13px; color: var(--text-faint); cursor: pointer; padding: 2px 6px; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.clock-sys[hidden] { display: none; }
.clock-sys b { font-weight: 500; color: var(--text-dim); margin-right: 3px; }
.clock-sys .v { display: inline-block; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sys { display: flex; flex-direction: column; gap: 18px; width: min(920px, 100%); margin: 0 auto; }
.sys .panel { margin-bottom: 0; }
.sys-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.pill { font-size: 12px; letter-spacing: .06em; padding: 4px 10px; border-radius: 999px; text-transform: none; font-weight: 500; }
.pill.ok { background: rgba(118,228,195,.16); color: var(--hum); }
.pill.off { background: rgba(255,122,122,.18); color: var(--danger); }
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 15px; }
.top-list li:last-child { border-bottom: none; }
.top-list li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }

/* date on the clock opens the calendar; dot when today has a note */
#clock-date-btn { cursor: pointer; position: relative; display: inline-block; padding: 4px 6px; margin-left: -6px; border-radius: 10px; }
#clock-date-btn:active { background: rgba(255,255,255,.08); }
.note-badge { display: inline-block; width: 11px; height: 11px; margin-left: 8px; vertical-align: super; border-radius: 50%; background: var(--warm); box-shadow: 0 0 0 0 rgba(255,179,107,.6); animation: badgePulse 2.4s ease-out infinite; }
.note-badge[hidden] { display: none; }
@keyframes badgePulse { 0% { box-shadow: 0 0 0 0 rgba(255,179,107,.55); } 70%, 100% { box-shadow: 0 0 0 10px rgba(255,179,107,0); } }

/* calendar */
.cal { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cal .panel { margin-bottom: 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 20px; font-weight: 500; text-transform: capitalize; }
.cal-head .btn-round { font-size: 26px; line-height: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); padding-bottom: 4px; }
.cal-day { position: relative; height: 50px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text); font: inherit; font-size: 17px; cursor: pointer; }
.cal-day:active { background: rgba(255,255,255,.1); }
.cal-day.other { color: var(--text-faint); }
.cal-day.today { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cal-day.sel { background: rgba(124,196,255,.22); }
.cal-day.has-note::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--warm); }
.cal-today { margin-top: 12px; width: 100%; justify-content: center; }
.cal-note h2 { text-transform: none; letter-spacing: 0; font-size: 18px; color: var(--text); }
.cal-note textarea {
  width: 100%; min-height: 300px; resize: vertical; box-sizing: border-box; padding: 14px 16px;
  border-radius: 14px; border: 1px solid var(--border); background: rgba(255,255,255,.06); color: var(--text);
  font: inherit; font-size: 18px; line-height: 1.45; outline: none;
}
.cal-note textarea:focus { border-color: var(--accent); background: rgba(255,255,255,.1); }
.zones { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* ---------- printer (Bambu, inside the sensors card while printing) ---------- */
#card-sensors.printing .card-body { flex: none; }
/* each sensor shrinks to its name over temperature · humidity */
#card-sensors.printing .sensor { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "name name" "temp hum"; align-items: baseline; column-gap: 12px; padding: 8px 12px; }
#card-sensors.printing .sensor-name { grid-area: name; font-size: 13px; }
#card-sensors.printing .sensor-temp { grid-area: temp; line-height: 1; }
/* block (not flex) so its baseline is the text's, not the drop icon's bottom edge */
#card-sensors.printing .sensor-hum { grid-area: hum; line-height: 1; display: block; }
#card-sensors.printing .sensor-hum svg { width: 13px; height: 13px; vertical-align: -1px; margin-right: 4px; }
#card-sensors.printing .sensor-temp { font-size: 24px; margin-top: 0; }
#card-sensors.printing .sensor-hum { font-size: 14px; }
#card-sensors.printing .sensor-spark, #card-sensors.printing .sensor-trend { display: none; }
#printer-strip {
  --ps: var(--accent);
  flex: 1; min-height: 0; margin-top: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; justify-content: space-evenly; gap: 8px;
  border-radius: 18px; background: rgba(255,255,255,.06);
}
#printer-strip.paused { --ps: var(--warm); }
#printer-strip.failed, #printer-strip.login { --ps: var(--danger); }
#printer-strip.done { --ps: #8fe39a; }
.ps-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ps-cover {
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
  background: rgba(255,255,255,.07); color: var(--text-faint);
}
.ps-cover img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transform: scale(1.35); /* the pictures have wide empty margins */
}
/* the pictures are transparent; hide the placeholder printer icon behind them */
.ps-cover img:not([hidden]) + svg { display: none; }
#printer-strip.login .ps-cover { color: var(--danger); }
.ps-main { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "file pct" "sub pct"; column-gap: 10px; align-items: center; }
.ps-file { grid-area: file; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-sub { grid-area: sub; font-size: 13px; color: var(--text-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-sub code { font-size: 12px; color: var(--text); }
.ps-pct { grid-area: pct; font-family: var(--font-display); font-size: 32px; font-weight: 300; line-height: 1; color: var(--ps); font-variant-numeric: tabular-nums; }
.ps-pct span { font-size: 17px; margin-left: 1px; opacity: .75; }
.ps-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.ps-bar i { display: block; height: 100%; width: var(--pct, 0%); border-radius: inherit; background: var(--ps); transition: width 1.2s ease; }
#printer-strip.login .ps-bar { display: none; }
.ps-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.ps-time { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-time b { color: var(--text); font-weight: 500; }
.ps-chips { flex: none; display: flex; gap: 5px; }
.ps-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: rgba(255,255,255,.07); color: var(--text-faint);
}
.ps-chip.lit { color: #ffe08a; background: rgba(255,224,138,.13); }
.ps-chip.warn { color: var(--warm); background: rgba(255,179,107,.13); }

/* sensors page: full printer panel on top while printing */
.pp { --ps: var(--accent); }
.pp.paused { --ps: var(--warm); }
.pp.failed, .pp.login { --ps: var(--danger); }
.pp.done { --ps: #8fe39a; }
.pp-pills { display: flex; gap: 6px; }
.pill.pp-state { background: color-mix(in srgb, var(--ps) 18%, transparent); color: var(--ps); }
.pp-top { display: flex; gap: 22px; align-items: center; }
.pp-cover {
  position: relative; flex: none; width: 190px; height: 190px; border-radius: 18px; overflow: hidden;
  display: grid; place-items: center; background: rgba(255,255,255,.06); color: var(--text-faint);
}
.pp-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform: scale(1.3); }
.pp-cover img:not([hidden]) + svg { display: none; }
.pp-live { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pp-file { font-size: 22px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-stage { font-size: 15px; color: var(--text-dim); margin-top: -4px; }
.pp-stage code { font-size: 13px; color: var(--text); }
.pp-progress { display: flex; align-items: center; gap: 16px; margin-top: 4px; }
.pp-pct { flex: none; font-family: var(--font-display); font-size: 52px; font-weight: 300; line-height: 1; color: var(--ps); font-variant-numeric: tabular-nums; }
.pp-pct span { font-size: 24px; margin-left: 2px; opacity: .75; }
.pp-bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; }
.pp-bar i { display: block; height: 100%; border-radius: inherit; background: var(--ps); transition: width 1.2s ease; }
.pp-time { font-size: 15px; color: var(--text-dim); }
.pp-time b { color: var(--text); font-weight: 500; }
.pp-kv { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 2px; }
.pp-kv div { display: flex; flex-direction: column; gap: 2px; }
.pp-kv span { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-faint); }
.pp-kv b { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pp-error { font-size: 14px; color: var(--danger); background: rgba(255,122,122,.12); border-radius: 10px; padding: 6px 10px; align-self: flex-start; }
.pp-stats:not(:empty) { margin-top: 18px; }
.pp-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.pp-light { display: inline-flex; color: var(--text-faint); }
.pp-light.lit { color: #ffe08a; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --gap: 14px; --radius: 22px; }
  .card { padding: 16px 18px; }
  .w-now img { width: 76px; height: 76px; }
  .w-temp { font-size: 58px; }
  .sensor-temp { font-size: 36px; }
  .w-day { font-size: 14px; }
  .sensor-trend .tw { display: none; }
}
@media (max-height: 700px) {
  .w-day { padding: 1px 0; }
  .w-hours { padding: 6px 0; }
  .w-stats { margin: 10px 0 8px; }
  .clock-extra { margin-top: 12px; }
}
/* 4:3 and similar landscape screens: clock across the top, cards in two wide columns */
@media (orientation: landscape) and (max-aspect-ratio: 3/2) {
  #home {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "clock clock"
      "weather sensors"
      "weather todos"
      "links links";
  }
  .card-clock { padding: 4px 8px; }
  .clock-wrap { display: flex; align-items: center; justify-content: center; gap: 4cqi; text-align: left; }
  .clock { font-size: clamp(60px, 17cqi, 170px); }
  .clock-meta { display: flex; flex-direction: column; align-items: center; gap: 12px; }
  .clock-date { margin-top: 0; font-size: clamp(18px, 3.2cqi, 30px); }
  .clock-extra { margin-top: 0; justify-content: center; gap: 18px; }
}
@media (orientation: portrait) {
  #home {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(0, 1.3fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "clock clock"
      "weather weather"
      "sensors todos"
      "links links";
  }
  .card-clock { padding: 24px 0 8px; }
  .sensors { grid-template-columns: 1fr; }
  .sensor-spark { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .cd-cards { grid-template-columns: repeat(2, 1fr); }
  .cal { grid-template-columns: 1fr; }
  .pp-cover { width: 120px; height: 120px; }
  .pp-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- on-screen keyboard ---------- */
#osk {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(20, 24, 34, .96);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-strong);
  transform: translateY(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; gap: 8px;
}
#osk.open { transform: none; }
.osk-row { display: flex; gap: 7px; justify-content: center; }
.osk-row button {
  flex: 1 1 0; max-width: 96px; height: 56px; border-radius: 12px; border: 0;
  background: rgba(255,255,255,.11); font-size: 22px; cursor: pointer;
}
.osk-row button:active { background: rgba(255,255,255,.28); }
.osk-row button.wide { flex: 1.5 1 0; max-width: 140px; font-size: 18px; }
.osk-row button.space { flex: 5 1 0; max-width: 520px; font-size: 16px; color: var(--text-dim); }
.osk-row button.on { background: rgba(255,255,255,.3); }
.osk-row button.accent { background: rgba(124,196,255,.35); font-weight: 600; }
#overlay:has(~ #osk.open) .overlay-content, body:has(#osk.open) .overlay-content { padding-bottom: 360px; }
.chart-slot { width: 100%; }

/* close (only shown when the local kiosk helper is present) */
#close {
  position: fixed; top: 10px; right: 12px; z-index: 5;
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
  background: rgba(18, 22, 32, .18); border-color: rgba(255,255,255,.06);
  color: var(--text-faint); display: grid; place-items: center; cursor: pointer; opacity: .6;
}
#close:active { background: var(--glass-hover); color: var(--text); opacity: 1; }

/* links share the row instead of overflowing on narrow screens */
.link { flex: none; position: relative; }
@media (max-height: 640px) {
  .sensor-spark { display: none; }
  .sensor { justify-content: center; }
}

/* ---------- phones: the page scrolls and cards size to their content ---------- */
@media (max-width: 600px), (max-height: 500px) {
  body { overflow-y: auto; overscroll-behavior-y: none; }
  #home { height: auto; min-height: 100dvh; grid-template-rows: none; grid-auto-rows: auto; align-content: start; }
  .card { min-height: 0; }
  .w-days { flex: none; flex-wrap: nowrap; }
  .sensor-spark { display: block; flex: none; height: 48px; }
  .sensor { justify-content: flex-start; }
  #card-todos { min-height: 200px; }
  #bottom { flex-direction: column; align-items: stretch; gap: 14px; padding-bottom: 6px; }
  .clock-sys { justify-content: center; text-align: center; }
  #links { justify-content: center; gap: 12px; }
  .link { width: 52px; height: 52px; border-radius: 14px; }
  .link .ico { font-size: 22px; }
  .overlay-content { padding-left: 16px; padding-right: 16px; }
  .wd-stats { min-width: 0; }
}
@media (max-width: 600px) {
  :root { --gap: 12px; --radius: 22px; }
  #home {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "clock" "weather" "sensors" "todos" "links";
  }
  .card-clock { padding: 18px 0 4px; }
  .clock { font-size: clamp(64px, 26vw, 120px); }
  .clock-date { font-size: 19px; margin-top: 8px; }
  .clock-extra { margin-top: 12px; }
  .sensors { grid-template-columns: 1fr 1fr; }
  .w-temp { font-size: 58px; }
  .w-now img { width: 76px; height: 76px; }
  .overlay-bar { padding-left: 12px; padding-right: 12px; gap: 10px; }
  .overlay-bar h1 { font-size: 20px; }
  .btn-round { width: 48px; height: 48px; }
  .panel { padding: 14px; }
  .panel h2 { flex-wrap: wrap; }
  .legend { gap: 10px; flex-wrap: wrap; }
  /* weather detail: icon + temperature on one row, stats in a full-width grid below */
  .wd-hero { gap: 6px 14px; }
  .wd-hero img { width: 84px; height: 84px; }
  .wd-hero .w-temp { font-size: 64px; }
  .wd-hero .w-desc { font-size: 18px !important; }
  .wd-hero .w-feels { font-size: 14px !important; }
  .wd-stats { flex: 1 1 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
  .wd-stats .stat { padding: 10px 12px; }
  .wd-stats .stat-value { font-size: 18px; }
  /* 11-day table: drop the condition text and wind so the temperature range fits */
  .day-table { font-size: 15px; }
  .day-table td { padding: 8px 3px; }
  .day-table td:nth-child(2) span, .day-table td:nth-child(4) { display: none; }
  .day-table .dn { width: auto; }
  .day-table img { width: 32px; height: 32px; }
  .day-table .rain { font-size: 13px; }
  .day-table .rbar { width: auto; min-width: 28px; }
  .cd .clock { font-size: clamp(72px, 24vw, 120px); }
  .sd-mm { margin-left: 0; text-align: left; flex: 1 1 100%; justify-content: start; }
  .seg button { padding: 8px 10px; min-width: 42px; font-size: 14px; }
  .pp-top { flex-direction: column; align-items: stretch; }
  .pp-cover { align-self: center; }
}
/* landscape phones: keep the three columns, just let the page grow */
@media (max-height: 500px) and (min-width: 601px) {
  #home { grid-template-areas: "weather clock sensors" "weather clock todos" "links links links"; }
  .w-day:nth-child(n+6) { display: none; }
}

/* ---------- parking fines warning modal ---------- */
#fines-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(8, 10, 16, 0.62);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: finesFade .2s ease;
}
#fines-modal[hidden] { display: none; }
@keyframes finesFade { from { opacity: 0; } to { opacity: 1; } }
.fines-box {
  width: min(520px, 100%);
  background: var(--glass-strong);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 122, 122, 0.25);
  padding: 30px 28px 26px;
  text-align: center;
  animation: finesPop .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes finesPop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.fines-icon { color: var(--danger); display: flex; justify-content: center; margin-bottom: 8px; }
.fines-box h1 { font-family: var(--font-display); font-weight: 500; font-size: 26px; margin: 0 0 16px; color: var(--text); }
.fines-body { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.fines-row {
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  background: rgba(255, 122, 122, 0.10);
  border: 1px solid rgba(255, 122, 122, 0.30);
  border-radius: 16px; padding: 12px 14px;
}
.fines-plate { font-family: var(--font-display); font-size: 22px; letter-spacing: 1px; color: var(--danger); font-weight: 500; }
.fines-msg { font-size: 14px; color: var(--text-dim); line-height: 1.4; }
.fines-foot { font-size: 13px; color: var(--text-faint); margin-bottom: 18px; }
.fines-dismiss {
  appearance: none; border: 0; cursor: pointer;
  background: var(--danger); color: #1a0909;
  font-family: var(--font); font-size: 17px; font-weight: 600;
  padding: 13px 44px; border-radius: 999px; min-width: 160px;
}
.fines-dismiss:active { transform: scale(.97); }
