:root {
  color-scheme: dark;
  --bg: #151719;
  --panel: #1d2023;
  --panel2: #22262a;
  --border: #363b40;
  --text: #d7dbdf;
  --muted: #8d969e;
  --accent: #4f8cff;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input {
  font: inherit;
}
button {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
}
button:hover { border-color: #58616b; }
.tool-button {
  width: 26px;
  min-width: 26px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  border-radius: 4px;
  line-height: 1;
}
.tool-button:hover {
  background: var(--panel2);
  color: var(--text);
}
#app { min-width: 0; position: relative; }
#sidebar-backdrop {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: none;
  background: transparent;
}
#sidebar.open + #workspace,
#sidebar.open ~ #workspace {
  pointer-events: auto;
}
#sidebar {
  position: fixed;
  z-index: 9;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  border-right: 1px solid var(--border);
  box-shadow: 14px 0 28px rgba(0, 0, 0, .28);
  background: var(--panel);
  padding: 10px;
  overflow: auto;
  transform: translateX(-100%);
  transition: transform .16s ease;
}
#sidebar.open { transform: translateX(0); }
#sidebar-backdrop.open { display: block; }
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.brand-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}
.brand {
  font-size: 16px;
  font-weight: 650;
}
.machine {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
#new-session {
  width: 100%;
  margin-bottom: 10px;
}
#session-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.session-group {
  margin: 12px 2px 4px;
  width: calc(100% - 4px);
  height: 24px;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  padding: 0 4px;
}
.session-group:hover {
  background: var(--panel2);
}
.group-arrow {
  color: var(--muted);
}
.group-count {
  color: var(--muted);
}
.session-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 6px;
  overflow: hidden;
}
.session-item:hover { background: var(--panel2); }
.session-item.running .session-name::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 999px;
  background: #54d17a;
}
.session-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-meta {
  color: var(--muted);
  font-size: 11px;
}
#workspace {
  width: 100%;
  height: 100%;
  min-width: 0;
  position: relative;
}
#toolbar {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
#pane-count { color: var(--muted); font-size: 12px; }
#panes {
  position: absolute;
  inset: 34px 0 0 0;
  overflow: hidden;
}
.pane {
  position: absolute;
  border: 1px solid var(--border);
  background: #111315;
}
.pane.active {
  border-color: #58616b;
}
.pane header {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.pane header input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  outline: none;
}
.pane header input:focus { color: var(--text); }
.pane header button {
  border: 0;
  background: transparent;
  min-width: 22px;
  padding: 0 5px;
}
.term-host {
  position: absolute;
  inset: 28px 0 0 0;
  padding: 6px;
  overflow: hidden;
}
.term-host .xterm {
  width: 100%;
  height: 100%;
}
.term-host .xterm-viewport {
  overflow-y: auto;
  scrollbar-width: none;
}
.term-host .xterm-viewport::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.term-scrollbar {
  position: absolute;
  z-index: 5;
  top: 6px;
  right: 2px;
  bottom: 6px;
  width: 12px;
  opacity: 0;
  transition: opacity .12s ease;
  pointer-events: auto;
  touch-action: none;
}
.term-scrollbar.visible,
.term-scrollbar:hover,
.term-scrollbar:active {
  opacity: 1;
}
.term-scrollbar.hidden {
  display: none;
}
.term-scrollbar-thumb {
  width: 8px;
  margin-left: 2px;
  border-radius: 999px;
  background: rgba(122, 132, 143, .72);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
  touch-action: none;
}
.term-scrollbar-thumb:hover,
.term-scrollbar-thumb:active {
  background: rgba(157, 166, 176, .9);
}
.login-body {
  display: grid;
  place-items: center;
  min-height: 100%;
}
.login-card {
  width: min(360px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.login-card .brand { margin-bottom: 14px; }
.login-card form { display: grid; gap: 10px; }
.login-card input {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #111315;
  color: var(--text);
  padding: 0 10px;
}
#error { min-height: 18px; color: #ff7b7b; }

@media (max-width: 760px) {
  #sidebar { width: min(300px, 86vw); }
}
