:root {
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ============ DARK (по умолчанию, если нет сохранённого выбора и система тёмная) ============ */
:root[data-theme="dark"] {
  --bg: #14171C;
  --surface: #1B1F26;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: #E7E9EC;
  --text-muted: #9AA2AC;
  --text-faint: #6B7280;
  --accent: #3B6E8F;
  --accent-hover: #4d84a8;
  --accent-strong: #E8590C;
  --green-rgb: 34, 197, 94;
  --amber-rgb: 242, 194, 48;
  --red-rgb: 239, 68, 68;
  --green: rgb(var(--green-rgb));
  --amber: rgb(var(--amber-rgb));
  --red: rgb(var(--red-rgb));
  --radius: 10px;
  --radius-sm: 6px;
}

/* ============ LIGHT ============ */
:root[data-theme="light"] {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --border: #D8DCE1;
  --border-strong: #1B4F72;
  --text: #1E2530;
  --text-muted: #5A6472;
  --text-faint: #8A93A0;
  --accent: #1B4F72;
  --accent-hover: #163d59;
  --accent-strong: #D9622B;
  --green-rgb: 21, 128, 61;
  --amber-rgb: 180, 83, 9;
  --red-rgb: 185, 28, 28;
  --green: rgb(var(--green-rgb));
  --amber: rgb(var(--amber-rgb));
  --red: rgb(var(--red-rgb));
  --radius: 2px;
  --radius-sm: 2px;
}

/* Фоллбэк до отработки JS / без JS вовсе */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #14171C; --surface: #1B1F26; --border: rgba(255,255,255,0.08); --border-strong: rgba(255,255,255,0.2);
    --text: #E7E9EC; --text-muted: #9AA2AC; --text-faint: #6B7280;
    --accent: #3B6E8F; --accent-hover: #4d84a8; --accent-strong: #E8590C;
    --green-rgb: 34,197,94; --amber-rgb: 242,194,48; --red-rgb: 239,68,68;
    --green: rgb(var(--green-rgb)); --amber: rgb(var(--amber-rgb)); --red: rgb(var(--red-rgb));
    --radius: 10px; --radius-sm: 6px;
  }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #F7F5F0; --surface: #FFFFFF; --border: #D8DCE1; --border-strong: #1B4F72;
    --text: #1E2530; --text-muted: #5A6472; --text-faint: #8A93A0;
    --accent: #1B4F72; --accent-hover: #163d59; --accent-strong: #D9622B;
    --green-rgb: 21,128,61; --amber-rgb: 180,83,9; --red-rgb: 185,28,28;
    --green: rgb(var(--green-rgb)); --amber: rgb(var(--amber-rgb)); --red: rgb(var(--red-rgb));
    --radius: 2px; --radius-sm: 2px;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background-color .25s ease, color .25s ease;
}

/* Плавный переход темы — на всех элементах, у которых меняется цвет/фон/рамка */
header, main, .card, .btn, .btn-secondary, input, table, th, td, .status, form,
nav a, nav button, .brand {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 64px;
  border-bottom: 1px solid var(--border);
}
:root[data-theme="light"] header { border-bottom: 2px solid var(--border-strong); }

header .brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
:root[data-theme="dark"] header .brand::before { content: "> "; color: var(--accent); }
:root[data-theme="dark"] header .brand::after {
  content: "_"; color: var(--accent-strong); margin-left: 2px;
  animation: cursorBlink 1.1s steps(1) infinite;
}
:root[data-theme="light"] header .brand {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 1.05rem;
}
@keyframes cursorBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

nav { display: flex; align-items: center; gap: 32px; }
nav a, nav button {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
nav a:hover, nav button:hover { color: var(--text); }
nav a.active, :root[data-theme="light"] nav a.active { color: var(--accent); font-weight: 600; }

#theme-toggle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  background: transparent;
}
#theme-toggle:hover { color: var(--text); border-color: var(--text-muted); }

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px;
}

.hero {
  text-align: center;
  padding: 56px 0 64px;
}
.hero h1 {
  font-family: var(--font-heading);
  font-size: 2.1rem;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.2;
}
.hero p {
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 28px;
}
:root[data-theme="light"] .hero {
  text-align: left;
  border-left: 2px dashed var(--border);
  padding-left: 32px;
  margin-left: 8px;
}
:root[data-theme="light"] .hero p { margin-left: 0; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
}
:root[data-theme="light"] .card::before {
  content: "";
  position: absolute; top: 12px; right: 12px;
  width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid var(--accent-strong);
}
.card h3 {
  font-family: var(--font-heading);
  margin: 0 0 10px;
  font-size: 1.05rem;
}
.card .meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 4px 0;
}
.card .btn { margin-top: 14px; width: 100%; text-align: center; }

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
:root[data-theme="light"] .status { border-radius: 3px; }
.status-active, .status-full { background: rgba(var(--green-rgb), 0.15); color: var(--green); }
.status-demo { background: rgba(var(--amber-rgb), 0.15); color: var(--amber); }
.status-expired, .status-forbidden, .status-hidden, .status-deprecated { background: rgba(var(--red-rgb), 0.15); color: var(--red); }
.status-soon { background: rgba(var(--amber-rgb), 0.15); color: var(--amber); }

.section-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}
:root[data-theme="dark"] .section-label::before { content: "// "; }
:root[data-theme="light"] .section-label {
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

form {
  max-width: 360px;
  margin: 48px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
form h2 { font-family: var(--font-heading); margin-top: 0; }

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
}

input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font-body);
}
input:focus { outline: none; border-color: var(--accent); }

form .btn { width: 100%; margin-top: 24px; }

.error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 1.2em;
}

.hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 16px;
  text-align: center;
}
