/* ==========================================================================
   InceptionDB Console — "Deck" design system
   A precision instrument panel for a journal-based document engine.
   Theme via body.theme-dark / body.theme-light (system preference).
   ========================================================================== */

.console {
  --deck-bg: #060a13;
  --deck-panel: #0b1120;
  --deck-card: #0e1526;
  --deck-raise: #131c30;
  --deck-field: #0a101d;
  --deck-code: #070c18;
  --deck-line: #1a2438;
  --deck-line-strong: #273450;
  --deck-text: #dce6f5;
  --deck-muted: #8fa1bd;
  --deck-dim: #5d6f8c;
  --deck-brand: #38bdf8;
  --deck-brand2: #8b5cf6;
  --deck-brand-ink: #06263a;
  --deck-ok: #34d399;
  --deck-warn: #fbbf24;
  --deck-danger: #fb7185;
  --deck-grid: rgba(148, 183, 235, 0.05);
  --deck-glow-a: rgba(56, 189, 248, 0.09);
  --deck-glow-b: rgba(139, 92, 246, 0.08);
  --deck-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
  --j-key: #7dd3fc;
  --j-str: #5eead4;
  --j-num: #fcd34d;
  --j-bool: #c4b5fd;
  --j-null: #64748b;
}

body.theme-light .console {
  --deck-bg: #eef1f7;
  --deck-panel: #ffffff;
  --deck-card: #ffffff;
  --deck-raise: #f3f6fb;
  --deck-field: #fbfcfe;
  --deck-code: #0e1526;
  --deck-line: #e2e8f2;
  --deck-line-strong: #cbd6e8;
  --deck-text: #161f31;
  --deck-muted: #54647e;
  --deck-dim: #8b9ab4;
  --deck-brand: #0284c7;
  --deck-brand2: #7c3aed;
  --deck-brand-ink: #0c4a6e;
  --deck-ok: #059669;
  --deck-warn: #b45309;
  --deck-danger: #e11d48;
  --deck-grid: rgba(15, 23, 42, 0.05);
  --deck-glow-a: rgba(2, 132, 199, 0.08);
  --deck-glow-b: rgba(124, 58, 237, 0.06);
  --deck-shadow: 0 24px 60px -28px rgba(15, 23, 42, 0.35);
  --j-key: #0369a1;
  --j-str: #0d9488;
  --j-num: #b45309;
  --j-bool: #7c3aed;
  --j-null: #94a3b8;
}

/* scoped reset ---------------------------------------------------------------- */
.console, .console *, .console *::before, .console *::after {
  box-sizing: border-box;
}
.console button {
  font: inherit;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}
.console input, .console select, .console textarea {
  font: inherit;
  color: inherit;
}
.console h1, .console h2, .console h3, .console h4, .console p, .console ul, .console pre {
  margin: 0;
}
.console ul {
  list-style: none;
  padding: 0;
}
.console svg {
  display: block;
}

/* shell ---------------------------------------------------------------------- */
.console-shell {
  display: flex;
  height: calc(100vh - 65px);
  min-height: 480px;
  overflow: hidden;
  position: relative;
  background: var(--deck-bg);
  color: var(--deck-text);
}

body.embed .console-shell {
  height: 100vh;
}

/* rail — icon column ---------------------------------------------------------- */
.rail {
  width: 64px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 0;
  background: linear-gradient(180deg, var(--deck-panel), var(--deck-bg));
  border-right: 1px solid var(--deck-line);
}

.rail-brand {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  margin-bottom: 10px;
  background: #0a101d;
  border: 1px solid var(--deck-line-strong);
  box-shadow: 0 4px 18px -6px rgba(56, 189, 248, 0.35);
  transition: transform 0.2s ease;
}
body.theme-light .rail-brand {
  background: #0e1526;
}
.rail-brand:hover {
  transform: rotate(12deg) scale(1.06);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  align-items: center;
  flex: 1;
}

.rail-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--deck-dim);
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.rail-btn:hover {
  color: var(--deck-text);
  background: var(--deck-raise);
}
.rail-btn.is-active {
  color: var(--deck-brand);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(139, 92, 246, 0.16));
}
.rail-btn.is-active::before {
  content: '';
  position: absolute;
  left: -9px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--deck-brand), var(--deck-brand2));
}

.rail-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--deck-dim);
  display: inline-block;
}
.status-dot.is-online    { background: var(--deck-ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.status-dot.is-degraded  { background: var(--deck-warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }
.status-dot.is-offline   { background: var(--deck-danger); box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.18); }
.status-dot.is-unknown   { background: var(--deck-dim); }

.rail-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid var(--deck-line-strong);
  display: block;
}
.rail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* panel — resources ----------------------------------------------------------- */
.panel {
  width: 280px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--deck-panel);
  border-right: 1px solid var(--deck-line);
}

.panel-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--deck-line);
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 10px 16px;
}

.panel-foot {
  padding: 12px;
  border-top: 1px solid var(--deck-line);
}

.kicker {
  display: block;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--deck-dim);
  margin-bottom: 8px;
}

.select, .input, textarea.input {
  width: 100%;
  background: var(--deck-field);
  border: 1px solid var(--deck-line-strong);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--deck-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select:focus, .input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--deck-brand);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}
.select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.select option {
  background: var(--deck-panel);
  color: var(--deck-text);
}

.panel-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
  justify-content: flex-end;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--deck-muted);
  border: 1px solid transparent;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  color: var(--deck-text);
  background: var(--deck-raise);
  border-color: var(--deck-line);
}
.icon-btn svg {
  width: 15px;
  height: 15px;
}

.text-btn {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--deck-muted);
  padding: 4px 8px;
  border-radius: 7px;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.text-btn:hover {
  color: var(--deck-brand);
  background: var(--deck-raise);
}
.text-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.panel-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 8px;
}
.panel-section-head .kicker {
  margin-bottom: 0;
}

.mini-form {
  display: flex;
  gap: 6px;
  padding: 4px 6px 10px;
}
.mini-form .input {
  flex: 1;
  min-width: 0;
}

.mini-error {
  font-size: 11.5px;
  color: var(--deck-danger);
  padding: 2px 8px 8px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.panel-note {
  font-size: 12.5px;
  color: var(--deck-dim);
  padding: 8px;
  line-height: 1.55;
}

.collection-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.collection-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  border-left: 2px solid transparent;
  color: var(--deck-muted);
  text-align: left;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.collection-item:hover {
  color: var(--deck-text);
  background: var(--deck-raise);
}
.collection-item.is-active {
  color: var(--deck-text);
  border-left-color: var(--deck-brand);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.13), transparent 75%);
}

.collection-badge {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--deck-brand);
  width: 18px;
  text-align: center;
  flex: none;
}

.collection-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-count {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: var(--deck-dim);
  background: var(--deck-raise);
  border: 1px solid var(--deck-line);
  padding: 1px 8px;
  border-radius: 999px;
  flex: none;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--deck-line);
  border-radius: 11px;
  background: var(--deck-card);
}
.status-card .status-dot {
  flex: none;
}
.status-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.status-text strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--deck-text);
}
.status-text span {
  font-size: 10.5px;
  color: var(--deck-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* stage — workspace ------------------------------------------------------------ */
.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(900px 480px at 6% -12%, var(--deck-glow-a), transparent 58%),
    radial-gradient(760px 440px at 98% -8%, var(--deck-glow-b), transparent 58%);
}
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--deck-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--deck-grid) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 0%, transparent 72%);
}
.stage > * {
  position: relative;
  z-index: 1;
}

.stage-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--deck-line);
  background: color-mix(in srgb, var(--deck-panel) 72%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--deck-text);
  overflow: hidden;
  white-space: nowrap;
}
.crumb-db {
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb-sep {
  color: var(--deck-dim);
  font-weight: 400;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.crumb-col {
  color: var(--deck-brand);
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb-col.is-dim {
  color: var(--deck-dim);
  font-weight: 500;
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.kbd-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border: 1px solid var(--deck-line-strong);
  border-radius: 9px;
  background: var(--deck-card);
  color: var(--deck-muted);
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.kbd-btn:hover {
  border-color: var(--deck-brand);
  color: var(--deck-text);
}
.kbd-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}
.kbd-label {
  font-size: 12.5px;
  font-weight: 600;
}
.kbd-hint {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 9.5px;
  color: var(--deck-dim);
  letter-spacing: 0.02em;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--deck-line-strong);
  border-radius: 10px;
  overflow: hidden;
  background: var(--deck-raise);
}
.segmented button {
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--deck-muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.segmented button + button {
  border-left: 1px solid var(--deck-line);
}
.segmented button:hover {
  color: var(--deck-text);
}
.segmented button.is-active {
  color: var(--deck-text);
  background: var(--deck-card);
}

.stage-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 96px;
}

/* buttons ---------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--deck-line-strong);
  background: var(--deck-card);
  color: var(--deck-text);
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, background-color 0.15s ease;
}
.btn:hover {
  border-color: var(--deck-brand);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(135deg, var(--deck-brand), var(--deck-brand2));
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover {
  filter: brightness(1.12);
  box-shadow: 0 6px 22px -8px rgba(56, 189, 248, 0.6);
}
.btn-danger {
  color: var(--deck-danger);
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.08);
}
.btn-danger:hover {
  border-color: var(--deck-danger);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.14);
  background: rgba(251, 113, 133, 0.14);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
  border-radius: 7px;
}

/* cards ------------------------------------------------------------------------- */
.card {
  background: var(--deck-card);
  border: 1px solid var(--deck-line);
  border-radius: 13px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--deck-line);
}
.card-body {
  padding: 14px 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--deck-line);
  color: var(--deck-muted);
  background: var(--deck-raise);
}
.chip.is-ok {
  color: var(--deck-ok);
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.08);
}

/* empty states ------------------------------------------------------------------- */
.empty {
  flex: 1;
  min-height: 320px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: 6px;
  padding: 24px;
}
.empty .mascot {
  font-size: 54px;
  line-height: 1;
  display: block;
  margin-bottom: 14px;
  animation: vortex-spin 16s linear infinite;
  filter: drop-shadow(0 6px 26px rgba(56, 189, 248, 0.35));
}
.empty h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--deck-text);
  letter-spacing: -0.01em;
}
.empty p {
  font-size: 13px;
  color: var(--deck-muted);
  max-width: 380px;
  line-height: 1.6;
}
.empty .empty-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

@keyframes vortex-spin {
  to {
    transform: rotate(360deg);
  }
}

/* manage view -------------------------------------------------------------------- */
.manage-grid {
  display: grid;
  gap: 14px;
  max-width: 980px;
  margin: 0 auto;
}
.manage-grid .card-body {
  display: grid;
  gap: 12px;
}

.kv-list {
  display: grid;
  gap: 8px;
}
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 8px 12px;
  border: 1px solid var(--deck-line);
  border-radius: 9px;
  background: var(--deck-raise);
  font-size: 12.5px;
}
.kv-row dt {
  color: var(--deck-dim);
  font-size: 10.5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.kv-row dd {
  color: var(--deck-text);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}

.secret-box {
  border: 1px dashed rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.07);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--deck-warn);
}

/* workbench (query + results + side) ---------------------------------------------- */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.wb-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.querybar textarea {
  width: 100%;
  min-height: 64px;
  max-height: 280px;
  resize: none;
  overflow-y: auto;
  border: 1px solid var(--deck-line-strong);
  border-radius: 11px;
  background: var(--deck-code);
  color: var(--deck-text);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, height 0.14s ease;
}
.querybar textarea:focus {
  outline: none;
  border-color: var(--deck-brand);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.qcontrols {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.qcontrols .select {
  width: auto;
  padding: 5px 9px;
  font-size: 12px;
}
.qcontrols .input {
  width: 150px;
  padding: 5px 9px;
  font-size: 12px;
}
.qcontrols label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--deck-muted);
}
.qcontrols input[type="checkbox"] {
  accent-color: var(--deck-brand);
}

.qfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
}
.qfoot .hint {
  font-size: 11px;
  color: var(--deck-dim);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.qfoot .error {
  font-size: 12px;
  color: var(--deck-danger);
  font-weight: 600;
}

.rhead {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rstats {
  display: flex;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}
.rtools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-card {
  border: 1px solid var(--deck-line);
  border-radius: 11px;
  background: var(--deck-code);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.doc-card:hover {
  border-color: var(--deck-line-strong);
}
.doc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--deck-line);
  background: var(--deck-raise);
}
.doc-id {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--deck-brand);
}
.doc-pos {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--deck-dim);
}
.doc-actions {
  display: flex;
  gap: 6px;
}
.doc-body {
  padding: 12px 14px;
}
pre.json {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--deck-text);
}
.jkey { color: var(--j-key); }
.jstr { color: var(--j-str); }
.jnum { color: var(--j-num); }
.jbool { color: var(--j-bool); }
.jnull { color: var(--j-null); }

.editor {
  border: 1px solid var(--deck-line-strong);
  border-radius: 10px;
  background: var(--deck-code);
  padding: 12px;
}
.editor textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  background: transparent;
  border: 0;
  color: var(--deck-text);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}
.editor textarea:focus {
  outline: none;
}
.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--deck-line);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th {
  text-align: left;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--deck-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--deck-line-strong);
  position: sticky;
  top: 0;
  background: var(--deck-card);
  z-index: 1;
}
.data-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--deck-line);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--deck-muted);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.data-table tbody tr {
  transition: background-color 0.12s ease;
}
.data-table tbody tr:hover td {
  background: var(--deck-raise);
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
}
.pager .page-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--deck-dim);
}
.pager .page-input input {
  width: 74px;
  background: var(--deck-field);
  border: 1px solid var(--deck-line-strong);
  border-radius: 7px;
  padding: 5px 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--deck-text);
}
.pager .page-input input:focus {
  outline: none;
  border-color: var(--deck-brand);
}
.pager .page-info {
  font-size: 11px;
  color: var(--deck-dim);
  margin-left: auto;
}

/* side cards (accordion) ---------------------------------------------------------- */
.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.accordion {
  border: 1px solid var(--deck-line);
  border-radius: 13px;
  background: var(--deck-card);
  overflow: hidden;
}
.accordion-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--deck-muted);
  transition: color 0.15s ease;
}
.accordion-head:hover {
  color: var(--deck-text);
}
.accordion-head .chev {
  font-size: 13px;
  color: var(--deck-dim);
  transition: transform 0.2s ease;
}
.accordion.is-open .accordion-head .chev {
  transform: rotate(180deg);
}
.accordion-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--deck-line);
  display: grid;
  gap: 10px;
}

.help-box {
  border: 1px solid var(--deck-line);
  border-radius: 9px;
  background: var(--deck-raise);
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--deck-muted);
  line-height: 1.6;
}
.help-box code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--deck-brand);
}

.metric-list {
  border: 1px solid var(--deck-line);
  border-radius: 9px;
  overflow: hidden;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  font-size: 12px;
}
.metric-row + .metric-row {
  border-top: 1px solid var(--deck-line);
}
.metric-row dt {
  color: var(--deck-muted);
}
.metric-row dd {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--deck-text);
}

.index-row {
  border: 1px solid var(--deck-line);
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.index-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.index-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--deck-text);
  overflow-wrap: anywhere;
}
.index-meta {
  font-size: 11px;
  color: var(--deck-dim);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.badge {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--deck-line-strong);
  color: var(--deck-muted);
}
.badge.is-unique { color: var(--deck-ok); border-color: rgba(52, 211, 153, 0.35); }
.badge.is-sparse { color: var(--deck-brand); border-color: rgba(56, 189, 248, 0.35); }

.file-input {
  width: 100%;
  font-size: 12px;
  color: var(--deck-muted);
  background: var(--deck-field);
  border: 1px dashed var(--deck-line-strong);
  border-radius: 9px;
  padding: 10px 12px;
}

/* rail balls — vertical request log, only user actions --------------------- */
.rail-balls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  max-height: 44vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 4px;
  scrollbar-width: none;
}
.rail-balls::-webkit-scrollbar {
  display: none;
}
.ball {
  position: relative;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  border: 1.5px solid var(--deck-line-strong);
  background: var(--deck-card);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ball:hover {
  transform: translateY(-2px) scale(1.14);
}
.ball-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--deck-dim);
}
.ball.m-get { border-color: var(--deck-ok); background: rgba(52, 211, 153, 0.12); }
.ball.m-post { border-color: var(--deck-brand); background: rgba(56, 189, 248, 0.12); }
.ball.m-put, .ball.m-patch { border-color: var(--deck-warn); background: rgba(251, 191, 36, 0.12); }
.ball.m-delete { border-color: var(--deck-danger); background: rgba(251, 113, 133, 0.12); }
.ball.is-success .ball-dot { background: var(--deck-ok); }
.ball.is-error .ball-dot { background: var(--deck-danger); box-shadow: 0 0 7px rgba(251, 113, 133, 0.8); }
.ball.is-pending .ball-dot { background: var(--deck-warn); animation: ball-pulse 0.9s ease infinite; }

@keyframes ball-pulse {
  50% { opacity: 0.3; }
}

/* a new ball falls from the top of the rail and stacks onto the pile */
.ball.is-new {
  animation: ball-drop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes ball-drop {
  0% {
    opacity: 0;
    transform: translateY(-64px) scale(0.45);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
/* when the pile is full the oldest ball falls out of the rail */
.ball.is-leaving {
  animation: ball-fall 0.32s ease-in both;
}
@keyframes ball-fall {
  to {
    opacity: 0;
    transform: translateY(30px) scale(0.5);
  }
}

/* palette — command palette --------------------------------------------------------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: start center;
  padding-top: 11vh;
  background: rgba(3, 6, 12, 0.55);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.palette-box {
  width: min(560px, 92vw);
  background: var(--deck-panel);
  border: 1px solid var(--deck-line-strong);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(56, 189, 248, 0.18);
}
.palette-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--deck-line);
  background: transparent;
  padding: 15px 18px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  color: var(--deck-text);
}
.palette-input:focus {
  outline: none;
}
.palette-input::placeholder {
  color: var(--deck-dim);
}
.palette-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
.palette-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--deck-muted);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
}
.palette-item.is-active {
  color: var(--deck-text);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.14), transparent 65%);
}
.palette-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-item .meta {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: var(--deck-dim);
}
.palette-empty {
  padding: 22px;
  text-align: center;
  font-size: 13px;
  color: var(--deck-dim);
}
.palette-foot {
  display: flex;
  gap: 14px;
  padding: 9px 16px;
  border-top: 1px solid var(--deck-line);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: var(--deck-dim);
}

/* activity modal — code viewer ------------------------------------------------------- */
#activity-modal,
#doc-editor-modal,
#prompt-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 1px solid var(--deck-line-strong);
  border-radius: 16px;
  background: var(--deck-panel);
  color: var(--deck-text);
  padding: 0;
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(56, 189, 248, 0.2);
  overflow: hidden;
}
#activity-modal {
  width: min(780px, 94vw);
  max-height: 84vh;
}
#doc-editor-modal {
  width: min(660px, 94vw);
}
#prompt-modal {
  width: min(460px, 94vw);
}
#activity-modal::backdrop,
#doc-editor-modal::backdrop,
#prompt-modal::backdrop {
  background: rgba(3, 6, 12, 0.62);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--deck-line);
}
.modal-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--deck-text);
}
.modal-sub {
  margin-top: 3px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--deck-dim);
  overflow-wrap: anywhere;
}
.modal-sub .m {
  font-weight: 700;
}
.modal-sub .m-get { color: var(--deck-ok); }
.modal-sub .m-post { color: var(--deck-brand); }
.modal-sub .m-put, .modal-sub .m-patch { color: var(--deck-warn); }
.modal-sub .m-delete { color: var(--deck-danger); }
.mod-tabs {
  display: flex;
  gap: 3px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--deck-line);
  background: var(--deck-raise);
  flex-wrap: wrap;
}
.mod-tab {
  padding: 5px 13px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--deck-muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.mod-tab:hover {
  color: var(--deck-text);
}
.mod-tab.is-active {
  color: var(--deck-brand);
  background: var(--deck-panel);
  box-shadow: 0 0 0 1px var(--deck-line);
}
.mod-code {
  margin: 0;
  padding: 16px 20px;
  background: var(--deck-code);
  color: var(--deck-text);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 46vh;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  border-top: 1px solid var(--deck-line);
  font-size: 11.5px;
  color: var(--deck-dim);
}

/* notifications ---------------------------------------------------------------------- */
.note-ok { font-size: 12px; color: var(--deck-ok); font-weight: 600; }
.note-err { font-size: 12px; color: var(--deck-danger); font-weight: 600; }
.note-info { font-size: 12px; color: var(--deck-muted); }

/* responsive --------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .panel {
    width: 240px;
  }
  .dock {
    left: calc(64px + 240px + 14px);
  }
  .dock-foot {
    display: none;
  }
  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }
  .side {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .rail {
    display: none;
  }
  .dock {
    left: calc(240px + 14px);
  }
}

@media (max-width: 720px) {
  .panel {
    position: fixed;
    top: 65px;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(300px, 84vw);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--deck-shadow);
  }
  .panel.is-open {
    transform: translateX(0);
  }
  .dock {
    left: 14px;
  }
  .stage-head {
    padding: 10px 12px;
  }
  .stage-body {
    padding: 14px 12px 120px;
  }
  .kbd-btn .kbd-hint {
    display: none;
  }
  .side {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 721px) {
  .menu-btn {
    display: none;
  }
}

/* scrollbars -------------------------------------------------------------------------- */
.console ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.console ::-webkit-scrollbar-thumb {
  background: var(--deck-line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.console ::-webkit-scrollbar-thumb:hover {
  background-color: var(--deck-dim);
}
.console {
  scrollbar-width: thin;
  scrollbar-color: var(--deck-line-strong) transparent;
}

/* ==========================================================================
   Deck v3 components
   ========================================================================== */

/* monograms ------------------------------------------------------------------ */
.monogram {
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex: none;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.monogram-sm {
  width: 24px;
  height: 24px;
  font-size: 9px;
  border-radius: 7px;
}
.monogram-lg {
  width: 42px;
  height: 42px;
  font-size: 13px;
  border-radius: 11px;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.5);
}
.monogram-xl {
  width: 52px;
  height: 52px;
  font-size: 15px;
  border-radius: 13px;
  box-shadow: 0 8px 22px -8px rgba(0, 0, 0, 0.55);
}

.collection-item .monogram-sm {
  transition: transform 0.15s ease;
}
.collection-item:hover .monogram-sm {
  transform: scale(1.12) rotate(-6deg);
}

/* card titles & generic helpers ------------------------------------------------ */
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--deck-text);
  letter-spacing: -0.01em;
}
.card-sub {
  font-size: 12px;
  color: var(--deck-dim);
  margin-top: 2px;
}
.danger-title {
  color: var(--deck-danger);
}
.danger-card {
  border-color: rgba(251, 113, 133, 0.35);
}

.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.key-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}
.key-main strong {
  font-size: 12.5px;
  color: var(--deck-text);
}
.key-main span {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--deck-muted);
  overflow-wrap: anywhere;
}
.key-main small {
  font-size: 10.5px;
  color: var(--deck-dim);
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inline-form .input {
  flex: 1;
  min-width: 0;
}
.inline-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--deck-line);
  border-radius: 10px;
  background: var(--deck-raise);
}

.side-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.side-row .select {
  flex: 1;
  min-width: 0;
}
.side-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--deck-muted);
}
.check input[type="checkbox"] {
  accent-color: var(--deck-brand);
}

.table-wrap {
  overflow-x: auto;
}
.index-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-head-l {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.doc-head-l .kicker {
  margin: 0;
}
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* database manager ------------------------------------------------------------ */
.db-manager {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.db-manager-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.db-manager-head .kicker {
  margin-bottom: 4px;
}
.db-manager-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--deck-text);
}
.db-create {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px dashed var(--deck-line-strong);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.07), rgba(139, 92, 246, 0.06)), var(--deck-card);
  transition: border-color 0.15s ease;
}
.db-create:focus-within {
  border-color: var(--deck-brand);
}
.db-create-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.db-create-main .kicker {
  margin: 0;
}
.db-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 860px) {
  .db-grid {
    grid-template-columns: 1fr;
  }
  .db-create {
    flex-wrap: wrap;
  }
}
.db-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--deck-line);
  border-radius: 14px;
  background: var(--deck-card);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.db-card:hover {
  transform: translateY(-2px);
  border-color: var(--deck-brand);
  box-shadow: var(--deck-shadow);
}
.db-card.is-selected {
  border-color: var(--deck-brand);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}
.db-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.db-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.db-card-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--deck-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-card-id {
  font-size: 11px;
  color: var(--deck-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11px;
  color: var(--deck-dim);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.db-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--deck-line);
  padding-top: 12px;
}

/* database overview hero -------------------------------------------------------- */
.db-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.db-hero-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.db-hero-name {
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-id-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--deck-dim);
}
.db-id-row .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-id-row .icon-btn {
  width: 22px;
  height: 22px;
}
.db-id-row .icon-btn svg {
  width: 12px;
  height: 12px;
}
.db-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 640px) {
  .db-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
.stat-mini {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 13px;
  border: 1px solid var(--deck-line);
  border-radius: 10px;
  background: var(--deck-raise);
}
.stat-mini-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--deck-text);
  letter-spacing: -0.02em;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.stat-mini-value.stat-mini-date {
  font-size: 11.5px;
  font-weight: 700;
  padding-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-mini-label {
  font-size: 9.5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--deck-dim);
}

/* credentials reveal (new API key) ---------------------------------------------- */
.cred-box {
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 13px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.05), transparent 60%), var(--deck-card);
}
.cred-warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.25);
  font-size: 12px;
  color: var(--deck-warn);
  line-height: 1.5;
}
.cred-warn svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
}
.cred-warn strong {
  color: inherit;
}
.cred-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 14px;
}
@media (max-width: 720px) {
  .cred-fields {
    grid-template-columns: 1fr;
  }
}
.cred-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cred-field .kicker {
  margin: 0;
}
.cred-value {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px 7px 12px;
  border: 1px solid var(--deck-line);
  border-radius: 9px;
  background: var(--deck-field);
}
.cred-value .mono {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--deck-text);
}
.cred-value .icon-btn svg {
  width: 13px;
  height: 13px;
}
.cred-tabs {
  display: flex;
  gap: 3px;
  padding: 0 10px;
  border-bottom: 1px solid var(--deck-line);
  background: var(--deck-raise);
  flex-wrap: wrap;
}
.cred-tab {
  padding: 7px 13px;
  border-radius: 8px 8px 0 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--deck-muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.cred-tab:hover {
  color: var(--deck-text);
}
.cred-tab.is-active {
  color: var(--deck-brand);
  border-bottom-color: var(--deck-brand);
}
.cred-code {
  position: relative;
  padding: 12px 14px;
  background: var(--deck-code);
}
.cred-pre {
  margin: 0;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--deck-text);
  white-space: pre-wrap;
  word-break: break-all;
  padding-right: 70px;
}
.cred-copy {
  position: absolute;
  top: 10px;
  right: 12px;
}

/* side select row */
.side-row .select {
  min-width: 0;
}

/* ==========================================================================
   Deck v4 components: modal editor, prompts, cell editing, mobile sheet
   ========================================================================== */

/* document editor modal -------------------------------------------------------- */
.editor-body {
  display: flex;
  flex-direction: column;
}
.doc-editor-input {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  border: 0;
  border-bottom: 1px solid var(--deck-line);
  background: var(--deck-code);
  color: var(--deck-text);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  padding: 14px 18px;
}
.doc-editor-input:focus {
  outline: none;
}
.editor-messages {
  padding: 10px 18px 4px;
  min-height: 32px;
}

/* prompt modal ----------------------------------------------------------------- */
.prompt-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
}
.prompt-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

/* editable table cells ---------------------------------------------------------- */
.data-table td.cell-edit {
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.data-table td.cell-edit:hover {
  color: var(--deck-text);
  background: var(--deck-raise);
  text-decoration: underline dotted;
}

/* mobile: floating tools button + bottom sheet ----------------------------------- */
.fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--deck-brand), var(--deck-brand2));
  color: #fff;
  place-items: center;
  box-shadow: 0 10px 30px -8px rgba(56, 189, 248, 0.6);
  transition: transform 0.15s ease;
}
.fab svg {
  width: 20px;
  height: 20px;
}
.fab.is-active {
  transform: rotate(45deg);
}

.sheet-head {
  display: none;
}

@media (max-width: 860px) {
  .fab {
    display: grid;
  }
  .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--deck-line);
  }
  .sheet-head .kicker {
    margin: 0;
  }
  .side {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 0;
    top: auto;
    z-index: 75;
    max-height: 72vh;
    overflow-y: auto;
    transform: translateY(110%);
    transition: transform 0.28s cubic-bezier(0.3, 1.2, 0.5, 1);
    background: var(--deck-panel);
    border: 1px solid var(--deck-line-strong);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    padding: 12px;
    box-shadow: var(--deck-shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .side.is-open {
    transform: translateY(0);
  }
}

/* ==========================================================================
   Deck v5: filter bar, autocomplete, NL popover, inline cells, ball polish
   ========================================================================== */

/* filter bar ------------------------------------------------------------------ */
.filter-bar {
  position: relative;
}
.filter-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 12px;
  border: 1px solid var(--deck-line-strong);
  border-radius: 11px;
  background: var(--deck-code);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-input-wrap:focus-within {
  border-color: var(--deck-brand);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.13);
}
.filter-icon {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--deck-dim);
}
.filter-input-line {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  padding: 8px 0;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--deck-text);
  caret-color: var(--deck-brand);
}
.filter-input-line::placeholder {
  color: var(--deck-dim);
}
.filter-sparkle {
  flex: none;
  color: var(--deck-dim);
}
.filter-sparkle:hover,
.filter-sparkle.is-active {
  color: var(--deck-warn);
  background: rgba(251, 191, 36, 0.1);
}

/* autocomplete ---------------------------------------------------------------- */
.filter-suggest {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 40;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  padding: 5px;
  background: var(--deck-panel);
  border: 1px solid var(--deck-line-strong);
  border-radius: 11px;
  box-shadow: var(--deck-shadow);
}
.filter-suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 11px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--deck-muted);
  text-align: left;
  transition: background-color 0.1s ease;
}
.filter-suggest-item:hover,
.filter-suggest-item.is-active {
  color: var(--deck-text);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.14), transparent 75%);
}

/* natural language popover ----------------------------------------------------- */
.nl-pop {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 40;
  width: min(400px, 94%);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--deck-panel);
  border: 1px solid var(--deck-line-strong);
  border-radius: 13px;
  box-shadow: var(--deck-shadow);
  animation: rise 0.18s ease both;
}
.nl-pop-head .kicker {
  margin: 0;
}
.nl-input {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  background: var(--deck-field);
  border: 1px solid var(--deck-line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--deck-text);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.nl-input:focus {
  outline: none;
  border-color: var(--deck-brand);
}
.nl-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* inline cell editor ------------------------------------------------------------ */
.cell-input {
  width: 100%;
  min-width: 90px;
  background: var(--deck-field);
  border: 1px solid var(--deck-brand);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--deck-text);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}
.cell-input:focus {
  outline: none;
}

/* request-log balls: stronger method colors, custom fast tooltip, juicier drop -- */
.ball.m-get { border-color: var(--deck-ok); background: rgba(52, 211, 153, 0.22); box-shadow: 0 0 10px -2px rgba(52, 211, 153, 0.45); }
.ball.m-post { border-color: var(--deck-brand); background: rgba(56, 189, 248, 0.22); box-shadow: 0 0 10px -2px rgba(56, 189, 248, 0.45); }
.ball.m-put, .ball.m-patch { border-color: var(--deck-warn); background: rgba(251, 191, 36, 0.22); box-shadow: 0 0 10px -2px rgba(251, 191, 36, 0.45); }
.ball.m-delete { border-color: var(--deck-danger); background: rgba(251, 113, 133, 0.22); box-shadow: 0 0 10px -2px rgba(251, 113, 133, 0.5); }

.ball {
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.ball:hover {
  transform: translateX(4px) scale(1.22);
  z-index: 95;
}
/* instant custom tooltip: operation name + path */
.ball:hover::after {
  content: attr(data-tip) "\A" attr(data-path);
  position: absolute;
  left: calc(100% + 9px);
  top: 50%;
  transform: translateY(-50%);
  max-width: 300px;
  padding: 6px 10px;
  border: 1px solid var(--deck-line-strong);
  border-radius: 8px;
  background: var(--deck-panel);
  color: var(--deck-text);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.55;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: var(--deck-shadow);
  animation: tooltip-in 0.1s ease both;
}
@keyframes tooltip-in {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(-6px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0) scale(1);
  }
}

/* juicier drop with squash & stretch + landing pulse */
.ball.is-new {
  animation: ball-drop 0.6s cubic-bezier(0.3, 1.35, 0.5, 1) both;
}
@keyframes ball-drop {
  0% {
    opacity: 0;
    transform: translateY(-84px) scale(0.45, 0.45) rotate(-160deg);
  }
  45% {
    opacity: 1;
  }
  60% {
    transform: translateY(4px) scale(1.18, 0.78) rotate(0deg);
  }
  78% {
    transform: translateY(-5px) scale(0.92, 1.1);
  }
  100% {
    transform: translateY(0) scale(1, 1);
  }
}
.ball.is-new .ball-dot {
  animation: ball-dot-pop 0.4s 0.55s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
@keyframes ball-dot-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(2.7);
    opacity: 0.45;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
/* pending requests get a soft breathing ring */
.ball.is-pending {
  animation: ball-breathe 1.4s ease infinite;
}
@keyframes ball-breathe {
  0%, 100% {
    box-shadow: 0 0 6px -2px rgba(251, 191, 36, 0.35);
  }
  50% {
    box-shadow: 0 0 14px 0 rgba(251, 191, 36, 0.6);
  }
}
.rail-balls {
  overflow: visible;
  max-height: none;
}

/* ==========================================================================
   Deck v7: multiline cell editor, save feedback, richer motion
   ========================================================================== */

/* single-line looking, multiline capable cell editor */
.cell-input {
  width: 100%;
  min-width: 90px;
  min-height: 26px;
  max-height: 150px;
  resize: none;
  overflow-y: auto;
  background: var(--deck-field);
  border: 1px solid var(--deck-brand);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--deck-text);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
  transition: box-shadow 0.15s ease;
}
.cell-input:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.2);
}

/* saved cell flashes green */
.cell-flash {
  animation: cell-flash 1s ease both;
}
@keyframes cell-flash {
  0% {
    background: rgba(52, 211, 153, 0.38);
  }
  100% {
    background: transparent;
  }
}

/* shake on invalid input */
.cell-input.is-error {
  animation: cell-shake 0.32s ease;
  border-color: var(--deck-danger);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.16);
}
@keyframes cell-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* doc cards stagger in on every query */
.doc-card {
  animation: rise 0.3s ease both;
}
.doc-card:hover {
  transform: translateY(-1px);
  border-color: var(--deck-line-strong);
}
.doc-card {
  transition: border-color 0.15s ease, transform 0.15s ease;
}

/* buttons press feedback */
.btn:active:not(:disabled),
.icon-btn:active,
.text-btn:active,
.kbd-btn:active,
.rail-btn:active,
.collection-item:active,
.accordion-head:active,
.dock-chip:active {
  transform: scale(0.96);
}

/* note messages fade in */
.note-ok, .note-err, .note-info {
  animation: note-in 0.22s ease both;
}
@keyframes note-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* dialogs pop open */
#activity-modal[open],
#doc-editor-modal[open],
#prompt-modal[open] {
  animation: modal-in 0.22s cubic-bezier(0.3, 1.3, 0.5, 1) both;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* suggestions pop in */
.filter-suggest {
  animation: rise 0.16s ease both;
}

/* collection count pulses when it changes */
.collection-count {
  transition: transform 0.2s ease;
}
.collection-item:hover .collection-count {
  transform: scale(1.1);
}
