:root {
  color-scheme: dark;
  --bg: #0c0f10;
  --panel: #111517;
  --panel-deep: #0e1213;
  --line: #263034;
  --line-soft: #1a2225;
  --text: #e8efed;
  --muted: #84918e;
  --accent: #62d6bd;
  --accent-soft: rgba(98, 214, 189, 0.12);
  --string: #b9dd92;
  --number: #8fc9ff;
  --boolean: #d8a5ff;
  --null: #89928f;
  --danger: #ff8f8f;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100dvh; display: grid; grid-template-rows: 58px 1fr; }
.product-bar { min-width: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); background: #0f1314; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-weight: 700; }
.brand strong { font-size: 16px; }
.product-label { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.mobile-tabs { display: none; }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); }
.pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto 1fr auto; background: var(--panel); }
.tree-pane { grid-template-rows: auto auto 1fr; border-left: 1px solid var(--line); background: var(--panel-deep); }
.pane-head { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 18px; border-bottom: 1px solid var(--line-soft); }
.pane-head > div:first-child { min-width: 0; display: flex; align-items: center; gap: 10px; }
.pane-head h1, .pane-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.step { color: var(--accent); font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.light-actions { display: flex; align-items: center; gap: 6px; }
.light-actions button, .search-bar button { min-height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.light-actions button:hover, .search-bar button:hover { border-color: var(--line); color: var(--text); background: rgba(255,255,255,0.025); }

#json-input { width: 100%; min-height: 340px; resize: none; padding: 20px; border: 0; outline: 0; background: #101415; color: #dce5e2; caret-color: var(--accent); font: 14px/1.75 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; tab-size: 2; }
#json-input::placeholder { color: #5e6b68; }
.input-footer { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
.status { min-width: 0; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.status.success { color: var(--accent); }
.status.error { color: var(--danger); }
.format-button { min-height: 42px; flex: none; padding: 0 17px; border: 1px solid #75e1c8; border-radius: 7px; background: var(--accent); color: #08231d; cursor: pointer; font-size: 13px; font-weight: 750; }
.format-button:hover { background: #7ce5cf; }

.search-bar { display: grid; grid-template-columns: minmax(120px, 1fr) auto 36px 36px; gap: 6px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line-soft); }
.search-field { min-width: 0; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #0d1112; color: var(--muted); }
.search-field:focus-within { border-color: #527d74; box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-field input::placeholder { color: #65716e; }
.match-count { min-width: 42px; color: var(--muted); font-size: 11px; text-align: right; }
.search-bar button { width: 36px; padding: 0; border-color: var(--line); }

.tree { min-width: 0; min-height: 340px; overflow: auto; padding: 16px 18px 40px; outline: 0; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.empty-tree { min-height: 100%; display: grid; align-content: center; justify-items: center; padding: 48px 20px; color: var(--muted); text-align: center; }
.empty-tree span { margin-bottom: 14px; color: #3e504c; font-size: 46px; }
.empty-tree strong { color: #a8b3b0; font: 600 13px/1.4 ui-sans-serif, sans-serif; }
.empty-tree p { max-width: 280px; margin: 8px 0 0; font: 12px/1.6 ui-sans-serif, sans-serif; }
.tree-node { min-width: max-content; }
.node-row { min-height: 28px; display: flex; align-items: flex-start; gap: 5px; width: max-content; max-width: 100%; padding: 2px 7px 2px 3px; border-radius: 4px; }
.node-row.match { background: rgba(255, 216, 102, 0.09); box-shadow: inset 2px 0 #b99d43; }
.node-row.current-match { background: rgba(98, 214, 189, 0.16); box-shadow: inset 2px 0 var(--accent); }
.node-toggle, .node-spacer { width: 22px; height: 22px; flex: none; display: inline-grid; place-items: center; border: 0; background: transparent; color: #81908c; }
.node-toggle { cursor: pointer; border-radius: 4px; }
.node-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.node-key { max-width: 38vw; color: #d8e2df; overflow-wrap: anywhere; white-space: pre-wrap; }
.node-colon, .node-meta, .node-bracket { color: #62706c; }
.node-value { max-width: 46vw; overflow-wrap: anywhere; white-space: pre-wrap; }
.type-string { color: var(--string); }
.type-number { color: var(--number); }
.type-boolean { color: var(--boolean); }
.type-null { color: var(--null); font-style: italic; }
.node-children { margin-left: 14px; padding-left: 11px; border-left: 1px solid #283234; }

@media (max-width: 760px) {
  .app-shell { grid-template-rows: 56px auto 1fr; }
  .product-bar { padding: 0 16px; }
  .product-label { display: none; }
  .mobile-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #0f1314; }
  .mobile-tab { min-height: 44px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; }
  .mobile-tab.active { border-bottom-color: var(--accent); color: var(--text); }
  .workspace { display: block; min-height: 0; }
  .pane { display: none; min-height: calc(100dvh - 117px); }
  .pane.active { display: grid; }
  .tree-pane { border-left: 0; }
  .pane-head { min-height: 60px; padding: 0 12px; }
  .light-actions button { min-width: 44px; min-height: 44px; padding: 0 8px; }
  #json-input { min-height: 50dvh; padding: 16px; font-size: 16px; line-height: 1.65; }
  .input-footer { min-height: 74px; padding: 10px 12px; }
  .format-button { min-height: 46px; padding: 0 15px; }
  .search-bar { grid-template-columns: minmax(0, 1fr) auto 44px 44px; padding: 9px 12px; }
  .search-field { height: 44px; }
  .search-field input { font-size: 16px; }
  .search-bar button { width: 44px; min-height: 44px; }
  .tree { padding: 14px 12px 40px; font-size: 12px; }
  .tree-node, .node-children { min-width: 0; width: 100%; }
  .node-row { width: 100%; min-width: 0; }
  .node-key, .node-value { min-width: 0; max-width: none; overflow-wrap: anywhere; }
}

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