:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #11151d;
  --panel-2: #171c26;
  --line: #2a3240;
  --text: #f3f6fb;
  --muted: #9ba8b8;
  --accent: #7cf7c4;
  --accent-ink: #052016;
  --danger: #ff7d8d;
  --warning: #ffd479;
  --shadow: 0 24px 80px rgb(0 0 0 / 35%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 5%, rgb(50 104 89 / 24%), transparent 30rem),
    radial-gradient(circle at 10% 40%, rgb(47 64 101 / 20%), transparent 35rem),
    var(--bg);
}

a { color: var(--accent); }

button, input, select, textarea { font: inherit; }

button, input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
}

input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #0b0f15;
  padding: 0.8rem 0.9rem;
}

textarea {
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
}

label {
  display: grid;
  gap: 0.45rem;
  color: #cfd7e2;
  font-size: 0.9rem;
}
.checkbox-row { display: flex; align-items: center; gap: 0.65rem; }
.checkbox-row input { width: auto; accent-color: var(--accent); }

button {
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  padding: 0.75rem 1rem;
  font-weight: 700;
}

button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { cursor: not-allowed; opacity: 0.45; }
button.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: rgb(255 125 141 / 45%); }
button, select, input, textarea { transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, opacity 180ms ease; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 8px;
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.shell { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; }

.hero {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: end;
  padding-block: 4.5rem 2rem;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.8rem; font-size: clamp(2.6rem, 7vw, 5.5rem); line-height: 0.95; letter-spacing: -0.06em; }
h2 { margin-bottom: 0.35rem; }
h3 { margin-bottom: 0.25rem; }
.lede { max-width: 720px; color: var(--muted); font-size: 1.08rem; }
.eyebrow { color: var(--accent); font: 700 0.72rem/1.4 "SFMono-Regular", monospace; letter-spacing: 0.16em; }
.muted { color: var(--muted); }

.build-card {
  width: min(330px, 100%);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(17 21 29 / 72%);
}

.build-card span { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; }
.build-card code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }

.status {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgb(17 21 29 / 78%);
}
.status.error { border-left-color: var(--danger); color: #ffd6db; }
.status.busy { border-left-color: var(--warning); color: #fff0cb; }
.status.success { color: #caffe9; }

.start-grid, .workspace-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.workspace-grid { grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.75fr); }

.panel {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgb(20 25 35 / 96%), rgb(13 17 24 / 96%));
  box-shadow: var(--shadow);
}

.panel-heading { display: flex; gap: 0.9rem; align-items: start; margin-bottom: 1.2rem; }
.panel-heading.compact { margin-bottom: 1rem; }
.panel-heading p { margin-bottom: 0; color: var(--muted); }
.step {
  flex: 0 0 auto;
  min-width: 2.4rem;
  padding: 0.35rem;
  text-align: center;
  color: var(--accent);
  border: 1px solid rgb(124 247 196 / 30%);
  border-radius: 8px;
  font: 700 0.78rem/1.4 "SFMono-Regular", monospace;
}

.stack { display: grid; gap: 1rem; }
.file-summary { min-height: 4.2rem; padding: 0.8rem; border: 1px dashed var(--line); border-radius: 10px; }
.workspace { margin-top: 1rem; }
.recovery-panel { margin-bottom: 1rem; border-color: rgb(255 212 121 / 55%); }
.mnemonic { font-size: 1.05rem; color: var(--warning); letter-spacing: 0.04em; }
.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2rem 0 1rem; }
.workspace-head p { margin-bottom: 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.8rem; }
.create-actions { margin-top: 0; }
.create-actions button { flex: 1 1 220px; }

.result { margin-top: 1rem; overflow: auto; max-height: 430px; border: 1px solid var(--line); border-radius: 10px; }
.result > p { padding: 0.8rem; margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; white-space: pre-wrap; }
th { position: sticky; top: 0; color: var(--accent); background: #121720; }

.key-list { display: grid; gap: 0.6rem; padding: 0; margin: 0 0 1rem; list-style: none; }
.key-list li { padding: 0.75rem; border: 1px solid var(--line); border-radius: 10px; background: #0c1017; }
.key-list strong, .key-list code { display: block; }
.key-list code { margin-top: 0.35rem; color: var(--muted); font-size: 0.72rem; overflow-wrap: anywhere; }
.fine-print { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.5; }
.security-note ul { padding-left: 1.1rem; margin-bottom: 0; color: var(--muted); line-height: 1.7; }
.footer { display: flex; justify-content: space-between; gap: 1rem; padding-block: 2rem; color: var(--muted); font-size: 0.78rem; }

.vault-open .hero { display: none; }
.vault-open main.shell { width: min(1440px, calc(100% - 1.5rem)); }
.vault-open .workspace { margin-top: 0.75rem; }

.vault-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.vault-shell.sidebar-collapsed { grid-template-columns: 72px minmax(0, 1fr); }
.vault-sidebar {
  position: sticky;
  top: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 1.5rem);
  min-height: calc(100dvh - 1.5rem);
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, rgb(20 25 35 / 98%), rgb(10 14 20 / 98%));
  box-shadow: var(--shadow);
}
.sidebar-head, .sidebar-brand, .sidebar-item {
  display: flex;
  align-items: center;
}
.sidebar-head { justify-content: space-between; gap: 0.4rem; padding-bottom: 0.65rem; border-bottom: 1px solid var(--line); }
.sidebar-brand { min-width: 0; gap: 0.7rem; padding: 0.55rem; color: var(--accent); font-weight: 800; }
.sidebar-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
}
.nav-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { display: grid; gap: 0.35rem; padding-block: 0.75rem; }
.sidebar-item {
  width: 100%;
  min-height: 46px;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  text-align: left;
  background: transparent;
  border-color: transparent;
}
.sidebar-item:hover:not(:disabled) { background: var(--panel-2); transform: none; }
.sidebar-item.active { color: var(--accent); background: rgb(124 247 196 / 10%); border-color: rgb(124 247 196 / 28%); }
.sidebar-foot { margin-top: auto; padding-top: 0.65rem; border-top: 1px solid var(--line); }
.vault-shell.sidebar-collapsed .nav-label { display: none; }
.vault-shell.sidebar-collapsed .sidebar-brand { justify-content: center; }
.vault-shell.sidebar-collapsed .sidebar-head { flex-direction: column; }
.vault-shell.sidebar-collapsed .sidebar-item { justify-content: center; padding-inline: 0.6rem; }
.vault-shell.sidebar-collapsed .collapse-icon { transform: rotate(180deg); }

.vault-main { min-width: 0; padding-bottom: 2rem; }
.vault-main .workspace-head { margin: 0 0 1rem; min-height: 72px; padding: 0.25rem 0.2rem; }
.vault-view { min-width: 0; }
.vault-view:focus { outline: none; }
.vault-view[hidden] { display: none; }
.compact-panel { max-width: 900px; }

.data-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 0.65rem;
  align-items: end;
}
.data-toolbar button { min-height: 44px; }
.table-summary { min-height: 2.6rem; margin-top: 1rem; padding: 0.65rem 0.8rem; border: 1px dashed var(--line); border-radius: 9px; }
.schema-list { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.75rem; }
.schema-chip { display: inline-flex; gap: 0.4rem; align-items: center; padding: 0.38rem 0.55rem; border: 1px solid var(--line); border-radius: 999px; color: #d7dfeb; background: #0c1017; font: 600 0.75rem/1.3 "SFMono-Regular", monospace; }
.schema-chip small { color: var(--muted); font: inherit; font-weight: 400; }
.data-result { max-height: min(62vh, 680px); }
.data-result td { max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.row-number { width: 1%; color: var(--muted); font-family: "SFMono-Regular", monospace; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }
.pagination span { min-width: 8rem; text-align: center; color: var(--muted); font-size: 0.85rem; }
.passkey-add-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 0.65rem; align-items: end; }
.passkey-add-row button { min-height: 44px; }

.self-test { max-width: 820px; padding-block: 4rem; }
.check-list { display: grid; gap: 0.7rem; padding: 0; list-style: none; }
.check-list li { padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #0c1017; }
.check-list li.pass { border-color: rgb(124 247 196 / 40%); color: #caffe9; }
.check-list li.fail { border-color: rgb(255 125 141 / 50%); color: #ffd6db; }

@media (max-width: 820px) {
  .hero, .workspace-head, .footer { align-items: stretch; flex-direction: column; }
  .start-grid, .workspace-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 2.5rem; }
  .vault-open main.shell { width: min(100% - 1rem, 100%); }
  .vault-shell, .vault-shell.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); gap: 0.65rem; }
  .vault-sidebar {
    z-index: 20;
    top: 0;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    padding: 0.4rem;
    border-radius: 12px;
  }
  .sidebar-head { display: none; }
  .sidebar-nav { display: flex; flex: 1; justify-content: space-around; gap: 0.2rem; padding: 0; }
  .sidebar-foot { margin: 0; padding: 0 0 0 0.35rem; border: 0; border-left: 1px solid var(--line); }
  .sidebar-item, .vault-shell.sidebar-collapsed .sidebar-item { justify-content: center; width: 46px; padding: 0.6rem; }
  .sidebar-item .nav-label { display: none; }
  .vault-main .workspace-head { min-height: 0; }
  .data-toolbar { grid-template-columns: 1fr 1fr; }
  .data-toolbar label { grid-column: 1 / -1; }
  .passkey-add-row { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
