:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #0b1017;
  --panel-2: #111824;
  --panel-3: #081019;
  --border: #1f2b3a;
  --border-soft: rgba(31, 43, 58, 0.55);
  --text: #d6deeb;
  --muted: #7b8fa8;
  --accent: #7ee787;
  --warn: #ff7b72;
  --nodes-width: 220px;
  --sessions-width: 300px;
  --resizer-width: 10px;
  --resizer-hit: 16px;
  --resizer-line: rgba(31, 43, 58, 0.85);
  --resizer-line-active: rgba(126, 231, 135, 0.9);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Consolas, "Cascadia Mono", monospace;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.login-screen {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at top, #101722 0%, #05070a 72%);
}

.login-card {
  width: min(360px, 100%);
  padding: 20px;
  border: 1px solid var(--border);
  background: rgba(11, 16, 23, 0.96);
  display: grid;
  gap: 12px;
}

.login-brand {
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.login-card input,
.login-card button,
.actions button,
.mobile-tab,
.terminal-actions button {
  border: 1px solid var(--border);
  background: #091019;
  color: var(--text);
  padding: 10px 12px;
}

.login-card button,
.actions button,
.mobile-tab,
.terminal-actions button {
  cursor: pointer;
}

.login-status,
.statusbar,
.meta,
.item-meta {
  color: var(--muted);
  font-size: 12px;
}

.shell {
  height: 100%;
  display: grid;
  grid-template-columns:
    minmax(0, var(--nodes-width))
    var(--resizer-width)
    minmax(0, var(--sessions-width))
    var(--resizer-width)
    minmax(0, 1fr);
  background: var(--bg);
}

.mobile-tabs {
  display: none;
}

.nodes,
.sessions {
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}

.pane-resizer {
  position: relative;
  cursor: col-resize;
  background: transparent;
  user-select: none;
  touch-action: none;
}

.pane-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--resizer-line);
}

.pane-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: var(--resizer-hit);
  transform: translateX(-50%);
}

.shell.is-resizing,
.shell.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.shell.is-resizing .pane-resizer::before,
.pane-resizer.is-active::before {
  background: var(--resizer-line-active);
  box-shadow: 0 0 12px rgba(126, 231, 135, 0.18);
}

.pane-title,
.actions,
.terminal-header,
.statusbar {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.pane-title {
  text-transform: lowercase;
  letter-spacing: 0.05em;
}

.actions {
  display: flex;
  gap: 8px;
  background: var(--panel);
}

.actions button {
  flex: 1;
}

.list {
  height: calc(100% - 44px);
  overflow: auto;
}

.sessions .list {
  height: calc(100% - 49px);
}

.item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.item.active {
  background: rgba(126, 231, 135, 0.12);
  outline: 1px solid rgba(126, 231, 135, 0.6);
  outline-offset: -1px;
}

.item.attention-warn {
  border-left: 2px solid rgba(255, 123, 114, 0.9);
  animation: attention-pulse-warn 1s steps(2, end) infinite;
}

.item.attention-warn .item-meta,
.item.attention-warn .item-title {
  color: #ffd4cf;
}

.item.attention-success {
  border-left: 3px solid #7fffd4;
  animation: attention-pulse-success 0.72s ease-in-out infinite;
}

.item.attention-success .item-meta,
.item.attention-success .item-title {
  color: #cffff5;
  text-shadow: 0 0 8px rgba(127, 255, 212, 0.55);
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  align-items: baseline;
}

.item-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-title-primary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title-secondary {
  flex-shrink: 0;
  white-space: nowrap;
}

[data-pane="nodes"].compact .item-meta:last-child,
[data-pane="sessions"].compact .item-meta:last-child {
  display: none;
}

[data-pane="nodes"].tight .item-meta:first-of-type,
[data-pane="sessions"].tight .item-meta:nth-of-type(1),
[data-pane="sessions"].tight .item-meta:nth-of-type(2) {
  display: none;
}

.item-status {
  color: var(--accent);
  flex-shrink: 0;
  white-space: nowrap;
}

.item-status.offline {
  color: var(--warn);
}

.empty-state {
  padding: 14px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
}

.terminal-pane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #070b10;
}

.terminal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  background: var(--panel-3);
}

.terminal-header.attention-success {
  animation: attention-pulse-success 0.72s ease-in-out infinite;
  box-shadow: inset 0 0 0 1px rgba(127, 255, 212, 0.92);
}

.terminal-header.attention-success .title,
.terminal-header.attention-success .meta {
  color: #cffff5;
  text-shadow: 0 0 8px rgba(127, 255, 212, 0.55);
}

.terminal-header.attention-warn {
  animation: attention-pulse-warn 1s steps(2, end) infinite;
}

.title {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.terminal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.terminal-actions button {
  min-width: 0;
}

.terminal-actions .danger {
  border-color: rgba(255, 123, 114, 0.45);
  color: var(--warn);
}

.terminal-host {
  min-height: 0;
  padding: 6px;
}

.terminal-stage,
.xterm {
  width: 100%;
  height: 100%;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-3);
}

.statusbar-version {
  flex-shrink: 0;
  color: var(--muted);
}

@keyframes attention-pulse-warn {
  0%,
  45% {
    background: rgba(255, 123, 114, 0.04);
    box-shadow: inset 0 0 0 0 rgba(255, 123, 114, 0);
  }

  50%,
  100% {
    background: rgba(255, 123, 114, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 123, 114, 0.65);
  }
}

@keyframes attention-pulse-success {
  0%,
  38% {
    background: rgba(127, 255, 212, 0.06);
    box-shadow:
      inset 0 0 0 0 rgba(127, 255, 212, 0),
      0 0 0 0 rgba(127, 255, 212, 0);
  }

  42%,
  100% {
    background: rgba(127, 255, 212, 0.24);
    box-shadow:
      inset 0 0 0 1px rgba(127, 255, 212, 0.95),
      0 0 20px rgba(127, 255, 212, 0.45);
  }
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .pane-resizer {
    display: none;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--border);
    background: var(--panel);
  }

  .mobile-tab {
    border-width: 0 1px 0 0;
    padding: 12px 10px;
    text-transform: lowercase;
  }

  .mobile-tab:last-child {
    border-right: 0;
  }

.mobile-tab.active {
  color: var(--accent);
  background: rgba(126, 231, 135, 0.08);
}

.mobile-tab.attention-warn {
  animation: attention-pulse-warn 1s steps(2, end) infinite;
  color: #ffd4cf;
}

.mobile-tab.attention-success {
  animation: attention-pulse-success 0.72s ease-in-out infinite;
  color: #cffff5;
  text-shadow: 0 0 8px rgba(127, 255, 212, 0.55);
}

  .nodes,
  .sessions,
  .terminal-pane {
    display: none;
    height: calc(100vh - 49px);
    border-right: 0;
  }

  .nodes.active-pane,
  .sessions.active-pane,
  .terminal-pane.active-pane {
    display: grid;
  }

  .nodes.active-pane,
  .sessions.active-pane {
    grid-template-rows: auto 1fr;
  }

  .terminal-pane.active-pane {
    grid-template-rows: auto 1fr auto;
  }

  .terminal-header {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .actions {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 16px;
  }

  .pane-title,
  .actions,
  .terminal-header,
  .statusbar {
    padding: 10px;
  }

  .terminal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .terminal-host {
    padding: 4px;
  }

  .xterm {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}
