/* Top control bar */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-height: 42px;
  padding: 6px 12px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
}

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

.topbar-right {
  margin-left: auto;
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
}

.sample-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.sample-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 2px;
}

/* Buttons & inline controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn:active {
  background: var(--border);
}

.btn-primary {
  background: var(--primary-bg);
  border-color: var(--primary-bg);
  color: var(--primary-fg);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-bg-hover);
  border-color: var(--primary-bg-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 0 7px;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-clear:hover {
  background: var(--err-soft);
  color: var(--err);
}

.btn-sm {
  height: 25px;
  padding: 0 8px;
  font-size: 12px;
}

.btn-icon {
  width: 28px;
  padding: 0;
  font-size: 14px;
}

.btn.is-muted {
  color: var(--muted);
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 4px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.check-control input {
  margin: 0;
  accent-color: var(--primary-bg);
  cursor: pointer;
}

.select-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.select-label {
  font-size: 12px;
  color: var(--muted);
}

select {
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

select:hover {
  border-color: var(--muted);
}

/* Panes */
.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.pane-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 38px;
  padding: 0 8px 0 10px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
}

.pane-head-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.pane-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.store-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.store-dot-gp {
  background: var(--gp);
}

.store-dot-as {
  background: var(--as);
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 19px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-hover);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.count-pill.has-items {
  color: var(--text);
}

/* Filter + sort strip inside result panes */
.pane-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  height: 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.filter-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.filter-input::placeholder {
  color: var(--muted);
}

.filter-input:focus {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--focus);
}

.sort-select {
  height: auto;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  padding: 0 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11.5px;
}

.sort-select:focus-visible {
  outline-offset: -2px;
}

/* Pane body: editor & ID output */
.pane-body {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
}

.code-input {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 12px;
  resize: none;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.55;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.code-input::placeholder {
  color: var(--muted);
}

.code-input:focus {
  outline: none;
}

.dropzone.is-dragging .code-input {
  opacity: 0.35;
}

.drop-overlay {
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--focus);
  border-radius: var(--radius);
  background: var(--drop-bg);
  color: var(--focus);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.pane-output {
  overflow: auto;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.empty-msg {
  margin: 0;
  padding: 14px 12px;
  color: var(--muted);
  font-size: 12px;
}

.id-list {
  margin: 0;
  padding: 10px 12px;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre;
  tab-size: 2;
}

/* Pane footer */
.pane-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 27px;
  padding: 0 12px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
}

.pane-meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

kbd {
  padding: 1px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 10px;
}

/* Bottom status bar */
.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
  padding: 4px 12px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

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

.status-dot.is-ok {
  background: var(--ok);
}

.status-dot.is-warn {
  background: var(--warn);
}

.status-dot.is-err {
  background: var(--err);
}

.status-text {
  margin: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-text.is-ok {
  color: var(--ok);
}

.status-text.is-warn {
  color: var(--warn);
}

.status-text.is-err {
  color: var(--err);
}

.status-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  color: var(--muted);
}

.status-local {
  white-space: nowrap;
}

.notes-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.notes-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.notes-toggle .caret {
  display: inline-block;
  font-size: 10px;
  transition: transform 120ms ease;
}

.notes-toggle[aria-expanded="true"] .caret {
  transform: rotate(180deg);
}

/* Collapsible bottom reference notes */
.notes-drawer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 10px 14px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  line-height: 1.5;
}

.note-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-weight: 600;
}

.note-item p {
  margin: 0;
  color: var(--muted);
}

/* Toast */
.toast {
  position: fixed;
  right: 12px;
  bottom: 38px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 24px));
  padding: 7px 12px;
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-size: 12px;
  font-weight: 500;
}

.noscript-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0;
  padding: 8px 12px;
  background: var(--warn);
  color: #fff;
  text-align: center;
  font-size: 12px;
}

@media (max-width: 719px) {
  .topbar {
    padding: 8px 10px;
  }

  .topbar-right {
    margin-left: 0;
  }

  .select-label {
    display: none;
  }

  .status-text {
    white-space: normal;
  }

  .status-local,
  .status-sep {
    display: none;
  }

  .notes-drawer {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
