:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f7faff;
  --text: #172033;
  --muted: #52627a;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --line: #d6e0ee;
  --danger: #b91c1c;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, select, input { min-height: 46px; }
button, .admin-back { border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; background: var(--surface); color: var(--text); font-weight: 800; cursor: pointer; }
button:hover, .admin-back:hover { border-color: var(--primary); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(37,99,235,.35); outline-offset: 3px; }

.admin-skip { position: fixed; z-index: 20; top: 8px; left: 8px; transform: translateY(-160%); padding: 10px 14px; border-radius: 8px; background: var(--surface); color: var(--primary); font-weight: 900; }
.admin-skip:focus { transform: none; }
.admin-header { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px clamp(14px,4vw,42px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
.admin-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.15rem; font-weight: 900; text-decoration: none; }
.admin-brand img { width: 46px; height: 46px; object-fit: contain; }
.admin-back { color: var(--primary); text-decoration: none; }
.admin-main { width: min(1500px, 96vw); margin: 0 auto; padding: clamp(24px,5vw,56px) 0; }
.admin-intro { max-width: 900px; margin-bottom: 26px; }
.admin-kicker { color: var(--primary); font-size: .82rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.admin-intro h1 { margin: 8px 0 12px; font-size: clamp(2rem,5vw,3.6rem); line-height: 1.05; }
.admin-intro p { margin: 0; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.admin-warning { margin-top: 16px; padding: 12px 14px; border: 1px solid #fbbf24; border-radius: 10px; background: #fffbeb; color: #78350f; }
.editor-shell { display: grid; grid-template-columns: minmax(270px, 360px) minmax(0, 1fr); min-height: 680px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 18px 50px rgba(15,23,42,.08); }
.editor-sidebar { display: flex; min-width: 0; flex-direction: column; gap: 14px; padding: 20px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.admin-field { display: grid; gap: 6px; min-width: 0; font-weight: 800; }
.admin-field select, .admin-field input, .admin-field textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); color: var(--text); }
.record-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.record-count { margin: 0; color: var(--muted); font-size: .9rem; }
.record-list { display: grid; align-content: start; gap: 6px; min-height: 320px; max-height: 640px; overflow: auto; padding-right: 4px; }
.record-list button { min-height: 44px; text-align: left; font-weight: 700; overflow-wrap: anywhere; }
.record-list button[aria-selected="true"] { border-color: var(--primary); background: #dbeafe; color: #1e3a8a; }
.record-editor { display: grid; align-content: start; gap: 14px; min-width: 0; padding: clamp(20px,4vw,34px); }
.record-editor-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.record-editor-heading h2 { margin: 5px 0 0; overflow-wrap: anywhere; }
.danger { border-color: #fecaca; color: var(--danger); }
.editor-field textarea { min-height: 440px; resize: vertical; font-family: "Cascadia Code", Consolas, monospace; font-size: .9rem; line-height: 1.5; tab-size: 2; }
.editor-help { margin: -4px 0 0; color: var(--muted); font-size: .9rem; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.primary { border-color: var(--primary); background: var(--primary); color: white; }
.primary:hover { background: var(--primary-dark); }
.admin-status { min-height: 1.5em; margin: 0; color: var(--primary); font-weight: 800; }
.admin-status[data-state="error"] { color: var(--danger); }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .editor-shell { grid-template-columns: minmax(0,1fr); }
  .editor-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .record-list { max-height: 300px; }
  .editor-actions { display: grid; grid-template-columns: minmax(0,1fr); }
  .record-editor-heading { align-items: stretch; flex-direction: column; }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg:#07111f; --surface:#0f1d31; --surface-soft:#14243b; --text:#f8fafc; --muted:#c3cfdf; --primary:#93c5fd; --primary-dark:#60a5fa; --line:#2d4464; --danger:#fca5a5; }
  .admin-header { background: rgba(15,29,49,.94); }
  .admin-warning { border-color:#d97706; background:#431407; color:#ffedd5; }
  .record-list button[aria-selected="true"] { background:#173c66; color:#dbeafe; }
}
