*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #07090f;
  --bg-header:  #0b0e1a;
  --bg-pane:    #0d1017;
  --bg-ph:      #111520;
  --bg-input:   #0a0d14;
  --border:     rgba(255,255,255,0.07);
  --border-mid: rgba(255,255,255,0.10);
  --accent:     #22d3ee;
  --accent-dim: rgba(34,211,238,0.12);
  --accent-mid: rgba(34,211,238,0.25);
  --text:       #e2e8f0;
  --text-muted: rgba(255,255,255,0.35);
  --text-dim:   rgba(255,255,255,0.18);
  --green:      #4ade80;
  --red:        #f87171;
  --radius:     10px;

  --s-key:   #7dd3fc;
  --s-str:   #86efac;
  --s-num:   #fdba74;
  --s-bool:  #f9a8d4;
  --s-null:  #94a3b8;
  --s-punct: #475569;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

.page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── HEADER ──────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 54px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-name {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.logo-name span { color: var(--accent); }

.logo-sep {
  width: 1px;
  height: 14px;
  background: var(--border-mid);
  margin: 0 4px;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-mid);
  margin: 0 4px;
}

.indent-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.indent-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.custom-select {
  position: relative;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s;
}

.custom-select-trigger:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
}

.custom-select-trigger svg {
  opacity: 0.5;
  transition: transform 0.15s;
}

.custom-select.open .custom-select-trigger {
  border-color: var(--accent);
}

.custom-select.open .custom-select-trigger svg {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: #111827;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 4px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.custom-select-option {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.custom-select-option:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}

.custom-select-option.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: 'Inter', system-ui, sans-serif;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn svg { width: 13px; height: 13px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #07090f;
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-color: var(--border-mid);
}
.btn-ghost:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.16); }
.btn-ghost:active { transform: scale(0.97); }
.btn-ghost.success { color: var(--green); border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.08); }

/* ── EDITOR ──────────────────────────────────── */
.editor {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── PANE ────────────────────────────────────── */
.pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.pane-input  { background: var(--bg-input); }
.pane-output { background: var(--bg-pane); border-left: 1px solid var(--border); }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 38px;
  background: var(--bg-ph);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pane-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.pane-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* ── VIEW TABS ───────────────────────────────── */
.view-tabs {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

.view-tab {
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 5px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.12s;
}

.view-tab:hover { color: var(--text); }
.view-tab.active { background: var(--accent-dim); color: var(--accent); }

/* ── RESIZER ─────────────────────────────────── */
.resizer {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
  z-index: 5;
}
.resizer:hover, .resizer.dragging { background: var(--accent); }

/* ── INPUT TEXTAREA ──────────────────────────── */
.textarea-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
}

textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.7;
  padding: 16px 20px;
  resize: none;
  tab-size: 2;
}

textarea::placeholder { color: var(--text-dim); font-family: 'Inter', system-ui, sans-serif; }

textarea.drag-over { background: var(--accent-dim); }

/* ── OUTPUT ──────────────────────────────────── */
.output-wrap {
  flex: 1;
  display: flex;
  overflow: auto;
  position: relative;
}

.line-numbers {
  flex-shrink: 0;
  padding: 16px 12px 16px 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
  text-align: right;
  user-select: none;
  border-right: 1px solid var(--border);
  background: var(--bg-ph);
  min-width: 48px;
  white-space: pre;
}

.output {
  flex: 1;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre;
  overflow: visible;
  word-break: normal;
}

.placeholder { color: var(--text-dim); font-family: 'Inter', system-ui, sans-serif; }

.output .s-key   { color: var(--s-key); }
.output .s-str   { color: var(--s-str); }
.output .s-num   { color: var(--s-num); }
.output .s-bool  { color: var(--s-bool); }
.output .s-null  { color: var(--s-null); }
.output .s-punct { color: var(--s-punct); }

.output .err-line { background: rgba(248,113,113,0.10); display: inline-block; width: 100%; }

/* ── TREE VIEW ───────────────────────────────── */
.tree-output {
  flex: 1;
  padding: 12px 16px;
  overflow: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

.tree-node { margin-left: 18px; }
.tree-node:first-child { margin-left: 0; }

.tree-header {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 1px 0;
  border-radius: 4px;
  transition: background 0.1s;
}
.tree-header:hover { background: rgba(255,255,255,0.04); }

.tree-toggle {
  width: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 10px;
  transition: transform 0.15s;
  user-select: none;
}

.tree-key { color: var(--s-key); }
.tree-colon { color: var(--s-punct); margin: 0 3px; }
.tree-bracket { color: var(--s-punct); }
.tree-count { color: var(--text-dim); font-size: 11px; margin-left: 5px; }
.tree-children { border-left: 1px solid var(--border); margin-left: 7px; padding-left: 10px; }
.tree-primitive { padding: 1px 0; cursor: default; }
.tree-type { font-size: 10px; color: var(--text-dim); margin-left: 5px; }

/* ── STATUS BAR ──────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 32px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 11.5px;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-idle   { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.status-valid  { display: flex; align-items: center; gap: 6px; color: var(--green); }
.status-valid .status-dot  { background: var(--green); }
.status-error  { display: flex; align-items: center; gap: 6px; color: var(--red); }
.status-error .status-dot  { background: var(--red); }

.stat { color: var(--text-muted); }
.stat span { color: var(--text); font-weight: 500; }

.status-privacy {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11.5px;
}
.status-privacy:hover { color: var(--accent); }

/* ── DROP OVERLAY ────────────────────────────── */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,9,15,0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border: 2px dashed var(--accent);
  border-radius: 0;
  transition: opacity 0.2s;
}

.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--accent);
}

.drop-overlay-inner p { font-size: 18px; font-weight: 600; }

/* ── UTILITIES ───────────────────────────────── */
.hidden { display: none !important; }

.file-input-hidden {
  display: none;
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── MOBILE TAB BAR (hidden on desktop) ──────── */
.mobile-tab-bar { display: none; }

/* ── PANE HEADER ACTIONS (mobile-only, hidden on desktop) ── */
.pane-header-actions { display: none; }

/* ── MOBILE ──────────────────────────────────── */
@media (max-width: 768px) {

  .page { height: 100svh; }

  /* Header — compact, touch-friendly */
  .header {
    padding: 0 14px;
    height: 52px;
    gap: 8px;
  }
  .toolbar { justify-content: flex-end; }
  .logo-sub { display: none; }
  .indent-wrap { display: none; }
  .toolbar-sep { display: none; }
  .pane-hint { display: none; }

  .btn {
    padding: 0;
    width: 40px;
    height: 40px;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
  }
  /* hide text labels, keep icons */
  .btn > svg { width: 16px; height: 16px; }
  .btn-label { display: none; }
  .btn-primary { width: auto; padding: 0 14px; gap: 6px; font-size: 13px; }
  .btn-primary .btn-label { display: inline; }

  /* Editor — single pane at a time */
  .editor {
    flex-direction: column;
    position: relative;
  }

  .resizer { display: none; }

  .pane {
    position: absolute;
    inset: 0;
    flex: none;
    width: 100%;
    height: 100%;
    transition: opacity 0.18s;
  }

  .pane.hidden-mobile {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }

  .pane-output {
    border-left: none;
    border-top: none;
  }

  /* Pane header — tighter */
  .pane-header { height: 40px; padding: 0 10px; }
  .header-actions { display: none; }
  .pane-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .pane-header-actions .btn {
    width: 36px;
    height: 36px;
    padding: 0;
  }
  .pane-header-actions .btn svg {
    width: 16px;
    height: 16px;
  }

  /* Textarea fills full pane */
  textarea { font-size: 14px; padding: 14px; }

  /* Output fills full pane */
  .output { font-size: 13px; padding: 14px; }
  .line-numbers { padding: 14px 10px 14px 12px; }

  /* Status bar — hidden on mobile (info moved to tab bar) */
  .status-bar { display: none; }

  /* Bottom tab bar */
  .mobile-tab-bar {
    display: flex;
    align-items: stretch;
    height: 58px;
    background: var(--bg-header);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    letter-spacing: 0.3px;
    padding: 6px 0 8px;
    border-bottom: 2px solid transparent;
  }

  .mobile-tab svg { width: 20px; height: 20px; }

  .mobile-tab:hover { color: var(--text); }

  .mobile-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  .mobile-tab-status {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
  }

  .mobile-tab-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.2s;
  }

  .mobile-tab-status.is-valid .status-dot { background: var(--green); }
  .mobile-tab-status.is-error .status-dot { background: var(--red); }
}

@media (max-width: 480px) {
  .pane-hint { display: none; }
  .view-tabs { display: none; }
}
