:root {
  --app-height: 100vh;
  --visual-top: 0px;
  --visual-left: 0px;
  --visual-width: 100vw;
  --visual-height: 100vh;
  --keyboard-inset: 0px;
  --mobile-composer-height: 46px;
  --mobile-keys-height: 42px;
  --mobile-controls-height: calc(var(--mobile-composer-height) + var(--mobile-keys-height));
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #111318;
  color: #eef1f6;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #111318;
}

button,
input {
  font: inherit;
}

button {
  height: 36px;
  border: 1px solid #303641;
  border-radius: 7px;
  padding: 0 12px;
  background: #1a1e26;
  color: #f3f5f8;
  cursor: pointer;
}

button:hover {
  background: #232936;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  border-color: #5b82ff;
  background: #315dff;
}

.primary-button:hover {
  background: #456dff;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 20px;
  border: 1px solid #282e38;
  border-radius: 8px;
  padding: 28px;
  background: #171b22;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.28);
}

.eyebrow {
  margin: 0 0 8px;
  color: #8da2c6;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: 0;
}

.login-copy {
  margin: 10px 0 0;
  color: #aeb8c8;
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 8px;
  color: #dce3ee;
  font-size: 14px;
}

.field input {
  height: 42px;
  width: 100%;
  border: 1px solid #353d4a;
  border-radius: 7px;
  padding: 0 12px;
  background: #101319;
  color: #fff;
  outline: none;
}

.field input:focus {
  border-color: #6287ff;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #ff8f8f;
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  width: 100vw;
  height: var(--app-height);
  background: #111318;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #272d37;
  padding: 0 16px;
  background: #151922;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 680;
}

.brand span:last-child {
  display: block;
  max-width: min(58vw, 680px);
  overflow: hidden;
  color: #96a0af;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #5b6472;
}

.status-dot.connected {
  background: #31d67b;
}

.status-dot.disconnected {
  background: #ff6b6b;
}

.actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.mobile-only {
  display: none;
}

.terminal-layout {
  display: grid;
  min-height: 0;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  border-right: 1px solid #272d37;
  background: #151922;
}

.sidebar-title {
  height: 44px;
  border-bottom: 1px solid #272d37;
  padding: 14px 14px 0;
  color: #8791a1;
  font-size: 12px;
  font-weight: 700;
}

.terminal-list {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.terminal-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  height: auto;
  min-height: 42px;
  border-color: transparent;
  padding: 8px 10px;
  text-align: left;
}

.terminal-item.active {
  border-color: #3e66ff;
  background: #202842;
}

.terminal-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-mode {
  color: #96a0af;
  font-size: 11px;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 44px minmax(0, 1fr) 42px;
}

.tabbar {
  display: flex;
  min-width: 0;
  align-items: center;
  border-bottom: 1px solid #272d37;
  background: #11151c;
}

.tabs {
  display: flex;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  min-width: 150px;
  max-width: 240px;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  border-right: 1px solid #272d37;
  border-radius: 0;
  background: transparent;
  color: #aeb8c8;
}

.tab.active {
  background: #191f2b;
  color: #fff;
}

.icon-button {
  flex: 0 0 auto;
  margin: 0 8px;
}

.terminal-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #07090d;
}

.terminal-pane {
  position: absolute;
  inset: 0;
  display: none;
  padding: 10px;
}

.terminal-pane.active {
  display: block;
}

.terminal-pane .xterm {
  height: 100%;
}

.mobile-keys {
  display: flex;
  min-width: 0;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  border-top: 1px solid #272d37;
  padding: 5px 8px;
  background: #151922;
}

.mobile-composer {
  display: none;
  min-width: 0;
  gap: 6px;
  align-items: center;
  border-top: 1px solid #272d37;
  padding: 6px 8px;
  background: #11151c;
}

.mobile-composer input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid #353d4a;
  border-radius: 7px;
  padding: 0 10px;
  background: #080b10;
  color: #fff;
  outline: none;
}

.mobile-composer input:focus {
  border-color: #6287ff;
}

.mobile-composer button {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 10px;
}

.mobile-keys button {
  min-width: 64px;
  height: 30px;
  padding: 0 9px;
  color: #d5ddea;
  font-size: 13px;
}

@media (max-width: 760px) {
  .app-shell {
    position: fixed;
    top: var(--visual-top);
    left: var(--visual-left);
    width: var(--visual-width);
    height: var(--visual-height);
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 8px;
    min-height: 46px;
    padding: 6px 8px;
  }

  .brand {
    flex: 1 1 auto;
  }

  .brand strong {
    font-size: 13px;
  }

  .brand span:last-child {
    display: none;
  }

  .actions {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: repeat(4, minmax(0, auto));
    gap: 4px;
  }

  .actions button {
    height: 30px;
    padding: 0 7px;
    font-size: 12px;
  }

  .mobile-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.compact-topbar .topbar,
  body.keyboard-open .topbar {
    min-height: 36px;
    padding: 4px 6px;
  }

  body.compact-topbar .brand,
  body.keyboard-open .brand {
    display: none;
  }

  body.compact-topbar .actions,
  body.keyboard-open .actions {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.compact-topbar .actions button,
  body.keyboard-open .actions button {
    height: 28px;
    padding: 0 5px;
    font-size: 11px;
  }

  .terminal-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    grid-template-rows: 36px minmax(0, 1fr) var(--mobile-composer-height) var(--mobile-keys-height);
    min-height: 0;
  }

  .tabbar {
    min-height: 36px;
  }

  .mobile-composer {
    display: flex;
    min-height: var(--mobile-composer-height);
    padding: 5px 6px;
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.24);
  }

  .mobile-composer input {
    height: 32px;
  }

  .mobile-composer button {
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }

  .mobile-keys {
    gap: 4px;
    min-height: var(--mobile-keys-height);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.18);
  }

  .tab {
    min-width: 128px;
  }

  .terminal-pane {
    padding: 4px;
  }
}
