:root {
  color-scheme: dark;
  --bg: #101214;
  --surface: #181b1f;
  --surface-2: #20242a;
  --border: #2c323a;
  --text: #e8eaed;
  --muted: #98a1ad;
  --accent: #ff7a45;
  --accent-ink: #1a0d06;
  --good: #3ecf8e;
  --warn: #f2c14e;
  --bad: #f06a6a;
  --fb: #5b8def;
  --ig: #e667a8;
  --radius: 10px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: inherit; }
h1 { font-size: 1.35rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: 0 0 10px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.accent { color: var(--accent); }
.text-bad { color: var(--bad); }
.text-good { color: var(--good); }
.text-warn { color: var(--warn); }
[hidden] { display: none !important; }

/* ---- shell: bottom tabs on phones, top bar from 720px */
.shell { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brandmark { font-weight: 700; letter-spacing: -0.02em; text-decoration: none; margin-right: auto; }
.brandmark span { color: var(--accent); }
.pill {
  font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.fb { color: var(--fb); border-color: color-mix(in srgb, var(--fb) 45%, transparent); }
.pill.ig { color: var(--ig); border-color: color-mix(in srgb, var(--ig) 45%, transparent); }

.nav {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; text-align: center; padding: 12px 4px; text-decoration: none;
  color: var(--muted); font-size: 0.85rem; font-weight: 550;
}
.nav a.active { color: var(--accent); }
main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 18px 16px 90px; }

@media (min-width: 720px) {
  .nav { position: static; border: 0; padding: 0; background: none; gap: 4px; }
  .nav a { flex: none; padding: 6px 12px; border-radius: 7px; }
  .nav a.active { background: var(--surface-2); }
  .brandmark { margin-right: 16px; }
  .topbar .spacer { margin-left: auto; }
  main { padding: 26px 20px 40px; }
}

.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { margin-right: auto; }

/* ---- controls */
button, .button {
  font: inherit; font-weight: 550; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; min-height: 40px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .button:hover { border-color: #3d4550; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.ghost, .button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.ghost:hover, .button.ghost:hover { color: var(--text); }
button.wide { width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: block; font-size: 0.85rem; font-weight: 550; margin-bottom: 5px; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=time], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 14px; }
@media (min-width: 620px) { .row.two { grid-template-columns: 1fr 1fr; } }

.check { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 0.95rem; margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { margin: 0; }
.days input { position: absolute; opacity: 0; }
.days span {
  display: inline-block; min-width: 44px; text-align: center; padding: 8px 6px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-weight: 550;
}
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.times { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.times .time { display: flex; align-items: center; gap: 2px; }
.times input { width: 118px; }

/* ---- surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid .card { margin: 0; }
a.card { display: block; text-decoration: none; }
a.card:hover { border-color: #3d4550; }
.card h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.actions .push { margin-left: auto; }

.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.item:first-of-type { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.sub { padding-left: 34px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.avatar.empty { display: grid; place-items: center; font-weight: 700; color: var(--muted); }

.notice { border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: 8px; padding: 11px 13px; margin-bottom: 14px; background: var(--surface); }
.notice.bad { border-left-color: var(--bad); }
.notice.info { border-left-color: var(--accent); }
.notice code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.85em; word-break: break-all; }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty h2 { color: var(--text); justify-content: center; }

/* ---- log */
.log { border-top: 1px solid var(--border); padding: 10px 0; }
.log:first-child { border-top: 0; }
.log summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; list-style: none; }
.log summary::-webkit-details-marker { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; align-self: center; }
.fail > .dot, .fail summary .dot { background: var(--bad); }
.log pre { margin: 8px 0 0; padding: 10px; background: var(--bg); border-radius: 8px; overflow-x: auto; font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; }

/* ---- login and setup */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login .card.setup { max-width: 560px; }
.login h1 { margin-bottom: 4px; }
.checkrow { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.checkrow .dot { margin-top: 7px; align-self: flex-start; }

#toasts { position: fixed; left: 0; right: 0; bottom: 76px; display: grid; justify-items: center; gap: 8px; z-index: 20; pointer-events: none; padding: 0 16px; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; box-shadow: 0 8px 24px #0008; max-width: 520px; }
.toast.bad { border-color: var(--bad); }
@media (min-width: 720px) { #toasts { bottom: 24px; } }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise 0.18s ease-out; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
