:root {
  color-scheme: light;
  --bg: #eff0eb;
  --surface: #fffefa;
  --surface-strong: #ffffff;
  --ink: #111111;
  --muted: #626a5d;
  --line: #d9dfd0;
  --logo-green: #80a24d;
  --logo-green-light: #99cc66;
  --accent: #5f7a38;
  --accent-strong: #35471e;
  --accent-soft: #edf5e7;
  --warn: #b2452c;
  --warn-soft: #fff0ea;
  --shadow: 0 18px 45px rgba(35, 42, 32, 0.11);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(128, 162, 77, 0.18), transparent 34%),
    linear-gradient(225deg, rgba(153, 204, 102, 0.13), transparent 30%),
    var(--bg);
  color: var(--ink);
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 14px;
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(35, 42, 32, 0.14));
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 2.6vw, 2.45rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.file-input {
  display: none;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, auto);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  box-shadow: 0 10px 26px rgba(35, 42, 32, 0.08);
  backdrop-filter: blur(14px);
}

.control-group {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.control-group-title {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.control-row {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

select,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
}

select {
  padding: 0 34px 0 11px;
}

.checkbox-control {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
}

.checkbox-control:hover {
  border-color: rgba(128, 162, 77, 0.6);
}

.checkbox-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

button {
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

button:disabled,
.checkbox-control:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.52;
}

button:hover,
select:hover {
  border-color: rgba(128, 162, 77, 0.6);
}

button:active {
  transform: translateY(1px);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.ghost-button {
  background: transparent;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 38px;
}

.status-pill,
.stats {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-valid {
  border-color: rgba(128, 162, 77, 0.34);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-error {
  border-color: rgba(178, 69, 44, 0.3);
  background: var(--warn-soft);
  color: var(--warn);
}

.editor-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.editor-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

.pane-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.view-tabs {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.view-tab {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.view-tab + .view-tab {
  border-left: 1px solid var(--line);
}

.view-tab.active {
  background: var(--accent);
  color: white;
}

.tree-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 68px;
  transition: opacity 160ms ease;
}

.tree-actions.is-hidden {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

.tree-actions .icon-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

.tree-actions .icon-button span {
  display: block;
  transform: translateY(-1px);
}

.pane-header label {
  font-weight: 900;
}

.pane-header span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 440px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 18px;
  background: transparent;
  color: #142018;
  font-family:
    "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.96rem;
  line-height: 1.55;
  tab-size: 2;
}

textarea::placeholder {
  color: #8a948b;
}

#formattedOutput {
  background: rgba(128, 162, 77, 0.045);
}

.hidden {
  display: none;
}

.tree-output {
  min-height: 440px;
  overflow: auto;
  padding: 18px;
  background: rgba(128, 162, 77, 0.045);
  color: #142018;
  font-family:
    "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.94rem;
  line-height: 1.5;
}

.tree-node {
  margin: 1px 0;
}

.tree-children {
  margin-left: 20px;
  padding-left: 10px;
  border-left: 1px solid rgba(128, 162, 77, 0.25);
}

.tree-toggle {
  min-height: 24px;
  min-width: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-weight: 900;
}

.tree-toggle:hover {
  border-color: transparent;
}

.tree-line {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.tree-key {
  color: #425f22;
  font-weight: 900;
}

.tree-index,
.tree-meta {
  color: var(--muted);
}

.tree-string {
  color: #7b3d1d;
}

.tree-number {
  color: #1f5f86;
}

.tree-boolean {
  color: #7a4a92;
}

.tree-null {
  color: #777;
}

.tree-empty {
  color: var(--muted);
  font-style: italic;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.app-footer a {
  color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.app-footer span:has([data-version]) {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.app-footer [data-version] {
  color: var(--accent);
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
    min-height: calc(100vh - 20px);
    margin: 10px auto;
  }

  .top-bar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .action-bar {
    justify-content: flex-start;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

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

  textarea {
    min-height: 300px;
  }

  .tree-output {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  .top-bar {
    padding: 14px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }

  .action-bar,
  .control-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    width: 100%;
  }

  .control-group {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .action-bar button {
    min-width: 0;
  }

  .checkbox-control {
    grid-column: span 2;
  }

  .status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .pane-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .pane-tools {
    justify-content: space-between;
    width: 100%;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-footer span:has([data-version]) {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .status-pill,
  .stats {
    width: 100%;
  }
}
