:root {
  color-scheme: light dark;
  --brand: #315cf6;
  --brand-strong: #2049df;
  --brand-soft: #e9efff;
  --success: #12805c;
  --success-soft: #e5f8f0;
  --warning: #a15c00;
  --danger: #be3447;
  --danger-soft: #fff0f2;
  --canvas: #f4f6fb;
  --surface: #ffffff;
  --surface-muted: #f8f9fc;
  --text: #17203a;
  --text-muted: #667085;
  --border: #dfe4ee;
  --border-strong: #c5cddd;
  --shadow: 0 18px 48px rgba(30, 42, 78, 0.10);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --focus: 0 0 0 4px rgba(49, 92, 246, 0.2);
}

html[data-theme="dark"] {
  --brand: #86a3ff;
  --brand-strong: #a9bcff;
  --brand-soft: #1d2a52;
  --success: #79d8b5;
  --success-soft: #173c31;
  --warning: #ffc56d;
  --danger: #ff9bab;
  --danger-soft: #4b2029;
  --canvas: #0d1220;
  --surface: #141b2d;
  --surface-muted: #1a2338;
  --text: #f0f4ff;
  --text-muted: #a9b2c7;
  --border: #2b3650;
  --border-strong: #3a4764;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --brand: #86a3ff;
    --brand-strong: #a9bcff;
    --brand-soft: #1d2a52;
    --success: #79d8b5;
    --success-soft: #173c31;
    --warning: #ffc56d;
    --danger: #ff9bab;
    --danger-soft: #4b2029;
    --canvas: #0d1220;
    --surface: #141b2d;
    --surface-muted: #1a2338;
    --text: #f0f4ff;
    --text-muted: #a9b2c7;
    --border: #2b3650;
    --border-strong: #3a4764;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  }
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--canvas); color: var(--text); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed;
  left: var(--space-4);
  top: -80px;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
}
.skip-link:focus { top: var(--space-4); }
:focus-visible { outline: none; box-shadow: var(--focus); }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; padding: 0 var(--space-2); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(145deg, var(--brand), #7b57e9);
  box-shadow: 0 10px 24px rgba(49, 92, 246, 0.28);
}
.brand span:last-child { display: flex; flex-direction: column; line-height: 1; }
.brand strong { font-size: 17px; letter-spacing: .02em; }
.brand small { margin-top: 5px; font-size: 9px; letter-spacing: .2em; color: var(--text-muted); }
.sidebar nav { display: grid; gap: var(--space-2); }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 46px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}
.nav-item span { width: 20px; color: var(--text-muted); font-size: 18px; text-align: center; }
.nav-item.active { color: var(--brand-strong); background: var(--brand-soft); }
.nav-item.active span { color: var(--brand); }
.nav-item.muted { pointer-events: none; }
.secure-note {
  margin-top: auto;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.secure-note span { color: var(--success); margin-right: var(--space-2); }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
}
.secure-pill { color: var(--success); font-size: 12px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }
.locale-link { min-height: 40px; display: grid; place-items: center; padding: 0 var(--space-3); border-radius: var(--radius-sm); text-decoration: none; font-weight: 700; }
.theme-switcher { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); }
.theme-option { padding: 7px 10px; border-radius: 8px; color: var(--text-muted); text-decoration: none; font-size: 12px; font-weight: 700; }
.theme-option.selected { background: var(--surface); color: var(--brand-strong); box-shadow: 0 2px 8px rgba(30, 42, 78, .08); }

.content { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: var(--space-7) 0 72px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 480px; gap: var(--space-7); align-items: end; margin-bottom: var(--space-6); }
.eyebrow { margin: 0 0 var(--space-2); color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { max-width: 720px; margin: 0; font-size: clamp(32px, 4vw, 52px); line-height: 1.08; letter-spacing: -.035em; }
.hero > div > p:last-child { max-width: 670px; margin: var(--space-4) 0 0; color: var(--text-muted); line-height: 1.65; }
.progress-card { display: flex; align-items: flex-start; justify-content: center; padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); }
.progress-step { width: 76px; display: grid; justify-items: center; gap: var(--space-2); color: var(--text-muted); font-size: 10px; line-height: 1.25; text-align: center; }
.progress-step b { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--border-strong); border-radius: 50%; color: var(--text-muted); }
.progress-step.current { color: var(--brand-strong); font-weight: 700; }
.progress-step.current b { border-color: var(--brand); color: #fff; background: var(--brand); }
.progress-step.done b { border-color: var(--success); color: #fff; background: var(--success); }
.progress-line { flex: 1; height: 2px; margin-top: 13px; background: var(--border); }

.identity-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
}
.identity-card.ready { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); background: var(--success-soft); }
.identity-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--warning); background: var(--surface); font-weight: 900; }
.identity-card.ready .identity-icon { color: var(--success); }
.identity-card strong { display: block; margin-bottom: 3px; }
.identity-card p { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.45; }

.onboarding-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr); gap: var(--space-5); align-items: start; }
.form-card, .preview-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.form-card { padding: var(--space-6); }
.preview-card { position: sticky; top: 96px; padding: var(--space-5); }
.card-heading { display: flex; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-6); }
.step-number { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 14px; color: var(--brand-strong); background: var(--brand-soft); font-size: 13px; font-weight: 900; }
.card-heading h2 { margin: 0; font-size: 20px; }
.card-heading p { margin: 5px 0 0; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
.field { display: grid; align-content: start; gap: var(--space-2); min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span, .field legend { color: var(--text); font-size: 13px; font-weight: 750; }
.field small { color: var(--text-muted); font-size: 11px; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
}
input:hover, select:hover { border-color: var(--brand); }
input:focus, select:focus { border-color: var(--brand); box-shadow: var(--focus); outline: none; }
.slug-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-muted); overflow: hidden; }
.slug-control:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.slug-control input { border: 0; border-radius: 0; box-shadow: none; }
.slug-control small { padding-right: var(--space-4); color: var(--text-muted); }
.model-field { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin: 0; padding: 0; border: 0; }
.model-field legend { grid-column: 1 / -1; margin-bottom: var(--space-2); }
.model-field label { position: relative; }
.model-field input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.model-field span { display: flex; align-items: center; gap: var(--space-3); min-height: 58px; padding: 0 var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 700; cursor: pointer; }
.model-field b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-muted); color: var(--brand); }
.model-field input:checked + span { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.model-field input:focus-visible + span { box-shadow: var(--focus); }

.preview-section + .preview-section { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.preview-section h3 { margin: 0 0 var(--space-3); font-size: 13px; }
.chip-list, .role-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-list li { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-muted); font-size: 12px; font-weight: 650; }
.chip-icon { color: var(--brand); }
.role-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.role-list li { display: flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--text-muted); font-size: 12px; }
.avatar { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.empty-preview { padding: var(--space-5); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-muted); text-align: center; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 46px; padding: 0 var(--space-5); border: 1px solid transparent; border-radius: var(--radius-sm); text-decoration: none; font-weight: 800; cursor: pointer; }
.button-primary { width: 100%; margin-top: var(--space-5); color: #fff; background: var(--brand); box-shadow: 0 12px 24px rgba(49, 92, 246, .24); }
.button-primary:hover:not(:disabled) { background: var(--brand-strong); transform: translateY(-1px); }
.button-primary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.button-secondary { color: var(--brand-strong); border-color: var(--border); background: var(--surface); white-space: nowrap; }
.submit-help { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: 11px; text-align: center; }
.result { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); margin-top: var(--space-5); padding: var(--space-4); border-radius: var(--radius-sm); font-size: 13px; }
.result.success { color: var(--success); background: var(--success-soft); }
.result.error { color: var(--danger); background: var(--danger-soft); }
.result-icon { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid currentColor; border-radius: 50%; font-weight: 900; }
.result p { margin: 3px 0; color: var(--text-muted); line-height: 1.4; }

footer { display: flex; justify-content: space-between; gap: var(--space-4); margin-top: auto; padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11px; }

@media (max-width: 1020px) {
  .app-shell { grid-template-columns: 86px minmax(0, 1fr); }
  .sidebar { align-items: center; padding-inline: var(--space-3); }
  .brand span:last-child, .nav-item:not(.active), .nav-item.active { font-size: 0; }
  .nav-item { justify-content: center; width: 50px; padding: 0; pointer-events: auto; }
  .nav-item span { font-size: 18px; }
  .secure-note { display: none; }
  .hero { grid-template-columns: 1fr; }
  .onboarding-grid { grid-template-columns: 1fr; }
  .preview-card { position: static; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav, .secure-note { display: none; }
  .brand span:last-child { display: flex; }
  .topbar { min-height: 62px; padding: 0 var(--space-4); }
  .topbar > div:first-child, .theme-option:first-child { display: none; }
  .content { width: min(100% - 28px, 620px); padding-top: var(--space-6); }
  .hero { gap: var(--space-5); }
  .progress-card { overflow-x: auto; justify-content: flex-start; padding: var(--space-4); }
  .progress-step { flex: 0 0 64px; }
  .identity-card { grid-template-columns: auto 1fr; padding: var(--space-4); }
  .identity-card .button { grid-column: 1 / -1; }
  .form-card, .preview-card { padding: var(--space-4); border-radius: var(--radius-md); }
  .form-fields, .model-field { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  footer { padding-inline: var(--space-4); }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .nav-item, .theme-option { transition: background-color .16s ease, color .16s ease, border-color .16s ease, transform .16s ease; }
}
