:root {
  color-scheme: light dark;
  --bg: #fafafa;
  --bg-soft: #f4f4f5;
  --surface: #ffffff;
  --surface-soft: #f4f4f5;
  --surface-hover: #f9f9fa;
  --ink: #09090b;
  --ink-soft: #18181b;
  --ink-2: #27272a;
  --ink-on: #ffffff;
  --muted: #71717a;
  --muted-2: #a1a1aa;
  --border: #e4e4e7;
  --border-soft: #f1f1f3;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #15803d;
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.18);
  --shadow-xs: 0 1px 2px rgba(9, 9, 11, 0.04);
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.06), 0 1px 1px rgba(9, 9, 11, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(9, 9, 11, 0.06), 0 2px 4px -2px rgba(9, 9, 11, 0.04);
  --shadow-lg: 0 16px 32px -12px rgba(9, 9, 11, 0.16), 0 8px 16px -8px rgba(9, 9, 11, 0.08);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --bg-soft: #18181b;
  --surface: #18181b;
  --surface-soft: #27272a;
  --surface-hover: #27272a;
  --ink: #fafafa;
  --ink-soft: #f4f4f5;
  --ink-2: #e4e4e7;
  --ink-on: #09090b;
  --muted: #a1a1aa;
  --muted-2: #71717a;
  --border: #27272a;
  --border-soft: #3f3f46;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --success: #4ade80;
  --ring: 0 0 0 3px rgba(165, 180, 252, 0.22);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.55), 0 2px 4px -2px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 32px -12px rgba(0, 0, 0, 0.65), 0 8px 16px -8px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--muted-2); }
a:hover { text-decoration-color: var(--ink); }
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
}
.secondary-link:hover { background: var(--surface-hover); border-color: var(--muted-2); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 24px; font-weight: 600; line-height: 1.2; }
h2 { font-size: 16px; font-weight: 600; line-height: 1.3; margin-bottom: 12px; }
h3 { font-size: 14px; font-weight: 600; line-height: 1.4; margin-bottom: 10px; }
::selection { background: rgba(9, 9, 11, 0.12); }

/* Buttons */
button, input, select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--ink-on);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: var(--shadow-xs);
}
button:hover { background: var(--ink-soft); }
button:active { transform: translateY(0.5px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
button.secondary:hover { background: var(--surface-hover); border-color: var(--muted-2); }
.btn-block { width: 100%; padding: 11px 14px; font-size: 13px; font-weight: 600; }

/* Form controls */
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { border-color: var(--muted-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: var(--ring); }
label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}

/* Layout shells */
.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background:
    radial-gradient(1000px 500px at 90% -10%, rgba(9, 9, 11, 0.04), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(79, 70, 229, 0.06), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  display: grid;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px;
}
.auth-head { display: grid; gap: 6px; text-align: left; }
.auth-head .brand-mark-lg { margin-bottom: 14px; }
.auth-head h1 { font-size: 24px; font-weight: 600; }
.auth-head .panel-label { margin-bottom: 4px; }
.auth-head .muted { font-size: 13px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .form-error { font-size: 12px; }
.auth-form details { margin: 0; }
.auth-form details > *:not(summary) { margin-top: 10px; }
.auth-aux { display: grid; gap: 12px; }
.auth-links {
  margin: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.auth-links a { color: var(--ink-2); }
.auth-footer {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Brand mark */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--ink-on);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.brand-mark-lg {
  width: 44px;
  height: 44px;
  font-size: 18px;
  border-radius: var(--radius);
}

/* Panel labels & messages */
.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; }
.success { color: var(--success); font-size: 13px; }
.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
}
.help {
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0 0;
}

/* Dashboard topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 22px; }

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}
.dashboard-title {
  display: grid;
  gap: 8px;
}
.dashboard-title h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.dashboard-title .muted {
  max-width: 720px;
  margin: 0;
}
.dashboard-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.dashboard-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.dashboard-sidebar {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.dashboard-menu-item {
  width: 100%;
  justify-content: flex-start;
  min-height: 40px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
  box-shadow: none;
}
.dashboard-menu-item:hover {
  background: var(--surface-hover);
  color: var(--ink);
}
.dashboard-menu-item.active {
  background: var(--ink);
  color: var(--ink-on);
}
.dashboard-content {
  min-width: 0;
}
.dashboard-section {
  display: none;
}
.dashboard-section.active {
  display: grid;
  gap: 16px;
}
.section-head {
  display: grid;
  gap: 6px;
  margin-bottom: 2px;
}
.section-head .muted {
  max-width: 740px;
  margin: 0;
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.choice-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.choice-card h3 { margin-bottom: 6px; }
.choice-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
  gap: 16px;
  align-items: start;
}
.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.subtle-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}
.subtle-box p {
  margin: 0;
}
.code-block {
  display: block;
  white-space: pre-wrap;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  overflow-x: auto;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.card.error { color: inherit; border-color: var(--danger); background: var(--danger-soft); }
.card.success { color: inherit; border-color: var(--border); background: var(--surface); }

/* Actions row */
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.path-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}
.path-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  min-height: 100%;
}
.path-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.path-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--ink-on);
  font-size: 12px;
  font-weight: 700;
}
.path-head h3 { margin-bottom: 2px; }
.path-meta {
  color: var(--muted);
  font-size: 12px;
}
.path-body {
  display: grid;
  gap: 12px;
}
.path-body p { margin: 0; }
.path-form {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.path-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
}
.mini-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}
.mini-list li {
  display: flex;
  gap: 8px;
  min-width: 0;
}
.mini-list li::before {
  content: "";
  width: 5px;
  height: 5px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--muted-2);
  flex: 0 0 auto;
}
.contract-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.contract-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.contract-item strong {
  display: block;
  margin-bottom: 6px;
}
.contract-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.table-wrap {
  overflow-x: auto;
}
.domain-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  vertical-align: top;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
code {
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--ink-soft);
}

/* Definition lists */
.kv {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }
.secret {
  display: inline-block;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: 12px;
}

/* Disclosure */
details { margin-top: 4px; }
summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-2);
  padding: 4px 0;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "›";
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
details[open] > summary::before { transform: rotate(90deg); }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .path-grid, .contract-grid { grid-template-columns: 1fr; }
  .choice-grid, .two-column, .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-sidebar { position: static; }
  .dashboard-hero { grid-template-columns: 1fr; align-items: start; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .auth-card { padding: 24px; border-radius: var(--radius); }
}