﻿:root {
      --bg: #f4f5f7;
      --surface: #fff;
      --fg: #1a1d26;
      --muted: #6d7485;
      --primary: #306b97;
      --primary-light: rgba(48, 107, 151, 0.12);
      --accent: #009a46;
      --error: #c0392b;
      --warn: #e67e22;
      --border: #e2e5ee;
      --font-sans: 'Segoe UI', system-ui, sans-serif;
      --font-mono: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
      --radius: 8px;
      --shadow: 0 1px 3px rgba(22, 28, 38, 0.06);
    }

    .json-editor-main {
      display: flex;
      flex: 1;
      min-height: 0;
      margin: 0;
      padding: 0;
      border-radius: 0;
      gap: 0;
      background: var(--bg);
    }

    .pane {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-width: 0;
      padding: 0.5rem;
      overflow: hidden;
    }

    .pane-tree {
      flex: 3 1 0;
    }

    .pane-editor {
      flex: 2 1 0;
    }

    .json-editor-main .pane + .pane {
      border-left: 1px solid var(--border);
    }

    .pane-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      margin-bottom: 0.35rem;
      flex-wrap: wrap;
      flex-shrink: 0;
    }

    .pane-header h2 {
      margin: 0;
      font-size: 0.95rem;
      font-weight: 650;
      color: var(--fg);
      letter-spacing: -0.02em;
    }

    .toolbar-zones {
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem;
      margin-bottom: 0.35rem;
      align-items: flex-end;
      flex-shrink: 0;
    }

    .toolbar-zone {
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
    }

    .toolbar-zone-label {
      font-size: 0.62rem;
      font-weight: 650;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--muted);
      padding-left: 0.1rem;
      user-select: none;
    }

    .toolbar-zone-actions {
      display: flex;
      gap: 0.3rem;
      align-items: center;
    }

    .toolbar-zone-actions.divider-left {
      padding-left: 1rem;
      border-left: 1px solid var(--border);
    }

    .btn {
      padding: 0.3rem 0.55rem;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--fg);
      border-radius: 6px;
      cursor: pointer;
      font-size: 0.75rem;
      font-family: var(--font-sans);
      transition: background 0.15s, border-color 0.15s;
      white-space: nowrap;
    }

    .btn:hover { background: #f0f2f6; border-color: #cdd2de; }
    .btn:active { transform: translateY(1px); }
    .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
    .btn.primary:hover { background: #285a80; }
    .btn.danger { color: var(--error); border-color: #f0c4c0; }
    .btn.danger:hover { background: #fdf2f2; }
    .btn:disabled { opacity: 0.45; cursor: not-allowed; }

    .btn-icon {
      width: 1.9rem;
      height: 1.9rem;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 0.95rem;
      line-height: 1;
    }

    .btn-icon.danger { color: var(--error); border-color: #f0c4c0; }
    .btn-icon.danger:hover { background: #fdf2f2; }

    .btn-menu.open {
      background: var(--primary-light);
      border-color: var(--primary);
      color: var(--primary);
    }

    .search-row {
      display: flex;
      gap: 0.35rem;
      margin-bottom: 0.35rem;
      align-items: center;
      flex-shrink: 0;
    }

    #search {
      flex: 1;
      padding: 0.45rem 0.6rem;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      font-size: 0.8rem;
      background: var(--surface);
    }

    #search:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 2px var(--primary-light);
    }

    .search-meta {
      font-size: 0.7rem;
      color: var(--muted);
      white-space: nowrap;
      min-width: 4.5rem;
      text-align: right;
    }

    #tree {
      flex: 1;
      overflow: auto;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 0.4rem;
      font-size: 0.8rem;
      box-shadow: var(--shadow);
      outline: none;
    }

    .node { margin-left: 0.85rem; }
    .node-label {
      display: flex;
      align-items: center;
      cursor: pointer;
      padding: 0.15rem 0.3rem;
      border-radius: 4px;
      gap: 0.2rem;
    }
    .node-label:hover { background: #f6f7fa; }
    .node-label.selected {
      background: rgba(48, 107, 151, 0.18);
      box-shadow: inset 3px 0 0 var(--primary);
    }
    .node-label.selected .key-name {
      color: var(--primary);
      font-weight: 650;
    }
    .node-label.selected:hover {
      background: rgba(48, 107, 151, 0.24);
    }
    .node-label.match { background: #fff3cd; }
    .node-label.match-current { background: #ffe69c; }
    .node-label.selected.match { background: #ffecb8; }
    .node-label.selected.match-current { background: #ffd966; }

    .toggle {
      width: 0.9rem;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      user-select: none;
      color: var(--muted);
      font-size: 0.65rem;
    }
    .toggle.closed::before { content: '▶'; }
    .toggle.expanded::before { content: '▼'; }
    .toggle-spacer {
      display: inline-block;
      width: 0.9rem;
    }

    .type-symbol {
      font-family: var(--font-mono);
      font-size: 0.72rem;
      margin-right: 0.15rem;
      color: var(--muted);
    }

    .key-name { font-weight: 500; }
    .key-name.renamable { cursor: text; }
    .key-name.renamable:hover { text-decoration: underline dotted; }

    .key-rename-input {
      font-family: var(--font-mono);
      font-size: 0.75rem;
      font-weight: 500;
      padding: 0.05rem 0.25rem;
      border: 1px solid var(--primary);
      border-radius: 3px;
      background: var(--surface);
      min-width: 3rem;
      max-width: 10rem;
    }
    .key-rename-input:focus {
      outline: none;
      box-shadow: 0 0 0 2px var(--primary-light);
    }
    .leaf-preview {
      color: var(--muted);
      font-family: var(--font-mono);
      font-size: 0.72rem;
      margin-left: 0.25rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 12rem;
    }

    .count {
      margin-left: 0.25rem;
      font-size: 0.68rem;
      color: var(--muted);
    }

    .node-add-wrap {
      margin-left: auto;
      padding-left: 0.35rem;
      flex-shrink: 0;
    }

    .node-add {
      width: 1.15rem;
      height: 1.15rem;
      padding: 0;
      border: none;
      border-radius: 3px;
      background: transparent;
      color: #c5c9d4;
      font-size: 0.9rem;
      font-weight: 500;
      line-height: 1;
      cursor: pointer;
      opacity: 0.3;
      transition: opacity 0.15s, color 0.15s, background 0.15s;
    }

    .node-label:hover .node-add,
    .node-label.selected .node-add,
    .node-add.menu-open,
    .node-add:focus-visible {
      opacity: 1;
      color: var(--primary);
    }

    .node-add:hover,
    .node-add.menu-open {
      background: var(--primary-light);
    }

    .flyout-menu,
    .tree-add-menu {
      position: fixed;
      z-index: 300;
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
      min-width: 6.75rem;
      padding: 0.3rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      box-shadow: 0 4px 14px rgba(22, 28, 38, 0.14);
    }

    .flyout-menu[hidden],
    .tree-add-menu[hidden] { display: none !important; }

    .flyout-menu button,
    .tree-add-menu button {
      padding: 0.35rem 0.55rem;
      border: none;
      border-radius: 4px;
      background: transparent;
      color: var(--fg);
      font-size: 0.75rem;
      font-family: var(--font-sans);
      text-align: left;
      cursor: pointer;
    }

    .flyout-menu button:hover,
    .tree-add-menu button:hover {
      background: #f0f2f6;
    }

    .flyout-menu button.menu-danger {
      color: var(--error);
    }

    .flyout-menu button.menu-danger:hover {
      background: #fdf2f2;
    }

    .flyout-menu .menu-sep {
      height: 1px;
      background: var(--border);
      margin: 0.15rem 0;
    }

    .editor-toolbar {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
      margin-top: 0.25rem;
      flex-shrink: 0;
    }

    .editor-toolbar-spacer {
      flex: 1;
      min-width: 0.5rem;
    }

    .children {
      margin-left: 0.35rem;
      padding-left: 0;
    }

    .breadcrumb {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 0.15rem;
      margin-bottom: 0.35rem;
      font-size: 0.78rem;
      min-height: 1.25rem;
      flex-shrink: 0;
    }

    .crumb {
      display: inline-flex;
      align-items: center;
      gap: 0.15rem;
      padding: 0.15rem 0.4rem;
      border-radius: 4px;
      background: #eef0f5;
      border: none;
      cursor: pointer;
      font-family: var(--font-mono);
      font-size: 0.75rem;
      color: var(--fg);
    }
    .crumb:hover { background: #e2e6ef; }
    .crumb.root { font-family: var(--font-sans); font-weight: 600; }
    .crumb-sep { color: var(--muted); user-select: none; }

    .editor-area {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
      gap: 0.25rem;
    }

    #jsonEditor {
      flex: 1;
      font-family: var(--font-mono);
      font-size: 0.82rem;
      line-height: 1.45;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 0.6rem;
      resize: none;
      min-height: 8rem;
      background: var(--surface);
      box-shadow: var(--shadow);
    }
    #jsonEditor:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 2px var(--primary-light);
    }
    #jsonEditor.invalid { border-color: var(--error); background: #fdf6f5; }

    .controls {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.35rem;
      margin-top: 0.35rem;
    }

    .status-pill {
      font-size: 0.7rem;
      padding: 0.2rem 0.5rem;
      border-radius: 99px;
      background: #eef0f5;
      color: var(--muted);
    }
    .status-pill.ok { background: #e8f6ee; color: #1e7a45; }
    .status-pill.warn { background: #fff3e0; color: #b35c00; }
    .status-pill.err { background: #fdecea; color: var(--error); }

    .toast {
      position: fixed;
      bottom: 2.5rem;
      right: 1rem;
      padding: 0.55rem 0.85rem;
      border-radius: var(--radius);
      background: #1a1d26;
      color: #fff;
      font-size: 0.78rem;
      opacity: 0;
      transform: translateY(0.5rem);
      transition: opacity 0.2s, transform 0.2s;
      pointer-events: none;
      z-index: 200;
      max-width: 18rem;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
    .toast.error { background: var(--error); }

    .status-bar {
      flex-shrink: 0;
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem;
      padding: 0.25rem 0.5rem;
      font-size: 0.7rem;
      color: var(--muted);
      background: var(--surface);
      border-top: 1px solid var(--border);
      font-variant-numeric: tabular-nums;
    }

    .status-bar strong { color: var(--fg); font-weight: 600; }

    .drop-overlay { display: none; position: fixed; inset: var(--shell-header-h, 3.75rem) 0 0 0;
      background: rgba(48, 107, 151, 0.15);
      border: 3px dashed var(--primary);
      z-index: 50;
      align-items: center;
      justify-content: center;
      font-size: 1.1rem;
      color: var(--primary);
      font-weight: 600;
      pointer-events: none;
    }
    .drop-overlay.active { display: flex; }

    @media (max-width: 768px) {
      .json-editor-main { flex-direction: column; }
      .json-editor-main .pane + .pane { border-left: none; border-top: 1px solid var(--border); }
      .pane-tree { flex: 3 1 0; min-height: 0; }
      .pane-editor { flex: 2 1 0; min-height: 0; }
    }

    .shell-main.json-editor-page {
      margin: 0;
      padding: 0;
      border: none;
      box-shadow: none;
      border-radius: 0;
      background: transparent;
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;
      overflow: hidden;
    }

    body[data-shell-active] .shell-main.json-editor-page {
      padding: 0;
    }

    .shell-main.json-editor-page .tool-page-header,
    .shell-main.json-editor-page .tool-lead {
      display: none;
    }

    body.json-editor-app {
      overflow: hidden;
      height: 100vh;
      max-height: 100dvh;
    }

    body.json-editor-app #shell-footer {
      display: none;
    }

    body.json-editor-app .shell-body {
      flex: 1;
      min-height: 0;
      overflow: hidden;
    }

    .json-editor-root {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      background: var(--bg);
    }

