* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #0b1016;
  --panel-2: #10161d;
  --panel-3: #161b22;
  --border: #30363d;
  --border-soft: #242c35;
  --text: #e6edf3;
  --muted: #8b949e;
  --green: #3fb950;
  --green-bright: #56d364;
  --blue: #58a6ff;
  --yellow: #e3b341;
  --red: #f85149;
  --purple: #bc8cff;
  --cyan: #39c5cf;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% -10%, rgba(63, 185, 80, 0.06), transparent 35%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

button, input { font: inherit; }

.db-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 24px;
}

.db-window {
  min-height: 78vh;
  overflow: hidden;
  background: rgba(11, 16, 22, 0.98);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.015) inset;
}

.db-titlebar {
  height: 48px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel-3);
  border-bottom: 1px solid #252d36;
}

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

.window-dot {
  width: 12px;
  height: 12px;
  display: inline-block;
  border: 0;
  border-radius: 50%;
}

a.window-dot {
  cursor: pointer;
  text-decoration: none;
}

.window-dot.red { background: #ff5f57; }
.window-dot.yellow { background: #febc2e; }
.window-dot.green { background: #28c840; }

a.window-dot.red:hover,
a.window-dot.red:focus-visible {
  outline: 2px solid rgba(255, 95, 87, 0.35);
  outline-offset: 3px;
  transform: scale(1.08);
}

.db-title {
  color: #9aa4af;
  font-size: 0.78rem;
  text-align: center;
}

.db-connection {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.45);
}

.db-layout {
  min-height: calc(78vh - 48px);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.db-sidebar {
  padding: 18px 12px;
  background: #0d131a;
  border-right: 1px solid var(--border-soft);
}

.sidebar-block + .sidebar-block { margin-top: 24px; }

.sidebar-label {
  margin: 0 8px 8px;
  color: #6e7681;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.sidebar-db,
.collection-list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  background: transparent;
  color: #aeb8c2;
  border: 0;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-db:hover,
.collection-list button:hover {
  background: #151d26;
  color: #f0f6fc;
}

.sidebar-db.active {
  background: rgba(63, 185, 80, 0.08);
  color: var(--green-bright);
}

.db-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

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

.collection-list button::before {
  content: "◈";
  color: #56616d;
  font-size: 0.68rem;
}

.collection-list button:hover::before { color: var(--green); }

.sidebar-note {
  margin-top: 28px;
  padding: 11px;
  color: #6e7681;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid #202731;
  border-radius: 8px;
  font-size: 0.63rem;
  line-height: 1.5;
}

.sidebar-note strong { color: #9aa4af; }

.db-console {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(rgba(11, 16, 22, 0.92), rgba(11, 16, 22, 0.92)),
    repeating-linear-gradient(0deg, transparent 0 25px, rgba(255, 255, 255, 0.012) 25px 26px);
}

.db-output {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - 185px);
  overflow-y: auto;
  padding: 22px 24px 10px;
  scrollbar-width: thin;
  scrollbar-color: #30363d transparent;
}

.output-line {
  margin: 0 0 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #c9d1d9;
  font-size: clamp(0.76rem, 1.1vw, 0.9rem);
  line-height: 1.52;
}

.output-line.command { margin-top: 10px; color: #f0f6fc; }
.output-line.muted { color: var(--muted); }
.output-line.green { color: var(--green-bright); }
.output-line.blue { color: var(--blue); }
.output-line.yellow { color: var(--yellow); }
.output-line.red { color: var(--red); }
.output-line.purple { color: var(--purple); }
.output-line.cyan { color: var(--cyan); }
.output-line.bold { color: #f0f6fc; font-weight: 700; }

.json-block {
  margin: 7px 0 11px;
  padding-left: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: clamp(0.74rem, 1vw, 0.87rem);
  line-height: 1.48;
}

.json-key { color: var(--cyan); }
.json-string { color: #a5d6ff; }
.json-number { color: #d2a8ff; }
.json-boolean { color: var(--yellow); }
.json-null { color: var(--red); }

.db-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 24px 14px;
}

.db-prompt {
  flex: 0 0 auto;
  color: var(--green);
  font-size: clamp(0.76rem, 1.1vw, 0.9rem);
}

.db-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: #f0f6fc;
  border: 0;
  outline: 0;
  caret-color: var(--green);
  font-size: clamp(0.76rem, 1.1vw, 0.9rem);
}

.db-hint {
  margin-top: 12px;
  color: #6e7681;
  font-size: 0.72rem;
  text-align: center;
}

.db-hint code { color: #9aa4af; }

@media (max-width: 760px) {
  .db-shell {
    width: min(100% - 18px, 1280px);
    padding-top: 12px;
  }

  .db-titlebar { padding: 0 10px; }

  .db-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .db-layout { grid-template-columns: 1fr; }
  .db-sidebar { display: none; }

  .db-output {
    max-height: calc(100vh - 150px);
    padding: 16px 14px 8px;
  }

  .db-input-row { padding: 8px 14px 12px; }
}


/* RunsLinux shared Labs workstation shell */
@media (min-width: 901px) {
  html, body { width: 100%; height: 100%; overflow: hidden; }
  body.rl-has-site-nav { background: #080d13; }
  .db-shell {
    position: relative !important;
    width: 100vw !important;
    max-width: none !important;
    height: calc(100vh - 54px) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: url('/assets/terminal-workstation.webp') center top / cover no-repeat !important;
  }
  .db-shell > .db-window {
    position: absolute !important;
    left: 19.65% !important;
    top: 5.75% !important;
    width: 62.75% !important;
    height: 60.45% !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    overflow: auto !important;
    border-radius: 10px !important;
    z-index: 3 !important;
    box-shadow: none !important;
  }
  .db-shell > :not(.db-window) { display: none !important; }
}

/* Workstation fit pass v1.1: keep the complete Data Explorer inside the monitor. */
@media (min-width: 901px) {
  .db-shell > .db-window { overflow: hidden !important; display: flex !important; flex-direction: column !important; }
  .db-titlebar { flex: 0 0 42px !important; height: 42px !important; }
  .db-layout { flex: 1 1 auto !important; min-height: 0 !important; height: auto !important; overflow: hidden !important; }
  .db-sidebar { min-height: 0 !important; overflow-y: auto !important; padding: 12px 10px !important; }
  .db-console { min-height: 0 !important; height: 100% !important; overflow: hidden !important; }
  .db-output { flex: 1 1 auto !important; min-height: 0 !important; max-height: none !important; overflow-y: auto !important; padding: 14px 18px 8px !important; }
  .db-input-row { flex: 0 0 44px !important; min-height: 44px !important; }
  .output-line { font-size: clamp(.66rem, .72vw, .82rem) !important; line-height: 1.38 !important; }
}
