:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --surface-3: #e9eaf1;
  --text: #1e1f24;
  --muted: #696b78;
  --border: #dfe1e9;
  --primary: #6750a4;
  --primary-strong: #563d96;
  --primary-soft: #eee9fb;
  --accent: #367ac6;
  --success: #16794a;
  --warning: #a86600;
  --danger: #b3261e;
  --shadow-sm: 0 1px 2px rgba(31, 35, 48, .08), 0 1px 6px rgba(31, 35, 48, .04);
  --shadow-md: 0 12px 35px rgba(31, 35, 48, .12), 0 2px 8px rgba(31, 35, 48, .08);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --focus: 0 0 0 3px rgba(103, 80, 164, .22);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111216;
  --surface: #1a1b20;
  --surface-2: #22232a;
  --surface-3: #2c2d35;
  --text: #f0f0f4;
  --muted: #a9abb6;
  --border: #363842;
  --primary: #b8a6ef;
  --primary-strong: #c9baf4;
  --primary-soft: #302a46;
  --accent: #86b9ef;
  --success: #68d8a0;
  --warning: #f0bd66;
  --danger: #ffb4ab;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md: 0 18px 42px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { border: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
img { max-width: 100%; }
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.hidden { display: none !important; }
.icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--border), var(--text) 15%); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #211a32; }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; }
.btn.icon-only { width: 40px; padding: 0; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.field { display: grid; gap: 6px; }
.field > label { font-size: 12px; font-weight: 700; color: var(--muted); }
.text-input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  min-height: 38px;
  padding: 8px 10px;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.divider { height: 1px; background: var(--border); }
.toast-stack {
  position: fixed;
  z-index: 1000;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: min(390px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface), var(--text) 5%);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  line-height: 1.35;
  pointer-events: auto;
  animation: toast-in .18s ease-out;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(12, 13, 18, .46);
  backdrop-filter: blur(5px);
}
.modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.modal.wide { width: min(900px, 100%); }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--surface), transparent 3%);
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 18px; }
.modal-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.site-header {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface), transparent 4%);
  backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.02em;
}
.brand img { width: 35px; height: 35px; }
.brand span { font-size: 18px; }
.site-nav { display: flex; align-items: center; gap: 5px; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 650;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.content-page { width: min(860px, calc(100% - 34px)); margin: 42px auto 80px; }
.content-page h1 { font-size: clamp(34px, 6vw, 52px); letter-spacing: -.045em; margin: 0 0 12px; }
.content-page h2 { margin-top: 38px; letter-spacing: -.02em; }
.content-page p, .content-page li { color: var(--muted); line-height: 1.7; }
.content-page .lead { font-size: 20px; line-height: 1.55; }
.content-page code { padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text); }

@media (max-width: 720px) {
  .site-header { padding: 0 14px; height: 60px; }
  .site-nav .optional { display: none; }
  .brand span { font-size: 16px; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { max-height: calc(100vh - 20px); border-radius: 18px 18px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
