/* Dark-first, generous line length for reading long articles, mobile first.
   SPEC.md §12. No framework, no build step -- this file is the whole design. */

:root {
  --bg: #14161a;
  --bg-raised: #1b1e24;
  --bg-sunken: #101216;
  --border: #2a2f38;
  --text: #e4e6eb;
  --text-dim: #9aa1ad;
  --text-faint: #6b7280;
  --accent: #7aa2f7;
  --accent-dim: #3d5a99;
  --mine: #9ece6a;
  --external: #e0af68;
  --danger: #f7768e;
  --radius: 8px;
  --measure: 68ch;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfbfa;
    --bg-raised: #ffffff;
    --bg-sunken: #f0f0ee;
    --border: #dcdcd8;
    --text: #1c1e21;
    --text-dim: #5c6370;
    --text-faint: #8a919e;
    --accent: #2f5fd0;
    --accent-dim: #b9c9f0;
    --mine: #3d7a2a;
    --external: #9a6b12;
    --danger: #c2334d;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  padding-bottom: 4rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- layout --------------------------------------------------------------- */

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1rem;
}

header.top {
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.top .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-right: auto;
}

nav.top-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

nav.top-nav a {
  color: var(--text-dim);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.94rem;
}
nav.top-nav a:hover { background: var(--bg-raised); text-decoration: none; }
nav.top-nav a[aria-current="page"] { color: var(--text); background: var(--bg-raised); }

main { padding-top: 1.5rem; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 2rem 0 0.75rem; color: var(--text-dim);
     text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
h2:first-child { margin-top: 0; }

/* --- cards ---------------------------------------------------------------- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
}

.card-title { font-weight: 600; margin-bottom: 0.2rem; }
.card-meta { color: var(--text-faint); font-size: 0.85rem; }
.card-body { color: var(--text-dim); margin-top: 0.4rem; }

/* --- badges --------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  border: 1px solid currentColor;
  vertical-align: 0.08em;
}
/* origin is load-bearing: at a glance you must know whose thinking this is. */
.badge-mine { color: var(--mine); }
.badge-external { color: var(--external); }
.badge-quiet { color: var(--text-faint); }
.badge-danger { color: var(--danger); }

/* --- stats ---------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}
.stat .n { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.stat .label { color: var(--text-faint); font-size: 0.8rem; }
.stat.warn .n { color: var(--external); }
.stat.bad .n { color: var(--danger); }

/* --- forms ---------------------------------------------------------------- */

input[type="text"], input[type="url"], input[type="password"], textarea {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.6rem 0.7rem;
  font: inherit;
}
input:focus, textarea:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: -1px;
  border-color: var(--accent);
}

button, .btn {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.secondary {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
  font-weight: 500;
}
button.secondary:hover { background: var(--bg-raised); filter: none; }

.field { margin-bottom: 0.75rem; }
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.row { display: flex; gap: 0.5rem; align-items: flex-start; }
.row > :first-child { flex: 1; }

.error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.notice {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.empty {
  color: var(--text-faint);
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.94rem;
}

/* --- note detail ---------------------------------------------------------- */

.note-content {
  white-space: pre-wrap;
  line-height: 1.75;
}

details.raw { margin-top: 2rem; }
details.raw summary {
  cursor: pointer;
  color: var(--text-faint);
  font-size: 0.88rem;
}
pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  overflow-x: auto;
  font: 0.82rem/1.5 var(--mono);
}

code { font-family: var(--mono); font-size: 0.88em; }

.url {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  word-break: break-all;
}

/* --- login ---------------------------------------------------------------- */

.login-wrap {
  max-width: 22rem;
  margin: 5rem auto;
  padding: 0 1rem;
}

/* --- htmx ----------------------------------------------------------------- */

.htmx-request { opacity: 0.55; transition: opacity 120ms ease-in; }
