:root {
  color-scheme: dark;
  --bg: #10121a;
  --panel: #171b27;
  --panel2: #1f2433;
  --ink: #f4f7fb;
  --text: #f4f7fb;
  --muted: #aeb8ca;
  --line: #2c3448;
  --accent: #8b5cf6;
  --accent2: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --ok: #22c55e;
  --shadow: rgba(0, 0, 0, 0.28);
  --radius-control: 12px;
  --radius-panel: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top left, #2b1754, transparent 38%), var(--bg);
  background-attachment: fixed;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}

a { color: #c4b5fd; text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #c4b5fd;
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 26, 0.92);
  backdrop-filter: blur(10px);
}

.site-header a { text-decoration: none; }
.wrap { width: min(1180px, calc(100% - 28px)); margin-inline: auto; }
.nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); font-size: 18px; font-weight: 900; }
.brand-logo { display: block; width: auto; height: 1.75rem; }
.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.nav-links a, .link-button { color: var(--muted); font-size: 14px; font-weight: 800; }
.nav-links form { margin: 0; }
.link-button { min-height: auto; padding: 0; border: 0; background: transparent; cursor: pointer; }

.main { padding: 26px 0 60px; }
.footer { padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.legal-page { max-width: 780px; margin-inline: auto; }
.legal-page h2 { margin-top: 24px; font-size: 1.25rem; }
.legal-page code { overflow-wrap: anywhere; }
.page-title { margin: 0 0 18px; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; }
.section-title { margin: 26px 0 12px; font-size: 1.35rem; }

.hero {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 28%, transparent), rgba(31, 36, 51, 0.92));
  box-shadow: 0 12px 30px var(--shadow);
}
.hero h1 { margin: 8px 0; font-size: clamp(28px, 5vw, 50px); line-height: 1.08; }
.hero p { max-width: 820px; color: var(--muted); line-height: 1.55; }
.compact-hero h1 { font-size: clamp(28px, 4vw, 42px); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.stack { display: grid; gap: 18px; }
.card, .form-panel, .table-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: rgba(23, 27, 39, 0.94);
  box-shadow: 0 12px 26px var(--shadow);
}
.card h1, .card h2, .card h3, .form-panel h1, .form-panel h2 { margin-top: 0; }
.card p, .card li { overflow-wrap: anywhere; }
.form-panel, .table-panel, .compact-panel, .group-card { margin-top: 18px; }
.narrow-card { max-width: 560px; margin-inline: auto; }
.muted, .help { color: var(--muted); }
.small, .help { font-size: 13px; }
.stat { font-size: 36px; font-weight: 900; }

.badge, .status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel2);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.ok, .validation-ok, .status-approved, .status-committed { border-color: rgba(34,197,94,.45); background: rgba(34,197,94,.18); color: #dcfce7; }
.badge.warn, .validation-warning, .status-reviewing { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.18); color: #fef3c7; }
.badge.danger, .validation-error, .status-rejected, .status-discarded { border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.18); color: #fee2e2; }

.button, .btn, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}
.button:hover, .btn:hover { text-decoration: none; filter: brightness(1.08); }
.button.secondary, .btn.secondary { border: 1px solid var(--line); background: var(--panel2); color: var(--text); }
.button.danger, .btn.danger { background: var(--danger); }
.button.success, .btn.success { background: var(--accent2); }
.button.warning, .btn.warning { background: var(--warning); color: #19150a; }
.small-button { min-height: 34px; padding: 6px 9px; font-size: 12px; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.actions, .btnrow, .compact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }

.form, .form-panel form:not(.inline-form) { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 800; color: var(--text); }
input:not([type="hidden"]):not([type="radio"]):not([type="checkbox"]), textarea, select {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1320;
  color: var(--text);
  font: inherit;
}
textarea { min-height: 130px; resize: vertical; }
fieldset { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
legend { padding: 0 8px; font-weight: 900; }
.checkline, .choice { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; }
.checkline input, .choice input { width: auto; flex: 0 0 auto; margin-top: .35em; }
.code-settings { display: grid; gap: 12px; margin-top: 18px; background: rgba(15,19,32,.72); }

.choice {
  grid-template-columns: 24px 1fr;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1320;
  box-shadow: none;
  cursor: pointer;
}
.choice:hover { border-color: color-mix(in srgb, var(--accent) 80%, white); }

.flash, .message { margin: 0 0 16px; padding: 12px 14px; border-radius: 14px; font-weight: 800; }
.flash.success { border: 1px solid rgba(34,197,94,.4); background: rgba(34,197,94,.18); }
.flash.error, .message.error { border: 1px solid rgba(239,68,68,.4); background: rgba(239,68,68,.18); }
.message.warning { border: 1px solid rgba(245,158,11,.4); background: rgba(245,158,11,.18); }

.table-panel, .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; }
.table-panel { padding: 0; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: rgba(31,36,51,.85); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
.empty-cell { color: var(--muted); text-align: center; }

.workflow { counter-reset: step; display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.workflow li { counter-increment: step; padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: #0f1320; }
.workflow li::before { content: counter(step); display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 900; }
.danger-zone { border-color: rgba(239,68,68,.45); }
.danger-zone h2, .danger-zone h3 { color: #fecaca; }

.hero-image { display: block; width: 100%; max-height: 420px; object-fit: contain; border: 1px solid var(--line); border-radius: 16px; background: rgba(0,0,0,.18); }
.card-cover { max-height: 210px; margin-bottom: 14px; object-fit: cover; }
.cover-preview { display: block; max-width: 520px; max-height: 320px; margin: .5rem 0; border: 1px solid var(--line); border-radius: 14px; }
.entry-image { display: block; max-width: 240px; max-height: 180px; border-radius: 12px; }
.rules-box { padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 14px; background: #0f1320; }
.rules-details { margin-top: 14px; }
.rules-details summary { color: #c4b5fd; font-weight: 900; cursor: pointer; }

.import-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 18px 0; }
.import-row-header, .split-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.import-row dl, .public-entry-fields { display: grid; grid-template-columns: minmax(100px,.35fr) minmax(0,1fr); gap: 4px 10px; }
.import-row dt, .public-entry-fields dt { font-weight: 800; }
.import-row dd, .public-entry-fields dd { margin: 0; overflow-wrap: anywhere; }
.mapping-summary .mapped { color: #86efac; }
.mapping-summary .unmapped { color: #fca5a5; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 680px) {
  .nav { align-items: flex-start; flex-direction: column; padding: 14px 0; }
  .nav-links { width: 100%; }
  .hero { padding: 20px; }
  .import-row-header { flex-direction: column; }
  .import-row dl, .public-entry-fields { grid-template-columns: 1fr; }
  table { min-width: 880px; }
}
