:root {
  color-scheme: light;
  --ink: #1d1d2b;
  --muted: #676779;
  --faint: #9a9aab;
  --line: #e6e6ef;
  --bg: #f5f5fa;
  --card: #ffffff;
  --brand: #5b5bf6;
  --brand-dark: #4141d6;
  --brand-soft: #ececfe;
  --danger: #e5484d;
  --danger-soft: #fdeced;
  --ok: #10a37f;
  --ok-soft: #e2f6f0;
  --warn-soft: #fff5dd;
  --tone-0: #5b5bf6;
  --tone-1: #ff6b6b;
  --tone-2: #20c5a0;
  --tone-3: #ffbe3d;
  --tone-4: #f25fae;
  --tone-5: #3fb4f2;
  --tone-6: #9a5cf5;
  --tone-7: #ff8a3d;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgb(29 29 43 / 6%), 0 6px 20px rgb(29 29 43 / 6%);
  --shadow-lg: 0 20px 60px rgb(29 29 43 / 18%);
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.15; }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.page-loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }

.tone-0 { --tone: var(--tone-0); }
.tone-1 { --tone: var(--tone-1); }
.tone-2 { --tone: var(--tone-2); }
.tone-3 { --tone: var(--tone-3); }
.tone-4 { --tone: var(--tone-4); }
.tone-5 { --tone: var(--tone-5); }
.tone-6 { --tone: var(--tone-6); }
.tone-7 { --tone: var(--tone-7); }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border: 1.5px solid transparent; border-radius: 999px;
  background: var(--card); color: var(--ink); font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary { background: var(--brand); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--brand-dark); }
.button.ghost { border-color: var(--line); background: var(--card); }
.button.ghost:hover:not(:disabled) { border-color: #cfcfdd; background: #fafafe; }
.button.quiet { background: transparent; }
.button.quiet:hover:not(:disabled) { background: rgb(29 29 43 / 6%); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger-ghost { border-color: var(--line); color: var(--danger); }
.button.danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-color: #f5c2c4; }
.button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.button.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.button.big { min-height: 56px; padding: 0 28px; font-size: 18px; }
.button.block { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.icon-button:hover:not(:disabled) { background: rgb(29 29 43 / 7%); color: var(--ink); }
.icon-button:disabled { opacity: .3; cursor: not-allowed; }

.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 14px; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 18px; height: 18px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }

.card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.live { background: var(--ok-soft); color: #08795e; }
.chip.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
.chip.draft { background: var(--warn-soft); color: #8a5a00; }
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); }
@keyframes pulse { 50% { opacity: .35; } }

.problems { margin: 0; padding: 12px 16px 12px 34px; border-radius: var(--radius); background: var(--danger-soft); color: #9f1f24; font-size: 14px; }
.notice { padding: 12px 16px; border-radius: var(--radius); background: var(--warn-soft); color: #6d4700; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; max-width: min(560px, calc(100vw - 32px));
  padding: 12px 20px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow-lg);
  transform: translate(-50%, 140%); opacity: 0; transition: transform .25s, opacity .25s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--danger); border-radius: 16px; }

dialog { width: min(460px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog::backdrop { background: rgb(29 29 43 / 45%); }
.dialog-body { display: grid; gap: 16px; padding: 28px; }
.dialog-body h2 { font-size: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
