/* Cat feeder dashboard. The status "lamp" echoes the feeder's own RGB LED:
   green = healthy, red = jam, purple = can't reach the broker. */
:root {
  --ground: #F1F3F2;
  --raise: #FFFFFF;
  --ink: #18211F;
  --muted: #5B6864;
  --line: #D9DFDC;
  --go: #1F9D5C;
  --stop: #D63C41;
  --wait: #B97F00;
  --off: #7C4DD8;
  --src-scheduled: #2E7F70;
  --src-button: #E39A2D;
  --src-remote: #4E7DF0;
  --track: #E3E8E5;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0E1413;
    --raise: #172120;
    --ink: #E7EEEC;
    --muted: #93A29D;
    --line: #26332F;
    --go: #3DD68C;
    --stop: #FF6B6F;
    --wait: #F2B83C;
    --off: #A78BFA;
    --src-scheduled: #4FB3A0;
    --track: #1D2927;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 16px/1.45 var(--font);
  min-height: 100vh; min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--src-remote); outline-offset: 2px; border-radius: 6px; }
.noscript { padding: 24px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { max-width: 600px; margin: 0 auto; padding: 0 16px calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 6px; }
.topbar h1 { font-size: 15px; font-weight: 650; margin: 0; color: var(--muted); letter-spacing: .01em; }
.linkbtn { background: none; border: 0; padding: 10px 4px; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.view > section { padding: 22px 0; border-top: 1px solid var(--line); }
.view > section:first-child { border-top: 0; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 650; }
.sub { color: var(--muted); font-size: 14px; margin: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--raise) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar nav { display: flex; width: 100%; max-width: 600px; }
.tab { flex: 1; min-height: var(--tab-h); background: none; border: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 600; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] svg { stroke-width: 2.4; }

/* ---------- home: lamp ---------- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; padding: 18px 0 22px 14px !important; }
.lamp {
  --c: var(--muted);
  width: 104px; height: 104px; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, color-mix(in srgb, #fff 55%, var(--c)) 0, var(--c) 46%, color-mix(in srgb, #000 22%, var(--c)) 100%);
  box-shadow: 0 0 0 9px color-mix(in srgb, var(--c) 16%, transparent), 0 0 44px color-mix(in srgb, var(--c) 40%, transparent);
}
.lamp[data-s="online"] { --c: var(--go); animation: breathe 4.5s ease-in-out infinite; }
.lamp[data-s="stale"] { --c: var(--wait); }
.lamp[data-s="offline"] { --c: var(--off); }
.lamp[data-s="fault"] { --c: var(--stop); }
.lamp[data-s="unknown"] { --c: #8A9692; box-shadow: 0 0 0 9px color-mix(in srgb, var(--c) 14%, transparent); }
@keyframes breathe { 50% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--c) 10%, transparent), 0 0 60px color-mix(in srgb, var(--c) 52%, transparent); } }
@media (prefers-reduced-motion: reduce) { .lamp { animation: none !important; } }
.hero h2 { font-size: 30px; line-height: 1.1; margin: 0 0 6px; font-weight: 700; letter-spacing: -.01em; }
.hero p { margin: 0; color: var(--muted); font-size: 15px; }
.alert { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; font-size: 15px; font-weight: 550;
  background: color-mix(in srgb, var(--stop) 12%, var(--ground)); color: var(--ink); border-left: 5px solid var(--stop); }
.alert.warn { background: color-mix(in srgb, var(--wait) 14%, var(--ground)); border-left-color: var(--wait); }

dl.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0; }
dl.facts dt, dl.facts dd { padding: 11px 0; border-bottom: 1px solid var(--line); margin: 0; }
dl.facts dt { color: var(--muted); font-size: 14px; padding-right: 18px; }
dl.facts dd { text-align: right; font-weight: 550; }
dl.facts > :nth-last-child(-n+2) { border-bottom: 0; }
dl.facts dd small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }

/* ---------- feed control ---------- */
.feedrow { display: flex; align-items: center; gap: 12px; }
.stepper { display: flex; align-items: center; background: var(--raise); border: 1px solid var(--line); border-radius: 16px; }
.stepper button { width: 52px; height: 56px; background: none; border: 0; font-size: 26px; line-height: 1; color: var(--ink); }
.stepper button:disabled { color: var(--line); cursor: default; }
.stepper output { min-width: 44px; text-align: center; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn { min-height: 56px; padding: 0 22px; border-radius: 16px; border: 0; background: var(--ink); color: var(--ground);
  font-weight: 700; font-size: 17px; }
.btn.grow { flex: 1; }
.btn.quiet { background: var(--raise); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: 44px; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.msg { min-height: 24px; margin: 12px 0 0; font-size: 15px; color: var(--muted); }
.msg.bad { color: var(--stop); font-weight: 600; }
.msg.good { color: var(--go); font-weight: 600; }
.msg.warn { color: var(--wait); font-weight: 600; }
dialog { border: 0; border-radius: 20px; padding: 22px; max-width: 340px; width: calc(100% - 32px); background: var(--raise); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h3 { margin: 0 0 6px; font-size: 20px; }
dialog p { margin: 0 0 18px; color: var(--muted); }
dialog .row { display: flex; gap: 10px; }
dialog .row .btn { flex: 1; }

/* ---------- chart ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--font); }
.chart .jam { fill: var(--stop); }

/* ---------- lists ---------- */
.seg { display: flex; background: var(--track); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 40px; border: 0; background: none; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.list li.daygroup { display: block; margin: 0; padding: 18px 0 4px; border: 0; font-size: 14px; font-weight: 650; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list .t { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.list .what { font-weight: 600; }
.list .what small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.badge { font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge.ok { color: var(--go); } .badge.bad { color: var(--stop); } .badge.warn { color: var(--wait); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.scheduled { background: var(--src-scheduled); } .dot.button { background: var(--src-button); } .dot.remote { background: var(--src-remote); }
.loglist { font: 12px/1.5 var(--mono); word-break: break-word; }
.loglist li { display: block; padding: 5px 0; }
.loglist .t { display: block; font: 11px var(--font); }
.empty { color: var(--muted); padding: 22px 0; }
.more { margin-top: 14px; width: 100%; }

/* ---------- uptime ---------- */
.pcts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pcts div { padding: 4px 0; }
.pcts b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.pcts span { color: var(--muted); font-size: 13px; }
.tl { display: grid; grid-template-columns: 38px 1fr; gap: 6px 8px; align-items: center; font-size: 13px; color: var(--muted); }
.tl svg { width: 100%; height: 16px; display: block; }
.tl .hours { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; }

/* ---------- schedule ---------- */
.sched { list-style: none; margin: 0 0 14px; padding: 0; }
.sched li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) 62px 40px; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.sched select, .sched input { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); padding: 0 10px; }
.sched .x { min-height: 44px; border: 0; background: none; color: var(--stop); font-size: 22px; }
.sched-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 0 auto; padding: calc(60px + env(safe-area-inset-top)) 20px 40px; }
.login .lamp { width: 72px; height: 72px; margin: 0 0 26px; }
.login h1 { margin: 0 0 4px; font-size: 28px; }
.login form { display: grid; gap: 12px; margin-top: 22px; }
.login label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.login input { min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--raise); padding: 0 14px; font-size: 17px; }
