/* Homebase — "Night Deck". Tokens per DESIGN.md */
/* the hidden attribute must always win over component display rules (flex/grid) */
[hidden] { display: none !important; }
:root {
  --bg: oklch(0.17 0.028 262);
  --surface: oklch(0.22 0.032 262);
  --surface-2: oklch(0.26 0.035 262);
  --line: oklch(0.32 0.035 262);
  --ink: oklch(0.93 0.008 262);
  --ink-dim: oklch(0.72 0.02 262);
  --mint: oklch(0.82 0.14 168);
  --teal: oklch(0.78 0.11 190);
  --down: oklch(0.72 0.17 25);
  --warn: oklch(0.8 0.13 85);
  --mono: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); }

:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 4px; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  transition: background 150ms var(--ease), border-color 150ms var(--ease);
}
button:hover { background: var(--line); }
button.primary {
  background: var(--mint);
  border-color: var(--mint);
  color: oklch(0.2 0.03 262);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.55; cursor: default; }

input {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color 150ms var(--ease);
}
input::placeholder { color: var(--ink-dim); }
input:focus { border-color: var(--mint); outline: none; }

.mono { font-family: var(--mono); }

/* ---------- shell ---------- */
.shell { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding-block: 0.25rem 1.25rem;
}
.wordmark {
  font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 0.55rem; min-width: 0; flex-wrap: wrap;
}
/* On narrow screens, stack the header actions below the wordmark so nothing overflows. */
@media (max-width: 560px) {
  header.top { flex-direction: column; align-items: flex-start; }
  .top-actions { width: 100%; }
  .top-actions button { flex: 1; padding-inline: 0.4rem; font-size: 0.75rem; }
}
.wordmark .logo { height: 40.9px; width: auto; display: block; }
.panel .wordmark .logo { height: 54.1px; }
@media (min-width: 640px) {
  .wordmark .logo { height: 50px; }
  .panel .wordmark .logo { height: 50px; }
}
.wordmark .sig {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 12px oklch(0.82 0.14 168 / 0.55);
}
.wordmark small {
  font-family: var(--mono); font-size: 0.75rem; font-weight: 400;
  color: var(--ink-dim);
  /* The "Homebase" wordmark sits at ~55% of the logo's height (the circular icon
     extends above/below it), so nudge the caption down to align with the word. */
  transform: translateY(1.5px);
}
@media (min-width: 640px) { .wordmark small { transform: translateY(2.5px); } }

/* ---------- vitals ---------- */
.vitals {
  display: flex; flex-direction: column; gap: 0.6rem;
  border-block: 1px solid var(--line);
  padding: 0.75rem 0.125rem;
  font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-dim);
}
/* two deliberate rows, each spread across the full width */
.vitals-row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.4rem 1.05rem; justify-content: space-between;
}
/* each metric is one unit so its label/value/sparkline never split across lines */
.vital { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.vitals b { color: var(--ink); font-weight: 500; }
.meter {
  display: inline-block; width: 56px; height: 5px; border-radius: 3px;
  background: var(--surface-2); vertical-align: 2px; margin-inline: 0.1rem;
  overflow: hidden; flex: none;
}
.meter i {
  display: block; height: 100%; background: var(--teal); border-radius: 3px;
  transition: width 300ms var(--ease);
}
.meter.hot i { background: var(--warn); }
.spark { color: var(--teal); width: 40px; height: 13px; flex: none; opacity: 0.85; }
.vital-ok b { color: var(--mint); }
.vital-warn { color: var(--warn); }
.vital-warn b { color: var(--warn); }
/* clickable vitals chip (OS updates) — looks like the others, acts like a button */
.vital-btn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.vital-btn:hover b { text-decoration: underline; }
.pulse { animation: hb-pulse 1.4s ease-in-out infinite; }
@keyframes hb-pulse { 50% { opacity: 0.45; } }

/* ---------- OS updates dialog ---------- */
.updates-list {
  max-height: 40vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  font-family: var(--mono); font-size: 0.75rem;
}
.updates-list .pkg {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--line);
}
.updates-list .pkg:last-child { border-bottom: 0; }
.updates-list .pkg span:last-child { color: var(--ink-dim); }
.reboot-note {
  border: 1px solid var(--warn); border-radius: 8px;
  background: oklch(0.8 0.13 85 / 0.1);
  color: var(--ink); font-size: 0.8125rem; line-height: 1.5;
  padding: 0.6rem 0.75rem; margin-block: 0.6rem;
}
.reboot-note b { color: var(--warn); }
.reboot-note .mono { color: var(--ink-dim); }
.reboot-advisor {
  border-radius: 8px; border: 1px solid var(--line);
  font-size: 0.8125rem; line-height: 1.5; padding: 0.55rem 0.7rem; margin-block: 0.6rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.reboot-advisor.advisor-ok { border-color: var(--mint); background: oklch(0.82 0.14 168 / 0.08); }
.reboot-advisor.advisor-warn { border-color: var(--warn); background: oklch(0.8 0.13 85 / 0.08); }
.reboot-advisor .advisor-quiet { color: var(--ink-dim); }
.reboot-action { margin-block: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem; }
.reboot-action label b { color: var(--warn); font-family: var(--mono); }
.reboot-success {
  border: 1px solid var(--mint); border-radius: 8px;
  background: oklch(0.82 0.14 168 / 0.1);
  color: var(--ink); font-size: 0.8125rem; line-height: 1.5;
  padding: 0.6rem 0.75rem; margin-block: 0.6rem;
}
.reboot-success b { color: var(--mint); }

/* response-time sparkline on cards */
.card-spark .spark { width: 34px; height: 11px; opacity: 0.6; vertical-align: -1px; }

/* ---------- server health list ---------- */
.health-list { display: flex; flex-direction: column; gap: 0.1rem; }
.health-row {
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: center;
  gap: 0.6rem; padding: 0.6rem 0.2rem; border-bottom: 1px solid var(--line);
}
.health-row:last-child { border-bottom: 0; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.health-row.ok .health-dot { background: var(--mint); box-shadow: 0 0 8px oklch(0.82 0.14 168 / 0.5); }
.health-row.warn .health-dot { background: var(--warn); box-shadow: 0 0 8px oklch(0.8 0.13 85 / 0.5); }
.health-label { font-weight: 600; white-space: nowrap; }
.health-detail { color: var(--ink-dim); font-size: 0.8125rem; }
.health-row.warn .health-detail { color: var(--warn); }
.health-act { flex: none; }
@media (max-width: 480px) {
  .health-row { grid-template-columns: auto 1fr auto; }
  .health-detail { grid-column: 2 / -1; }
}

/* ---------- category filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 1.1rem; }
.chip {
  font-family: var(--mono); font-size: 0.75rem;
  border: 1px solid var(--line); border-radius: 99px;
  background: none; color: var(--ink-dim);
  padding: 0.3rem 0.85rem;
}
.chip:hover { background: var(--surface); color: var(--ink); }
.chip.on {
  background: var(--mint); border-color: var(--mint);
  color: oklch(0.2 0.03 262); font-weight: 600;
}

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  padding-block: 1.5rem;
}

.card {
  position: relative;
  display: flex; gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.95rem 1rem;
  transition: transform 180ms var(--ease), border-color 180ms var(--ease);
}
.card:hover { transform: translateY(-2px); border-color: oklch(0.42 0.04 262); }
.card:hover .go { opacity: 1; transform: none; }

/* rounded-square app icon */
.card-icon {
  position: relative; flex: none;
  width: 52px; height: 52px; border-radius: 12px;
  overflow: hidden; border: 1px solid var(--line);
  background: var(--surface-2);
}
.card-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-icon .mark {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--mono); font-size: 1.25rem; font-weight: 600;
  color: oklch(0.88 0.06 var(--h, 168));
  background:
    radial-gradient(120% 140% at 80% -10%, oklch(0.36 0.07 var(--h, 168) / 0.6), transparent 62%),
    oklch(0.2 0.035 262);
}
/* settings affordance: appears on hover over the icon, sits above the stretched link */
.card-icon .gear {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center;
  border: 0; border-radius: 0; padding: 0;
  background: oklch(0.15 0.03 262 / 0.72); color: var(--ink);
  font-size: 1.15rem; line-height: 1;
  opacity: 0; transition: opacity 150ms var(--ease);
}
.card-icon .gear:hover, .card-icon .gear:focus-visible { opacity: 1; }
.card:hover .card-icon .gear { opacity: 0.72; }
.card:hover .card-icon .gear:hover { opacity: 1; }

.card-main { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; flex: 1; }
.card .name-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.card-link {
  font-size: 1rem; font-weight: 600; letter-spacing: -0.005em;
  color: var(--ink); text-decoration: none;
}
/* stretched link: whole card is clickable, edit button (z-index 2) stays above it */
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card:hover .card-link { color: var(--mint); }
.card p { font-size: 0.8125rem; color: var(--ink-dim); }
.card .foot {
  margin-top: auto; padding-top: 0.35rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.card .meta { font-size: 0.75rem; color: var(--ink-dim); flex: none; }
.card-stats {
  display: flex; justify-content: space-between; gap: 0.75rem;
  margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--line);
  font-size: 0.6875rem; color: var(--ink-dim);
}
.card-stats .upd {
  position: relative; z-index: 2;
  color: oklch(0.2 0.03 262); background: var(--warn);
  padding: 0.02rem 0.35rem; border-radius: 99px; font-weight: 600; margin-left: 0.25rem;
}

.tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tag {
  font-family: var(--mono); font-size: 0.6875rem;
  border: 1px solid var(--line); border-radius: 99px;
  padding: 0.1rem 0.55rem; color: var(--ink-dim);
}

.go {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 1;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: oklch(0.2 0.03 262 / 0.8); color: var(--ink);
  opacity: 0; transform: translateY(2px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  font-size: 0.75rem;
  /* decorative indicator only: let clicks fall through to the card's stretched
     link so the ↗ corner opens the app instead of swallowing the click */
  pointer-events: none;
}
.info {
  position: absolute; top: 0.55rem; right: 2.3rem; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: oklch(0.2 0.03 262 / 0.85); color: var(--ink-dim);
  opacity: 0; transform: translateY(2px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease), color 150ms var(--ease);
  font-size: 0.8rem;
}
.card:hover .info { opacity: 1; transform: none; }
.info:hover, .info:focus-visible { color: var(--mint); border-color: var(--mint); }

/* Bottom action row — the touch alternative to the hover-only corner icons.
   Hidden on hover-capable (desktop) devices, where the ⓘ/↗ affordances are used. */
.card-actions { display: none; }
@media (hover: none) {
  /* the corner affordances rely on hover, which touch devices lack — drop them
     so they no longer sit on top of the card content */
  .card > .go, .card > .info { display: none; }
  /* ...and replace with two explicit, non-overlapping choices at the foot of the card */
  .card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
  .card-actions > .act {
    position: relative; z-index: 2;            /* sit above the stretched card-link */
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.55rem 0.75rem; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
    font-size: 0.8125rem; font-weight: 500; text-decoration: none;
  }
  .card-actions > .act-open {
    background: var(--mint); color: oklch(0.2 0.03 262);
    border-color: var(--mint); font-weight: 600;
  }
}

/* Lock the background from scrolling while a modal dialog is open. The AI
   assistant (#ai) is intentionally non-modal so it stays scrollable behind. */
html:has(dialog[open]:not(#ai)) { overflow: hidden; }

/* two-factor setup / recovery panels in the security dialog */
.twofa-panel {
  display: flex; flex-direction: column; gap: 0.55rem;
  padding: 0.85rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2);
}
.twofa-key {
  font-size: 0.8125rem; letter-spacing: 0.04em; word-break: break-all;
  padding: 0.55rem 0.7rem; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  user-select: all; line-height: 1.7;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  z-index: 50;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0.55rem 1rem; font-size: 0.8125rem;
  box-shadow: 0 8px 24px oklch(0.1 0.02 262 / 0.5);
}
.toast.err { border-color: var(--down); color: var(--down); }

/* ---------- settings dialog ---------- */
.settings {
  width: min(460px, calc(100vw - 2rem));
  /* margin:auto restores the native dialog centering that the global reset (margin:0) removed */
  margin: auto;
  /* cap height and scroll internally so the (locked) background isn't needed to reach tall content */
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  padding: 0; box-shadow: 0 24px 60px oklch(0.08 0.02 262 / 0.6);
}
.settings::backdrop { background: oklch(0.1 0.02 262 / 0.55); backdrop-filter: blur(2px); }
.set-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.25rem 0.9rem; border-bottom: 1px solid var(--line);
}
.set-head h2 { font-size: 0.9375rem; font-weight: 600; }
.set-x {
  border: 0; background: none; color: var(--ink-dim); padding: 0.2rem 0.4rem;
  font-size: 0.9rem; border-radius: 6px;
}
.set-x:hover { background: var(--surface-2); color: var(--ink); }
.set-body { padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.set-image { display: flex; align-items: center; gap: 0.9rem; }
.set-thumb {
  width: 56px; height: 56px; flex: none;
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: var(--surface-2);
}
.set-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.set-thumb .mark {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--mono); font-size: 1.25rem; font-weight: 600; color: var(--teal);
  background: oklch(0.2 0.035 262);
}
.set-field { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.8125rem; color: var(--ink-dim); }
.set-field input, .set-field textarea { color: var(--ink); font-size: 0.875rem; }
.set-field textarea { resize: vertical; min-height: 2.5rem; line-height: 1.5; }

.cat-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.cat-tags:empty { display: none; }
.cat-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: var(--mono); font-size: 0.6875rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px;
  padding: 0.12rem 0.3rem 0.12rem 0.6rem; color: var(--ink);
}
.cat-tag button {
  border: 0; background: none; color: var(--ink-dim); padding: 0 0.15rem;
  font-size: 0.7rem; line-height: 1; border-radius: 50%;
}
.cat-tag button:hover { color: var(--down); background: none; }
.cat-empty { font-size: 0.75rem; color: var(--ink-dim); }

.set-check {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8125rem; color: var(--ink); cursor: pointer;
}
.set-check input {
  /* undo the global text-input styling: keep it a plain native checkbox */
  width: auto; flex: none; padding: 0; margin: 0;
  accent-color: var(--mint);
}
.set-check-note { color: var(--ink-dim); }

.set-actions {
  display: flex; justify-content: flex-end; gap: 0.6rem;
  padding: 0.9rem 1.25rem 1.1rem; border-top: 1px solid var(--line);
}
.btn-sm {
  font-size: 0.8125rem; padding: 0.45rem 0.9rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.btn-sm:hover { background: var(--line); }
.btn-sm.ghost { background: none; }
.btn-sm.ghost:hover { background: var(--surface-2); }
.btn-sm.primary {
  background: var(--mint); border-color: var(--mint); color: oklch(0.2 0.03 262); font-weight: 600;
}
.btn-sm.primary:hover { filter: brightness(1.06); background: var(--mint); }
.btn-sm:disabled { opacity: 0.55; }
.btn-sm.danger { border-color: var(--down); color: var(--down); background: none; }
.btn-sm.danger:hover { background: oklch(0.72 0.17 25 / 0.12); }

/* header actions + activity/security */
.top-actions { display: flex; align-items: center; gap: 0.5rem; }
.top-actions button {
  font-size: 0.8125rem; padding: 0.4rem 0.8rem; white-space: nowrap;
}
.activity-list {
  max-height: 40vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
/* wider Activity & Security dialog + two-column body to cut vertical scrolling */
.sec-dialog { width: min(880px, calc(100vw - 2rem)); }
/* Layout ONLY when open — display on the base class would override the UA's
   dialog:not([open]) rule and leave the closed dialog visible at the page bottom.
   Open: fits the viewport, no dialog scrollbar; the activity list is the scroller. */
.sec-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
.sec-dialog .set-body { flex: 1; min-height: 0; overflow-y: auto; }
.sec-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; flex: 1; min-height: 0; }
.sec-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; min-height: 0; }
.sec-col .set-field { min-height: 0; }
.sec-col .activity-list { flex: 1; max-height: none; min-height: 10rem; overflow-y: auto; }
@media (max-width: 640px) {
  /* single column on phones — the stacked layout scrolls with the dialog, that's fine */
  .sec-dialog[open] { overflow-y: auto; }
  .sec-cols { grid-template-columns: 1fr; flex: none; }
  .sec-col .activity-list { flex: none; max-height: 40vh; }
}

/* security posture checklist */
.sec-overview { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.sec-row {
  display: flex; align-items: baseline; gap: 0.5rem;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line);
  font-size: 0.8125rem;
}
.sec-row:last-of-type { border-bottom: 0; }
.sec-mark { flex: none; font-weight: 700; }
.sec-ok { color: var(--mint); }
.sec-warn { color: var(--warn); }
.sec-label { flex: none; color: var(--ink); font-weight: 600; }
.sec-detail { color: var(--ink-dim); min-width: 0; }
.sec-ips {
  padding: 0.5rem 0.75rem; border-top: 1px solid var(--line);
  font-size: 0.6875rem; color: var(--ink-dim); word-break: break-all;
}
.act-row {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line);
}
.act-row:last-child { border-bottom: 0; }
.act-what { font-size: 0.8125rem; color: var(--ink); }
.act-meta { font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-dim); }
.act-empty { padding: 1rem; text-align: center; color: var(--ink-dim); font-size: 0.8125rem; }
.sec-danger {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border: 1px solid var(--down); border-radius: 10px;
  padding: 0.8rem 1rem; background: oklch(0.72 0.17 25 / 0.06);
}
.sec-danger-text strong { font-size: 0.875rem; }
.sec-danger .btn-sm { flex: none; }
.sec-block {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1rem;
}
.sec-block-actions { display: flex; gap: 0.4rem; flex: none; }

/* ---------- detail drawer ---------- */
.detail {
  width: min(560px, calc(100vw - 2rem)); margin: auto;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  padding: 0; box-shadow: 0 24px 60px oklch(0.08 0.02 262 / 0.6);
}
.detail::backdrop { background: oklch(0.1 0.02 262 / 0.55); backdrop-filter: blur(2px); }

/* ---------- ideas & roadmap ---------- */
.rm-section { margin-bottom: 1.6rem; }
.rm-section:last-child { margin-bottom: 0.25rem; }
.rm-head { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.rm-head h3 { font-size: 0.9375rem; font-weight: 700; }
.rm-sub { font-size: 0.75rem; color: var(--ink-dim); }
.rm-add { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.rm-add input { flex: 1; }
.rm-ideas { display: flex; flex-direction: column; gap: 0.4rem; }
.rm-idea {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  font-size: 0.8125rem;
}
.rm-idea.is-done .rm-idea-text { text-decoration: line-through; color: var(--ink-dim); }
.rm-idea-text { flex: 1; min-width: 0; }
.rm-idea-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); flex: none; margin: 0 0.15rem; }
.rm-check {
  width: 18px; height: 18px; flex: none; padding: 0; border-radius: 5px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--mint); font-size: 0.7rem; line-height: 1; display: inline-flex;
  align-items: center; justify-content: center;
}
.rm-check[data-done="1"] { background: var(--mint); border-color: var(--mint); color: oklch(0.2 0.03 262); }
.rm-del { flex: none; border: 0; background: none; color: var(--ink-dim); padding: 0 0.2rem; font-size: 0.75rem; }
.rm-del:hover { color: var(--down); background: none; }
.rm-empty { font-size: 0.8125rem; color: var(--ink-dim); }

/* Fit the dialog to the viewport so there's no giant page-height slider; instead
   the Ideas list and the roadmap (Shipped is long) each scroll inside their own box. */
#roadmap[open] { display: flex; flex-direction: column; overflow: hidden; }
#roadmap .detail-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#roadmap .rm-section:first-child { flex: none; }         /* Ideas — natural height */
#roadmap .rm-section:last-child { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rm-ideas { max-height: 22vh; overflow-y: auto; }        /* many ideas scroll, don't shove */
.rm-list {
  flex: 1; min-height: 0; overflow-y: auto;               /* the roadmap scroller */
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  padding: 0.75rem 0.9rem;
}
@media (max-width: 640px) {
  /* on phones let the whole dialog scroll — simpler than nested scrollers */
  #roadmap[open] { overflow-y: auto; }
  #roadmap .detail-body { display: block; overflow: visible; }
  #roadmap .rm-section:last-child { display: block; }
  .rm-ideas { max-height: none; }
  .rm-list { max-height: none; border: 0; padding: 0; }
}
.rm-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 1rem; }
.rm-bar span { display: block; height: 100%; background: var(--mint); border-radius: 99px; transition: width 400ms var(--ease); }
.rm-group { margin-bottom: 1.1rem; }
.rm-group:last-child { margin-bottom: 0; }
.rm-group-h {
  font-size: 0.6875rem; font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim);
  margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem;
}
.rm-group-h span {
  font-size: 0.625rem; padding: 0.05rem 0.4rem; border-radius: 99px;
  border: 1px solid var(--line); color: var(--ink-dim);
}
.rm-item { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.35rem 0; font-size: 0.8125rem; }
.rm-mark { flex: none; font-weight: 700; width: 1rem; text-align: center; }
.rm-done .rm-mark { color: var(--mint); }
.rm-done .rm-title { color: var(--ink-dim); }
.rm-doing .rm-mark { color: var(--warn); }
.rm-todo .rm-mark { color: var(--teal); }
.rm-title { min-width: 0; }

/* ---------- changelog ("What's new") ---------- */
/* wider than the shared .detail so PROJECT/PERIOD chips + date fit on one line each */
#changelog.detail { width: min(640px, calc(100vw - 2rem)); }
.cl-filters {
  display: flex; flex-direction: column; gap: 0;
  margin-bottom: 1.1rem;
}
.cl-filters:empty { display: none; }
/* one labelled row per filter dimension; a rule divides Project from Period */
.cl-row { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.7rem 0; }
.cl-row + .cl-row { border-top: 1px solid var(--line); }
.cl-row:first-child { padding-top: 0; }
.cl-row-label {
  flex: none; width: 4.25rem; padding-top: 0.35rem;
  font-family: var(--mono); font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim);
}
.cl-chip-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
/* chips + date share one box model so they sit on a common baseline */
#cl-filters .chip, .cl-date {
  height: 30px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; margin: 0;
}
/* id-scoped so it wins over the UA form-control margin that was floating it up */
#cl-filters .cl-date {
  width: auto; font-family: var(--mono); font-size: 0.75rem;
  padding: 0 0.7rem; margin: 0; border-radius: 99px; border: 1px solid var(--line);
  background: none; color: var(--ink-dim);
  color-scheme: dark; /* dark native calendar popup */
}
/* On mobile, lay the controls out 2-per-row so nothing crowds. */
@media (max-width: 480px) {
  .cl-row { flex-direction: column; gap: 0.45rem; }
  .cl-row-label { width: auto; padding-top: 0; }
  .cl-chip-group { display: grid; grid-template-columns: 1fr 1fr; }
  #cl-filters .chip, .cl-chip-group .cl-date { width: 100%; }
}
/* each day is its own card, Etch-changelog style: small dated rule, bold title, bulleted changes */
.cl-day {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  padding: 1rem 1.15rem 1.1rem; margin-bottom: 1rem;
}
.cl-date {
  font-size: 0.6875rem; font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.09em; color: var(--ink-dim);
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.55rem;
}
.cl-date::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.cl-day h3 { font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.75rem; }
.cl-day ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.cl-day li {
  font-size: 0.8125rem; line-height: 1.5; padding-left: 1rem; position: relative;
}
.cl-day li::before {
  content: ""; position: absolute; left: 0; top: 0.5em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--mint);
}
.cl-day li + li { border-top: 1px solid oklch(1 0 0 / 0.045); padding-top: 0.6rem; }
.cl-day li + li::before { top: calc(0.6rem + 0.5em); }
.cl-subject b { font-weight: 650; }
.cl-app {
  display: inline-block; font-family: var(--mono); font-size: 0.6563rem;
  color: var(--mint); border: 1px solid var(--line); border-radius: 99px;
  padding: 0.05rem 0.5rem; margin-right: 0.4rem; vertical-align: 1px;
  background: var(--surface-2); white-space: nowrap;
}
.cl-subject { color: var(--ink); }
.cl-hash { font-family: var(--mono); font-size: 0.6563rem; color: var(--ink-dim); margin-left: 0.45rem; }
.cl-empty { font-size: 0.8125rem; color: var(--ink-dim); }
.detail-body { padding: 1.1rem 1.25rem; }
.detail-facts {
  display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem;
  margin: 0 0 1.1rem; font-size: 0.8125rem;
}
.detail-facts dt { color: var(--ink-dim); font-family: var(--mono); font-size: 0.75rem; }
.detail-facts dd { margin: 0; color: var(--ink); }
.detail-facts dd.wrap { font-family: var(--mono); font-size: 0.6875rem; word-break: break-all; color: var(--ink-dim); }
.detail-logs-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.75rem; color: var(--ink-dim); font-family: var(--mono);
  margin-bottom: 0.4rem;
}
.detail-logs {
  margin: 0; max-height: 40vh; overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-family: var(--mono); font-size: 0.6875rem; line-height: 1.55;
  color: var(--ink-dim); white-space: pre-wrap; word-break: break-word;
}

/* ---------- drag to reorder ---------- */
.card[draggable="true"] { cursor: grab; }
.card.dragging { opacity: 0.5; cursor: grabbing; }

/* ---------- AI assistant ---------- */
.ai-fab {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 40;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1rem; border-radius: 99px;
  border: 1px solid var(--mint);
  background: var(--mint); color: oklch(0.2 0.03 262);
  font-weight: 600; font-size: 0.875rem;
  box-shadow: 0 8px 24px oklch(0.82 0.14 168 / 0.25);
}
.ai-fab:hover { filter: brightness(1.06); }
.ai {
  width: min(440px, calc(100vw - 2rem)); height: min(560px, calc(100dvh - 3rem));
  position: fixed; right: 1.25rem; bottom: 1.25rem; left: auto; top: auto; margin: 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); padding: 0;
  box-shadow: 0 24px 60px oklch(0.08 0.02 262 / 0.6);
}
/* Only lay it out when open; otherwise the UA rule (dialog:not([open])) hides it.
   Setting display on the base .ai would override that and keep it always visible. */
.ai[open] { display: flex; flex-direction: column; }
.ai-messages { flex: 1; overflow-y: auto; padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: 0.6rem; }
.ai-msg {
  max-width: 85%; padding: 0.55rem 0.8rem; border-radius: 12px;
  font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.ai-msg.user { align-self: flex-end; background: var(--mint); color: oklch(0.2 0.03 262); border-bottom-right-radius: 4px; }
.ai-msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.ai-msg.pending { color: var(--ink-dim); font-style: italic; }
.ai-usage {
  align-self: flex-start; margin-top: -0.35rem;
  font-family: var(--mono); font-size: 0.625rem; color: var(--ink-dim);
}
.ai-total {
  padding: 0.4rem 0.9rem; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-dim);
  white-space: nowrap; overflow-x: auto;
}
.ai-total:empty { display: none; }
.ai-total-btn {
  width: 100%; text-align: left; background: none; border: 0; padding: 0;
  font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-dim);
  display: flex; justify-content: space-between; gap: 0.5rem; cursor: pointer;
}
.ai-total-btn:hover { color: var(--ink); background: none; }
.ai-total-more { color: var(--teal); }
.usage-list { display: flex; flex-direction: column; }
.usage-row {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.5rem 0.25rem; border-bottom: 1px solid var(--line);
  font-size: 0.8125rem;
}
.usage-month { color: var(--ink); }
.usage-nums { font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-dim); }
.usage-total { border-bottom: 0; border-top: 1px solid var(--line); font-weight: 600; margin-top: 0.25rem; }
.usage-total .usage-nums, .usage-total span { color: var(--mint); }
.cost-add { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.cost-add input[type="text"] { flex: 1; }
.cost-add input[type="number"] { width: 5.5rem; }
.cost-rm { border: 0; background: none; color: var(--ink-dim); padding: 0 0.2rem; font-size: 0.7rem; }
.cost-rm:hover { color: var(--down); background: none; }
.ai-form { display: flex; gap: 0.5rem; padding: 0.8rem; border-top: 1px solid var(--line); }
.ai-form input { flex: 1; }
.set-head-actions { display: flex; align-items: center; gap: 0.25rem; }

/* AI settings */
.ais-hint { font-size: 0.6875rem; color: var(--ink-dim); font-family: var(--mono); }
.ais-keystatus {
  font-family: var(--mono); font-size: 0.75rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.45rem 0.6rem;
}
.ais-check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.75rem; color: var(--ink-dim); }
.ais-check input { width: auto; }
.ais-note { font-size: 0.75rem; color: var(--ink-dim); line-height: 1.5; }

/* ---------- command palette ---------- */
.palette {
  width: min(520px, calc(100vw - 2rem));
  margin: 12vh auto auto;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  padding: 0; box-shadow: 0 24px 60px oklch(0.08 0.02 262 / 0.6);
  overflow: hidden;
}
.palette::backdrop { background: oklch(0.1 0.02 262 / 0.55); backdrop-filter: blur(2px); }
#palette-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: none; padding: 1rem 1.15rem; font-size: 1rem;
}
#palette-input:focus { outline: none; border-color: var(--line); }
#palette-list { list-style: none; margin: 0; padding: 0.4rem; max-height: 45vh; overflow-y: auto; }
#palette-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: 0.55rem 0.75rem; border-radius: 8px; cursor: pointer;
}
#palette-list li.on { background: var(--surface-2); }
#palette-list li:hover { background: var(--surface-2); }
#palette-list .p-sub { font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-dim); }
#palette-list .p-empty { color: var(--ink-dim); cursor: default; justify-content: flex-start; }
#palette-list .p-empty:hover { background: none; }
.palette-hint {
  padding: 0.5rem 1.15rem; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-dim);
}

/* ---------- services ---------- */
.services { border-top: 1px solid var(--line); padding-top: 1.1rem; margin-bottom: 1.5rem; }
.services h2 {
  font-size: 0.8125rem; font-weight: 500; color: var(--ink-dim);
  font-family: var(--mono); margin-bottom: 0.7rem;
}
.service-links { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.service {
  position: relative;
  display: inline-flex; align-items: center; gap: 0.55rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface);
  padding: 0.4rem 0.7rem;
  font-size: 0.875rem;
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}
.service:hover { background: var(--surface-2); border-color: oklch(0.42 0.04 262); }
.svc-icon {
  position: relative; flex: none;
  width: 24px; height: 24px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2);
}
.svc-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.svc-mark {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--mono); font-size: 0.75rem; font-weight: 600; color: var(--teal);
}
.svc-edit {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; border: 0; padding: 0;
  background: oklch(0.15 0.03 262 / 0.72); color: var(--ink);
  font-size: 0.7rem; opacity: 0; transition: opacity 150ms var(--ease);
}
.service:hover .svc-edit { opacity: 0.7; }
.service:hover .svc-edit:hover { opacity: 1; }
.svc-link { display: inline-flex; align-items: baseline; gap: 0.4rem; text-decoration: none; color: var(--ink); }
.svc-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.svc-link b { font-weight: 600; }
.svc-link span { font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-dim); }
.svc-go { font-style: normal; font-size: 0.75rem; color: var(--teal); }

/* ---------- status ---------- */
.status { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--mono); font-size: 0.75rem; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-dim); }
.status.up { color: var(--mint); } .status.up .dot { background: var(--mint); }
.status.down { color: var(--down); }
.status.down .dot { background: var(--down); animation: pulse 1.6s var(--ease) infinite; }
.status.unknown { color: var(--ink-dim); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px oklch(0.72 0.17 25 / 0.18); } }

.hint { font-size: 0.8125rem; color: var(--warn); font-family: var(--mono); }
.hint:empty { display: none; }

/* "N hidden cards" reveal toggle under the grid */
.hidden-toggle { text-align: center; margin: -0.25rem 0 0; }
.hidden-toggle button {
  font-size: 0.75rem; font-family: var(--mono); color: var(--ink-dim);
  background: none; border: none; text-decoration: underline dotted; cursor: pointer;
}
.hidden-toggle button:hover { color: var(--ink); }
.card.is-hidden { opacity: 0.55; }
.card.is-hidden:hover { opacity: 0.85; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.panel {
  width: min(360px, 100%);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.75rem 1.5rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.panel .wordmark { justify-content: center; padding-bottom: 0.25rem; }
.panel form { display: flex; flex-direction: column; gap: 0.75rem; }
.panel label { font-size: 0.8125rem; color: var(--ink-dim); }
.panel .note { font-size: 0.8125rem; color: var(--ink-dim); text-align: center; }
.panel .error { font-size: 0.8125rem; color: var(--down); text-align: center; min-height: 1.2em; }
#code {
  font-family: var(--mono); font-size: 1.4rem; letter-spacing: 0.45em;
  text-align: center; padding-left: calc(0.75rem + 0.45em);
}
.swap { transition: opacity 180ms var(--ease); }
.swap.out { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
