:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #10141f;
  color: #e7edf7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
select {
  font: inherit;
}

button,
select,
.file-button {
  border: 1px solid #42536d;
  border-radius: 0.4rem;
  background: #151d2b;
  color: #dce8f7;
}

button,
.file-button {
  min-height: 2.35rem;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

button:hover:not(:disabled),
.file-button:hover,
select:hover {
  border-color: #78c7ff;
  background: #1b2a3d;
}

button:focus-visible,
select:focus-visible,
.file-button:focus-visible,
a:focus-visible {
  outline: 2px solid #9cdbff;
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.page-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.hero h1 {
  margin: 0.1rem 0 0.25rem;
  font-size: clamp(1.7rem, 4vw, 2.45rem);
}

.hero-copy {
  margin: 0;
  color: #b9c5d6;
}

.eyebrow {
  margin: 0;
  color: #78c7ff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.5rem 0.8rem;
  color: #9aabc2;
  font-size: 0.85rem;
  text-align: right;
}

.privacy-badge {
  color: #b8e8ce;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.55rem;
  border: 1px solid #293548;
  border-radius: 0.7rem;
  background: #171d2b;
}

.toolbar-select select {
  min-height: 2.35rem;
  padding: 0.4rem 2rem 0.4rem 0.65rem;
}

.toolbar-select:first-child select {
  min-width: min(22rem, 72vw);
}

.file-button {
  background: #183451;
  border-color: #4a8ac0;
  color: #eaf6ff;
  font-weight: 650;
}

.file-status {
  max-width: 15rem;
  overflow: hidden;
  color: #9aabc2;
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secondary-button {
  margin-left: auto;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.panel {
  min-width: 0;
  border: 1px solid #293548;
  border-radius: 0.75rem;
  background: #171d2b;
  padding: 0.9rem;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

.muted,
.version {
  color: #9aabc2;
  font-size: 0.85rem;
}

.editor {
  min-height: 34rem;
  overflow: hidden;
  border: 1px solid #42536d;
  border-radius: 0.45rem;
  background: #0c111b;
}

.cm-editor {
  height: 34rem;
  font:
    0.9rem/1.5 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
}

.cm-editor.cm-focused {
  outline: 2px solid #5ba9df;
  outline-offset: -2px;
}

.cm-scroller {
  overflow: auto;
}

.cm-content {
  caret-color: #f4f8ff;
}

.cm-gutters {
  border-right: 1px solid #293548;
  background: #101722;
  color: #687c96;
}

.cm-activeLine,
.cm-activeLineGutter {
  background: #182337 !important;
}

.ts-comment {
  color: #71849b;
  font-style: italic;
}

.ts-string,
.ts-constant {
  color: #d9b77d;
}

.ts-number,
.ts-constant-builtin {
  color: #c89ee6;
}

.ts-keyword,
.ts-operator,
.ts-punctuation-special {
  color: #82c8ff;
}

.ts-type {
  color: #72d0bd;
}

.ts-function,
.ts-function-call,
.ts-function-method-call {
  color: #9fd3ff;
}

.ts-property,
.ts-variable,
.ts-variable-parameter {
  color: #d9e7fa;
}

.ts-label {
  color: #f1a8a8;
}

.cm-recovery-error {
  background: #40222a;
  background: color-mix(in srgb, #d95c70 28%, transparent);
  text-decoration: wavy underline #ff899c 1.5px;
}

.cm-missing-marker {
  display: inline-block;
  width: 0.2rem;
  height: 1.15em;
  margin: 0 -0.1rem;
  border-left: 2px solid #f4ca77;
  vertical-align: -0.2em;
}

.tree-controls {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.mode-switch,
.tree-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tree-controls button {
  min-height: 2rem;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
}

.mode-switch [aria-pressed="true"] {
  border-color: #5ba9df;
  background: #183451;
  color: #f0f8ff;
}

.metrics {
  display: flex;
  gap: 1rem;
  margin: 0 0 0.45rem;
}

.metrics div {
  display: flex;
  gap: 0.3rem;
}

.metrics dt {
  color: #9aabc2;
}

.metrics dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.recovery-summary {
  margin: 0 0 0.55rem;
  color: #89d9a9;
  font-size: 0.85rem;
}

.recovery-summary.has-recovery {
  color: #ff9d9d;
}

.tree-output {
  min-height: 25rem;
  max-height: 34rem;
  overflow: auto;
  border-radius: 0.45rem;
  background: #0c111b;
  color: #dce8f7;
  font:
    0.84rem/1.5 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
}

.syntax-tree,
.tree-children,
.recovery-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.syntax-tree {
  padding: 0.55rem;
}

.tree-children {
  margin-left: 1.15rem;
  border-left: 1px solid #293548;
}

.tree-row {
  display: flex;
  align-items: center;
  min-height: 1.7rem;
  gap: 0.35rem;
}

.tree-toggle,
.tree-toggle-spacer {
  display: inline-grid;
  width: 1.2rem;
  height: 1.2rem;
  place-items: center;
  flex: 0 0 auto;
}

.tree-toggle {
  min-height: 1.2rem;
  padding: 0;
  color: #9aabc2;
}

.tree-field {
  color: #c89ee6;
}

.tree-node {
  min-height: auto;
  border: 0;
  padding: 0.1rem 0.2rem;
  background: transparent;
  color: #a8d5ff;
  text-align: left;
}

.tree-node:hover,
.tree-node.selected {
  background: #1e3955;
  color: #f5f9ff;
}

.tree-recovery-badge {
  border-radius: 0.25rem;
  padding: 0.05rem 0.25rem;
  background: #4b2630;
  color: #ffd5dc;
  font-size: 0.72rem;
  font-weight: 700;
}

.recovery-missing .tree-recovery-badge {
  background: #4b3d22;
  color: #ffe5a6;
}

.sexpr-output {
  margin: 0;
  padding: 0.7rem;
  white-space: pre;
}

.status {
  font-size: 0.85rem;
  font-weight: 700;
}

.status.clean {
  color: #7ce0a4;
}

.status.recovery,
.status.failed {
  color: #ff9d9d;
}

.status.loading {
  color: #f4ca77;
}

.recovery-panel {
  margin-top: 1rem;
}

.recovery-list button {
  width: 100%;
  border-color: #4e3945;
  background: #251a21;
  color: #ffdce1;
  text-align: left;
}

.recovery-list li + li {
  margin-top: 0.45rem;
}

.reporting {
  margin-top: 0.75rem;
  color: #9aabc2;
  font-size: 0.85rem;
}

.reporting span {
  color: #dce8f7;
  font-weight: 650;
}

a {
  color: #78c7ff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 950px) {
  .hero {
    align-items: start;
    flex-direction: column;
    gap: 0.6rem;
  }

  .hero-meta {
    justify-content: start;
    text-align: left;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor,
  .cm-editor {
    min-height: 24rem;
    height: 24rem;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 0.8rem;
  }

  .secondary-button {
    margin-left: 0;
  }

  .tree-controls {
    align-items: start;
    flex-direction: column;
  }

  .tree-output {
    min-height: 20rem;
  }
}
