:root {
  color-scheme: dark;
  --bg: #10110d;
  --surface: #171913;
  --surface-2: #20231b;
  --surface-3: #292d23;
  --text: #f6f2e8;
  --muted: #b9b2a5;
  --line: rgba(255, 255, 255, 0.12);
  --yellow: #facc15;
  --teal: #2dd4bf;
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
  --topbar-h: 62px;
  --sticky-offset: calc(var(--topbar-h) + 16px);
  --editor-min-h: 420px;
  --editor-pad-y: 14px;
  --editor-pad-x: 16px;
  --editor-font-size: 0.82rem;
  --editor-line-height: 1.55;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(250, 204, 21, 0.16), transparent 28rem),
    radial-gradient(circle at 92% 12%, rgba(45, 212, 191, 0.14), transparent 26rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  flex-shrink: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 13, 0.88);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--yellow), var(--teal));
  color: #0b0d0a;
  font-size: 0.72rem;
  font-weight: 800;
}

.brand-sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.lang-btn.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.icon-button:hover {
  border-color: rgba(250, 204, 21, 0.35);
  background: var(--surface-2);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.page {
  flex: 1;
  min-height: 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hero-block {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.hero-block h1 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 800;
}

.hero-block p {
  margin: 0;
  color: var(--muted);
  max-width: 52rem;
  font-size: 0.95rem;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 960px) {
  html,
  body {
    height: auto;
    max-height: none;
    overflow: auto;
  }

  body {
    display: block;
    min-height: 100dvh;
  }

  .page {
    overflow: visible;
    min-height: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 70vh;
  }

  .panel--results {
    max-height: 50vh;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel--editor {
  min-height: 0;
  height: 100%;
}

.panel--editor .editor-shell {
  flex: 1;
  min-height: 0;
}

.panel--results {
  min-height: 0;
  height: 100%;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.panel-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: border-color 0.15s, transform 0.1s;
}

.btn:hover {
  border-color: rgba(45, 212, 191, 0.45);
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.22), rgba(45, 212, 191, 0.18));
  border-color: rgba(250, 204, 21, 0.35);
}

.btn--ghost {
  background: transparent;
}

.editor-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-scroll {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  overflow: auto;
  overscroll-behavior: contain;
}

.gutter {
  position: sticky;
  left: 0;
  z-index: 2;
  align-self: start;
  padding: var(--editor-pad-y) 0;
  background: #141612;
  border-right: 1px solid var(--line);
  user-select: none;
  text-align: right;
}

.gutter pre {
  margin: 0;
  padding: 0 10px 0 14px;
  font-family: var(--mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  color: rgba(185, 178, 165, 0.55);
  tab-size: 2;
}

.gutter .ln {
  display: block;
  min-height: calc(var(--editor-font-size) * var(--editor-line-height));
}

.gutter .ln.is-error {
  color: var(--red);
  font-weight: 700;
  background: rgba(248, 113, 113, 0.12);
  border-radius: 4px;
  margin: 0 -4px;
  padding: 0 4px;
}

.editor-wrap {
  position: relative;
  min-width: min-content;
  align-self: start;
}

.editor-highlights {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 0;
}

.editor-highlights pre {
  margin: 0;
  padding: var(--editor-pad-y) var(--editor-pad-x);
  font-family: var(--mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  white-space: pre;
  color: transparent;
  tab-size: 2;
  will-change: transform;
}

.editor-highlights .hl-line {
  display: block;
  min-height: calc(var(--editor-font-size) * var(--editor-line-height));
}

.editor-highlights .hl-line.is-error {
  background: rgba(248, 113, 113, 0.2);
  box-shadow: inset 3px 0 0 var(--red);
}

.editor-highlights .ws-lead {
  background: rgba(251, 191, 36, 0.08);
  border-radius: 2px;
}

.ws-char {
  color: rgba(251, 191, 36, 0.85);
  font-weight: 600;
}

.ws-char.ws-tab {
  color: var(--teal);
}

.hl-col,
.ws-char-mark {
  background: rgba(248, 113, 113, 0.55);
  color: #fff !important;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--red);
}

.btn.is-active {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.12);
  color: var(--yellow);
}

#yamlInput {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-width: 100%;
  min-height: 12rem;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: var(--editor-pad-y) var(--editor-pad-x);
  font-family: var(--mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  tab-size: 2;
  caret-color: var(--yellow);
  overflow: hidden;
  white-space: pre;
  field-sizing: content;
}

#yamlInput::placeholder {
  color: rgba(185, 178, 165, 0.45);
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
  background: #141612;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
}

.status-pill--idle {
  background: var(--surface-3);
  color: var(--muted);
}

.status-pill--ok {
  background: rgba(74, 222, 128, 0.15);
  color: var(--green);
}

.status-pill--err {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

.status-pill--warn {
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.panel--results .results-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 18rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.35;
}

.error-card {
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.08);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.error-card:hover,
.error-card.is-focused {
  border-color: rgba(248, 113, 113, 0.65);
  background: rgba(248, 113, 113, 0.12);
}

.error-card h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--red);
  font-weight: 600;
}

.error-meta {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}

.error-snippet {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0d0f0b;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.45;
  color: #e8e2d6;
  overflow-x: auto;
  white-space: pre;
}

.error-snippet .caret-line {
  color: var(--red);
}

.indent-hint {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.indent-hint h4 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--amber);
}

.indent-meta {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.indent-diff {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.indent-diff--extra {
  color: var(--red);
}

.indent-diff--missing {
  color: var(--amber);
}

.indent-compare {
  margin-top: 8px;
}

.indent-compare-title {
  margin: 0 0 6px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.indent-compare-line {
  margin: 0 0 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0d0f0b;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

.indent-compare-line.is-error-line {
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.indent-compare-line.is-expected-line {
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.06);
}

.indent-label {
  display: inline-block;
  min-width: 2.2rem;
  color: var(--muted);
  user-select: none;
}

.indent-hint .ws-char {
  color: rgba(251, 191, 36, 0.9);
}

.success-card {
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 12px;
  background: rgba(74, 222, 128, 0.08);
  padding: 12px 14px;
}

.success-card h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--green);
}

.success-stats {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.preview-block h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.preview-tree {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: #0d0f0b;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 280px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d6d0c4;
}

.preview-tree .key {
  color: var(--teal);
}

.preview-tree .str {
  color: var(--yellow);
}

.preview-tree .num {
  color: #93c5fd;
}

.preview-tree .bool {
  color: #c084fc;
}

.preview-tree .null {
  color: var(--muted);
}

.hints {
  flex-shrink: 0;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.hints ul {
  margin: 4px 0 0;
  padding-left: 1.2rem;
}

@media (min-width: 961px) {
  .hints {
    display: none;
  }
}

.hints li {
  margin: 4px 0;
}

.hints kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
}
