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

html, body {
  height: 100%;
}

body {
  background: #0d1117;
  color: #e6edf3;
  font-family: 'Menlo', 'Monaco', 'Lucida Console', 'Courier New', monospace;
  font-size: 13.5px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── banner ── */
.banner {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  color: #8b949e;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 5px 16px;
  text-align: center;
  text-transform: lowercase;
  flex-shrink: 0;
}

.connbar {
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  color: #6e7681;
  font-size: 11px;
  padding: 5px 16px;
  text-align: center;
  flex-shrink: 0;
  white-space: pre-wrap;
}

.connbar .live {
  color: #56d364;
}

.connbar .dim {
  color: #6e7681;
}

/* ── layout ── */
.wrap {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 14px 16px 10px;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  min-height: 0;
}

/* ── sidebar ── */
.sidebar {
  width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  color: #6e7681;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 2px 6px;
}

.sidebar-head-chips {
  margin-top: 14px;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.tbl-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #e6edf3;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  padding: 4px 7px;
  text-align: left;
  width: 100%;
  animation: fade-in 0.5s ease;
}

.tbl-row:hover, .tbl-row:focus-visible {
  background: #161b22;
  border-color: #30363d;
  outline: none;
}

.tbl-name {
  color: #58a6ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tbl-name.ghost {
  color: #a371f7;
}

.tbl-count {
  color: #6e7681;
  flex-shrink: 0;
  font-size: 11px;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.chip {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 4px;
  color: #8b949e;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  padding: 5px 7px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip:hover, .chip:focus-visible {
  background: #161b22;
  color: #e6edf3;
  border-color: #30363d;
  outline: none;
}

/* ── terminal ── */
.terminal {
  background: #010409;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 14px 16px 12px;
  cursor: text;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 150px);
  min-width: 0;
}

.terminal::before {
  content: '● ● ●';
  display: block;
  font-size: 9px;
  letter-spacing: 4px;
  color: #30363d;
  margin-bottom: 12px;
  margin-top: -2px;
  flex-shrink: 0;
}

/* ── output area ── */
.output {
  flex: 1;
  overflow-y: auto;
}

.block {
  margin-bottom: 10px;
}

.line {
  display: block;
  white-space: pre;
  overflow-x: auto;
  min-height: 1.55em;
}

.line.wrap-line {
  white-space: pre-wrap;
  word-break: break-word;
}

/* prompt lines */
.prompt-line { display: flex; align-items: baseline; gap: 0; }
.prompt-line .ps1   { color: #58a6ff; flex-shrink: 0; white-space: pre; }
.prompt-line .typed { color: #e6edf3; white-space: pre-wrap; word-break: break-word; }

/* result table */
.result { color: #e6edf3; }
.result .hdr { color: #d2a8ff; }
.result .sep { color: #30363d; }
.result .foot { color: #6e7681; }

.err   { color: #f85149; }
.err-line { color: #6e7681; }
.err-caret { color: #f85149; }
.hint  { color: #d29922; }
.notice { color: #6e7681; }
.warn  { color: #d29922; }
.ok    { color: #56d364; }
.dim   { color: #6e7681; }
.timing { color: #6e7681; font-size: 12px; }

/* ── input row ── */
.input-row {
  display: flex;
  align-items: baseline;
  margin-top: 2px;
  gap: 0;
  flex-shrink: 0;
}

.ps1-live {
  color: #58a6ff;
  white-space: nowrap;
  flex-shrink: 0;
}

#cmd {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e6edf3;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  caret-color: #58a6ff;
  padding: 0;
  min-width: 0;
}

#cmd:focus-visible {
  outline: none;
}

/* ── footer ── */
.footer {
  text-align: center;
  padding: 10px 0 14px;
  font-size: 12px;
  color: #6e7681;
  flex-shrink: 0;
}

.footer a {
  color: #6e7681;
  text-decoration: none;
}

.footer a:hover {
  color: #e6edf3;
}

/* ── scrollbars ── */
.output::-webkit-scrollbar,
.sidebar-list::-webkit-scrollbar,
.chips::-webkit-scrollbar,
.line::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.output::-webkit-scrollbar-thumb,
.sidebar-list::-webkit-scrollbar-thumb,
.chips::-webkit-scrollbar-thumb,
.line::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}

/* ── mobile ── */
@media (max-width: 760px) {
  .wrap {
    flex-direction: column;
    padding: 10px 8px 8px;
  }
  body {
    font-size: 12.5px;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 16px;
  }
  .sidebar-head-chips {
    margin-top: 0;
  }
  .sidebar-list, .chips {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
  }
  .tbl-row {
    width: auto;
  }
  .chip {
    white-space: normal;
  }
  .terminal {
    padding: 10px 10px 8px;
    min-height: 50vh;
  }
  .connbar {
    font-size: 10px;
  }
}
