:root {
  --bg: #e9eef0;
  --surface: #f7f9fa;
  --ink: #101b22;
  --muted: #566871;
  --line: #c3cfd5;
  --accent: #2436e8;
  --accent-ink: #ffffff;
  --mark: #d8f03a;
  --mark-ink: #101b22;
  --dot: #b7c5cc;
  --danger: #b3261e;
  --ok: #17693a;
  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root:not([data-theme="light"]) {
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1317;
    --surface: #131d23;
    --ink: #e6eef2;
    --muted: #93a5af;
    --line: #26353d;
    --accent: #8c98ff;
    --accent-ink: #0c1317;
    --mark: #c5e02b;
    --dot: #22323a;
    --danger: #ff8a80;
    --ok: #6fd39a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--body);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
button, input, textarea { font: inherit; color: inherit; }

/* ---------- header ---------- */
#top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem); flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font: 800 1.35rem/1 var(--display); text-decoration: none; color: var(--ink); letter-spacing: -0.02em; }
.nav { display: flex; align-items: center; gap: 0.5rem 1.1rem; flex-wrap: wrap; font-size: 0.95rem; }
.nav a { color: var(--ink); text-decoration-color: var(--line); text-underline-offset: 4px; }
.nav a:hover { text-decoration-color: var(--accent); }
.who { color: var(--muted); font-size: 0.85rem; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  padding: 0.5rem 0.95rem; border-radius: 8px; cursor: pointer; font-weight: 500; text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); color: var(--accent-ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--bg); }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.875rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- home ---------- */
.home {
  min-height: calc(100vh - 8rem);
  display: flex; flex-direction: column; justify-content: center;
  padding: 2rem clamp(1rem, 6vw, 5rem) 4rem;
  background-image: radial-gradient(var(--dot) 1.6px, transparent 1.8px);
  background-size: 22px 22px;
  background-position: 0 0;
}
.wordmark { margin: 0 0 1.4rem; line-height: 0; }
.wordmark img { width: clamp(190px, 30vw, 300px); height: auto; border-radius: 50%; background: #fff; display: block; box-shadow: 0 0 0 3px var(--ink); }
.lede { max-width: 34rem; margin: 0 0 1.6rem; color: var(--muted); font-size: 1.1rem; }

.searchbox {
  display: flex; max-width: 46rem; width: 100%;
  background: var(--surface); border: 2px solid var(--ink); border-radius: 12px; overflow: hidden;
  box-shadow: 6px 6px 0 var(--ink);
}
.searchbox:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }
.searchbox input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 1rem 1.1rem; font-size: 1.15rem; outline: none;
}
.searchbox button {
  border: 0; border-left: 2px solid var(--ink); background: var(--mark); color: var(--mark-ink);
  padding: 0 1.4rem; font-weight: 600; cursor: pointer; font-size: 1rem;
}
.searchbox button:hover { filter: brightness(.95); }
.stats { color: var(--muted); font-size: 0.9rem; margin: 1.6rem 0 0.4rem; }
.addlink { align-self: flex-start; margin-top: .6rem; }

/* ---------- results ---------- */
.results-wrap { padding: 0.5rem clamp(1rem, 4vw, 2.5rem) 4rem; max-width: 62rem; }
.results-wrap .searchbox { box-shadow: 4px 4px 0 var(--ink); margin-bottom: 1rem; }
.meta-line { color: var(--muted); font-size: 0.875rem; margin: 0 0 1.4rem; }
.result { margin: 0 0 1.7rem; max-width: 46rem; }
.result .url { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; margin: 0 0 .1rem; }
.result h3 { margin: 0 0 .2rem; font: 600 1.25rem/1.25 var(--display); }
.result h3 a { text-decoration: none; }
.result h3 a:hover { text-decoration: underline; }
.result p.snippet { margin: 0; color: var(--ink); opacity: .86; overflow-wrap: anywhere; }
mark { background: var(--mark); color: var(--mark-ink); padding: 0 .12em; border-radius: 3px; }
.empty { max-width: 34rem; }
.empty h2 { font: 800 1.6rem/1.2 var(--display); margin: 0 0 .4rem; }

/* ---------- panels (add / manage) ---------- */
.page { padding: 1rem clamp(1rem, 4vw, 2.5rem) 4rem; max-width: 52rem; }
.page h1 { font: 800 clamp(2rem, 5vw, 3rem)/1.05 var(--display); letter-spacing: -0.03em; margin: 0.5rem 0 .6rem; }
.page p.intro { color: var(--muted); max-width: 38rem; margin-top: 0; }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem; margin: 1rem 0; }
label { display: block; font-weight: 600; margin: 0 0 .25rem; }
.field { margin-bottom: 1rem; }
.field input, .field textarea {
  width: 100%; padding: .65rem .75rem; background: var(--bg); border: 1.5px solid var(--line); border-radius: 8px;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.hint { color: var(--muted); font-size: .875rem; margin: .25rem 0 0; }
.notice { border-left: 4px solid var(--accent); background: var(--surface); padding: .8rem 1rem; border-radius: 0 8px 8px 0; margin: 1rem 0; }
.notice.warn { border-color: var(--danger); }
.err { color: var(--danger); margin: .5rem 0 0; min-height: 1.4em; }

.tabs { display: flex; gap: .5rem; margin: 1.2rem 0 .4rem; border-bottom: 1.5px solid var(--line); }
.tab {
  background: none; border: 0; padding: .55rem .9rem; cursor: pointer; font-weight: 500; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1.5px;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.row { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; padding: .9rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row:last-child { border-bottom: 0; }
.row .info { min-width: 0; flex: 1 1 18rem; }
.row .info a { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: .85rem; margin: .1rem 0 0; overflow-wrap: anywhere; }
.row .acts { display: flex; gap: .5rem; }
.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; border: 1.5px solid currentColor; }
.badge.pending { color: var(--muted); }
.badge.approved { color: var(--ok); }
.badge.denied { color: var(--danger); }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline-form input { flex: 1 1 16rem; padding: .55rem .7rem; background: var(--bg); border: 1.5px solid var(--line); border-radius: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 140%);
  background: var(--ink); color: var(--bg); padding: .65rem 1rem; border-radius: 8px; max-width: min(90vw, 28rem);
  transition: transform .2s ease, visibility .2s; z-index: 10; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

@media (max-width: 520px) {
  .searchbox button { padding: 0 1rem; }
  .searchbox { box-shadow: 4px 4px 0 var(--ink); }
}

.brand img { border-radius: 50%; background: #fff; }
