:root {
  --bg: #faf9f7;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e5e2dc;
  --accent: #8a4baf;
  --accent-dark: #6f3890;
  --ok: #2f7d4f;
  --warn: #b26a00;
  --bad: #b3261e;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; letter-spacing: 0.01em; }
.topbar .brand small { display: block; font-weight: 400; color: var(--muted); font-size: 0.72rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; font-size: 0.95rem; }
.topbar .who { color: var(--muted); font-size: 0.85rem; }

.page { max-width: 52rem; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page.wide { max-width: 68rem; }

h1 { font-size: 1.55rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; }
p.lead { color: var(--muted); margin-top: 0.25rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.panel h3 { margin: 0 0 0.5rem; font-size: 1.02rem; }

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

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.9rem 0 0.3rem; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 7rem; font-family: var(--mono); font-size: 0.9rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-dark); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover, .btn.ghost:hover { border-color: var(--muted); background: transparent; }
button.danger, .btn.danger { background: var(--bad); }
button.small, .btn.small { padding: 0.3rem 0.7rem; font-size: 0.82rem; }

.form-actions { display: flex; gap: 0.6rem; margin-top: 1.1rem; align-items: center; }

.error { background: #fdecea; border: 1px solid #f3c2bd; color: var(--bad); padding: 0.6rem 0.85rem; border-radius: var(--radius); margin: 0.8rem 0; }
.ok-msg { background: #eaf6ee; border: 1px solid #bfe3cb; color: var(--ok); padding: 0.6rem 0.85rem; border-radius: var(--radius); margin: 0.8rem 0; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- lists */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card h4 { margin: 0 0 0.25rem; font-size: 1.02rem; }
.card .meta { color: var(--muted); font-size: 0.82rem; display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
}
.badge.note { background: #efe7f7; color: var(--accent-dark); }
.badge.reference { background: #e6f0f7; color: #245a7a; }
.badge.ch { background: #f2f0ea; color: var(--muted); }
.badge.status { text-transform: none; letter-spacing: 0; font-weight: 600; }
.badge.status.sent, .badge.status.pending { background: #eaf2fb; color: #245a7a; }
.badge.status.accepted { background: #eaf6ee; color: var(--ok); }
.badge.status.expired, .badge.status.revoked { background: #fdecea; color: var(--bad); }

.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters button { padding: 0.32rem 0.75rem; font-size: 0.85rem; background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.filters button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------------------------------------------------------------- content */

.content-body { line-height: 1.7; }
.content-body img { max-width: 100%; }
.content-body pre { background: #f5f3ef; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; overflow-x: auto; font-family: var(--mono); font-size: 0.88rem; }
.content-body code { font-family: var(--mono); font-size: 0.9em; background: #f5f3ef; padding: 0.1rem 0.3rem; border-radius: 4px; }
.content-body blockquote { margin: 0; padding: 0 1rem; border-left: 3px solid var(--line); color: var(--muted); }

.comment { border-top: 1px solid var(--line); padding: 0.8rem 0; }
.comment .meta { font-size: 0.8rem; color: var(--muted); display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }

/* ---------------------------------------------------------------- tables */

table.list { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.list th { text-align: left; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.4rem 0.6rem; border-bottom: 2px solid var(--line); }
table.list td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1.2rem; }
.tabs button { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.results { margin: 0.9rem 0; max-height: 14rem; overflow-y: auto; font-size: 0.88rem; font-family: var(--mono); }
.results .ok { color: var(--ok); }
.results .bad { color: var(--bad); }

.preview { border: 1px dashed var(--line); border-radius: var(--radius); padding: 0.9rem 1.1rem; margin-top: 0.8rem; background: var(--panel); }

footer { margin-top: 3rem; color: var(--muted); font-size: 0.8rem; text-align: center; }
