:root {
  --bg: #0c0d10;
  --bg-card: #16181d;
  --bg-card-hover: #1c1f26;
  --bg-input: #0f1116;
  --border: #262931;
  --border-strong: #353945;
  --text: #e7e9ee;
  --text-dim: #9aa0ac;
  --text-mute: #6b7280;
  --accent: #d6b370;
  --accent-hover: #e2c184;
  --accent-soft: rgba(214, 179, 112, 0.15);
  --danger: #e57373;
  --success: #6ec99a;
  --warning: #e3b46a;
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ────────────────────────────────────────────────────────────── */
header.site {
  padding: 24px 48px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-size: 18px; font-weight: 600; letter-spacing: 0.4px; }
.brand .dot { color: var(--accent); }
nav.site a {
  margin-left: 24px;
  color: var(--text-dim);
  font-size: 14px;
}
nav.site a:hover, nav.site a.active {
  color: var(--text);
  text-decoration: none;
}
nav.site .user {
  margin-left: 24px;
  color: var(--text-mute);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
main { max-width: 1120px; margin: 0 auto; padding: 48px 48px 96px; }
main.wide { max-width: 1280px; }
h1 {
  font-size: 32px;
  line-height: 1.2;
  margin: 0 0 16px;
  font-weight: 700;
  letter-spacing: -0.4px;
}
h1.hero { font-size: 40px; letter-spacing: -0.5px; }
h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px;
}
.lead {
  color: var(--text-dim);
  font-size: 17px;
  max-width: 720px;
  margin: 0 0 40px;
}
.section-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 16px;
}

/* ── Cards / Grid ──────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  transition: background .15s, border-color .15s, transform .15s;
}
.card.active { cursor: pointer; }
.card.active:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.card.disabled { opacity: 0.55; }
.card .icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.card p { margin: 0; color: var(--text-dim); font-size: 14px; }
.badge {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(255,255,255,0.06); color: var(--text-dim);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.success { background: rgba(110, 201, 154, 0.15); color: var(--success); }
.badge.warning { background: rgba(227, 180, 106, 0.15); color: var(--warning); }
.badge.danger  { background: rgba(229, 115, 115, 0.18); color: var(--danger); }
.card .badge.top { position: absolute; top: 14px; right: 14px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: transparent; color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
}
.btn:hover { background: rgba(255,255,255,0.04); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); color: #1a1306; border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #1a1306; }
.btn.danger { color: var(--danger); border-color: rgba(229,115,115,0.4); }
.btn.danger:hover { background: rgba(229,115,115,0.1); color: var(--danger); border-color: var(--danger); }
.btn.ghost { border-color: transparent; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label,
.field .label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 6px;
}
.input,
.textarea,
.select {
  width: 100%;
  font: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  transition: border-color .15s;
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
}
.textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.textarea.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }

/* ── Form sections (authoring) ─────────────────────────────────────────── */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
}
.form-section > h2 {
  margin: 0 0 4px;
  font-size: 18px;
  display: flex; align-items: baseline; gap: 12px;
}
.form-section > h2 .tag {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.form-section > .sub {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 20px;
}

/* ── Tables (compact form tables) ──────────────────────────────────────── */
table.compact {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
table.compact th, table.compact td {
  text-align: left;
  font-size: 13px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
table.compact th { color: var(--text-dim); font-weight: 500; }
table.compact td input,
table.compact td textarea {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font: inherit;
  padding: 6px 8px;
  border-radius: 6px;
}
table.compact td input:focus,
table.compact td textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-input);
}

/* ── List rows (dashboard) ─────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}
.list-row .name { flex: 1; min-width: 0; }
.list-row .name b { display: block; font-weight: 600; }
.list-row .name span { font-size: 12px; color: var(--text-mute); }
.list-row .actions { display: flex; gap: 8px; }

/* ── Toast / Alert ─────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  z-index: 9999; max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.empty {
  text-align: center;
  padding: 64px 16px;
  color: var(--text-dim);
}

/* ── Footer ────────────────────────────────────────────────────────────── */
footer.site {
  padding: 28px 48px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

@media (max-width: 720px) {
  header.site, main, footer.site { padding-left: 20px; padding-right: 20px; }
  main { padding-top: 32px; }
  h1.hero { font-size: 28px; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  nav.site .user { display: none; }
}
