#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 46px;
  padding: 0 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

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

.logo {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -1px;
}

.brand-name { font-weight: 650; color: var(--fg-strong); letter-spacing: .2px; }

.doc { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.doc-name { color: var(--fg-strong); font-size: 12.5px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { color: var(--faint); font-size: 11.5px; white-space: nowrap; }

.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.search {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 5px 0 9px;
  min-width: 300px;
  flex: 0 1 420px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { color: var(--faint); font-size: 14px; }
.search input { flex: 1 1 auto; min-width: 0; height: 100%; color: var(--fg-strong); }
.search input::placeholder { color: var(--faint); }
.mcount { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; padding: 0 4px; }
.search .btn.icon { background: transparent; border-color: transparent; }
.search .btn.icon:hover { background: var(--bg-3); }

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

.stats {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 0;
  overflow: hidden;
  background: var(--bg-1);
  border-bottom: 1px solid transparent;
  transition: height var(--t-fast);
  flex: 0 0 auto;
}

.stats.on { height: 32px; border-bottom-color: var(--line); }

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: 20px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.stat b { color: var(--fg-strong); font-weight: 600; font-family: var(--font-mono); }
.stat .dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.o { background: var(--key); }
.dot.a { background: var(--number); }
.dot.s { background: var(--string); }
.dot.n { background: var(--number); }
.dot.b { background: var(--bool); }
.dot.z { background: var(--null); }

.crumb {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 0;
  padding: 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-1);
  border-bottom: 1px solid transparent;
  white-space: nowrap;
  flex: 0 0 auto;
  scrollbar-width: none;
}

.crumb::-webkit-scrollbar { height: 0; }
.crumb.on { height: 30px; border-bottom-color: var(--line); }

.crumb-item {
  height: 21px;
  padding: 0 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
}

.crumb-item:hover { background: var(--accent-soft); }
.crumb-item.cur { color: var(--fg-strong); background: var(--bg-3); }
.crumb-sep { color: var(--faint); font-size: 11px; padding: 0 1px; }

.content { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }

.view { position: relative; display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; }

.subbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 26px;
  padding: 0 12px;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  flex: 0 0 auto;
}

.st-item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stPath { color: var(--accent); max-width: 55vw; cursor: pointer; }
#stPath:hover { text-decoration: underline; }
.st-sep { width: 1px; height: 13px; background: var(--line); }

.empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); }
.empty-card { text-align: center; max-width: 380px; padding: 24px; }
.empty-logo { font-family: var(--font-mono); font-size: 42px; color: var(--line); margin-bottom: 8px; letter-spacing: -3px; }
.empty-card h2 { font-size: 17px; color: var(--fg-strong); margin-bottom: 6px; font-weight: 650; }
.empty-card p { color: var(--muted); margin-bottom: 18px; }

.pop-wrap { position: relative; }

.popover {
  position: absolute;
  top: 34px;
  right: 0;
  width: 260px;
  padding: 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  z-index: 60;
  display: none;
  flex-direction: column;
  gap: 10px;
}

.popover.on { display: flex; }
.pop-title { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); font-weight: 600; }
.popover .field select { width: 108px; height: 24px; padding: 0 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.pop-foot { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line-soft); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  background: rgba(4, 8, 14, .62);
  backdrop-filter: blur(3px);
}

.modal.on { display: flex; }

.modal-card {
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop .14s ease;
}

.modal-card.sm { max-width: 460px; }

@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.99); } }

.modal-head { display: flex; align-items: center; padding: 14px 16px 10px; }
.modal-head h2 { font-size: 15px; font-weight: 650; color: var(--fg-strong); }
.modal-head .btn.icon { margin-left: auto; }
.modal-tabs { margin: 0 16px; align-self: flex-start; }
.modal-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.modal-body { padding: 12px 16px 4px; }

.pane { display: none; }
.pane.on { display: block; }

#inText {
  width: 100%;
  height: clamp(120px, 26vh, 220px);
  padding: 12px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--fg-strong);
  white-space: pre;
  overflow: auto;
  direction: ltr;
}

#inText:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pane-actions { display: flex; flex-wrap: nowrap; gap: 6px; margin-top: 10px; overflow-x: auto; padding-bottom: 2px; }
.pane-actions .btn { flex: 0 0 auto; }
.pane-actions::-webkit-scrollbar, .err-actions::-webkit-scrollbar { height: 0; }

.drop-area {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 34px 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-md);
  background: var(--bg-2);
  text-align: center;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.drop-area.hot { border-color: var(--accent); background: var(--accent-soft); }
.drop-ico { font-size: 26px; color: var(--muted); }

.vstatus { padding: 8px 16px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; min-height: 32px; }
.vstatus .ok { color: var(--ok); font-weight: 600; }
.vstatus .bad { color: var(--danger); font-weight: 600; }

.errbox { margin: 0 16px 12px; border: 1px solid var(--danger); border-radius: var(--r-md); background: var(--danger-bg); overflow: hidden; }
.err-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; flex-wrap: nowrap; min-width: 0; }
.err-badge { flex: 0 0 auto; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--danger); border: 1px solid var(--danger); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.err-msg { flex: 1 1 auto; min-width: 0; color: var(--fg-strong); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-pos { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.err-snip {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  color: var(--fg);
  white-space: pre;
}

.err-snip .lno { color: var(--faint); user-select: none; }
.err-snip .bad-line { color: var(--fg-strong); }
.err-snip .caret { color: var(--danger); font-weight: 700; }

.err-hints { margin: 0; padding: 8px 12px 8px 30px; font-size: 12px; color: var(--fg); }
.err-hints li { margin: 3px 0; }
.err-hints code { font-family: var(--font-mono); background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.err-actions { display: flex; gap: 6px; padding: 8px 12px 10px; flex-wrap: nowrap; overflow-x: auto; }
.err-actions .btn { flex: 0 0 auto; }

.modal-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--bg-2); }

.keys-grid { display: grid; grid-template-columns: auto auto 1fr; gap: 7px 8px; align-items: center; padding: 4px 16px 18px; }
.keys-grid span { color: var(--muted); font-size: 12.5px; }

.drop-overlay { position: fixed; inset: 0; z-index: 120; display: none; place-items: center; background: rgba(4, 8, 14, .7); backdrop-filter: blur(2px); }
.drop-overlay.on { display: grid; }
.drop-overlay-in { padding: 40px 60px; border: 2px dashed var(--accent); border-radius: var(--r-lg); color: var(--fg-strong); font-size: 16px; font-weight: 600; background: var(--bg-1); }

.toasts { position: fixed; bottom: 38px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none; }

.toast {
  padding: 8px 14px;
  border-radius: 22px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--fg-strong);
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: toast-in .16s ease;
}

.toast.bad { border-color: var(--danger); color: var(--danger); }
.toast.good { border-color: var(--ok); }
.toast.out { animation: toast-out .18s ease forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

@media (max-width: 900px) {
  .doc { display: none; }
  .brand-name { display: none; }
  .search { min-width: 180px; }
}
