:root {
  --bg: #0b0e14;
  --bg-elevated: #11151f;
  --border: #1e2533;
  --text: #e6e9ef;
  --muted: #8b95a7;
  --accent: #6ea8fe;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.muted {
  color: var(--muted);
}

code {
  background: var(--bg-elevated);
  padding: 0 0.25em;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}

.mark {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

select,
input {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
}

select {
  min-width: 11rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.btn {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #1a2130;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
}

.btn:hover {
  background: #232c3d;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-danger:hover {
  background: #3a1d22;
  border-color: #5a2a30;
  color: #ffb4b4;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #07101f;
  font-weight: 600;
}

.btn-primary:hover {
  background: #86b7ff;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  min-width: 8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.status-dot.connecting {
  background: var(--warn);
}

.status-dot.offline {
  background: var(--danger);
}

/* ---------- banner ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: #3a1d22;
  color: #ffd7d7;
  border-bottom: 1px solid #5a2a30;
  font-size: 13px;
  flex: none;
}

/* `display: flex` above would otherwise win over the hidden attribute's
   UA-supplied `display: none`, leaving an empty bar on screen. */
.banner[hidden] {
  display: none;
}

.banner .btn {
  margin-left: auto;
}

/* ---------- terminal ---------- */

.terminal {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px 4px 4px 10px;
  background: var(--bg);
  overflow: hidden;
}

.terminal .xterm {
  height: 100%;
}

.terminal .xterm-viewport {
  background-color: transparent !important;
  scrollbar-width: thin;
}

.terminal .xterm-viewport::-webkit-scrollbar {
  width: 10px;
}

.terminal .xterm-viewport::-webkit-scrollbar-thumb {
  background: #2a3242;
  border-radius: 5px;
}

.foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 11.5px;
  flex: none;
}

.foot .spacer {
  margin-left: auto;
}

#session-cwd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- dialog ---------- */

.dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 20px;
  width: min(30rem, calc(100vw - 2rem));
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.dialog-field {
  display: block;
  margin-bottom: 14px;
}

.dialog-field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.dialog-field input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.dialog-field small {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
}

.dialog-error {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 12.5px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- login ---------- */

.login-page {
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.login-card {
  width: min(24rem, calc(100vw - 2rem));
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 13px;
}

.login-card .dialog-field input {
  font-size: 15px;
}

.login-submit {
  width: 100%;
  padding: 8px 12px;
}

.login-hint {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .brand .muted,
  .foot .spacer {
    display: none;
  }

  .controls {
    margin-left: 0;
  }

  select {
    min-width: 7rem;
  }
}
