:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: rgba(17, 22, 33, .82);
  --surface-solid: #111621;
  --surface-hover: #171e2d;
  --border: #273143;
  --border-soft: rgba(146, 164, 195, .14);
  --text: #f4f6fb;
  --muted: #8995a9;
  --faint: #5d687b;
  --accent: #9ce57b;
  --accent-strong: #baff94;
  --accent-ink: #10200e;
  --danger: #ff8d93;
  --danger-soft: rgba(255, 141, 147, .11);
  --shadow: 0 24px 80px rgba(0, 0, 0, .33);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); letter-spacing: -.01em; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.ambient { position: fixed; z-index: -1; pointer-events: none; border-radius: 50%; filter: blur(1px); opacity: .35; }
.ambient-one { top: -22rem; left: 20%; width: 42rem; height: 42rem; background: radial-gradient(circle, rgba(128, 255, 132, .11), transparent 67%); }
.ambient-two { right: -20rem; bottom: -17rem; width: 42rem; height: 42rem; background: radial-gradient(circle, rgba(95, 120, 255, .1), transparent 65%); }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .2em; line-height: 1.2; }
.eyebrow-danger { color: var(--danger); }
.subtle, .login-copy, .modal-copy { color: var(--muted); line-height: 1.55; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 4px rgba(156, 229, 123, .08); }
.status-dot.warning { background: #ffc16d; }
.status-dot.offline { background: var(--danger); }

.login-layout { display: grid; min-height: 100vh; place-items: center; padding: 28px 20px; }
.login-card { width: min(100%, 416px); padding: 44px; border: 1px solid var(--border-soft); border-radius: 20px; background: linear-gradient(145deg, rgba(22, 29, 43, .9), rgba(11, 15, 23, .82)); box-shadow: var(--shadow); }
.brand-mark, .wordmark-symbol { display: grid; place-items: center; color: var(--accent-ink); background: var(--accent); font-weight: 850; }
.brand-mark { width: 42px; height: 42px; margin-bottom: 34px; border-radius: 12px; font-size: 21px; }
.login-card h1 { margin: 0; font-size: clamp(32px, 7vw, 42px); letter-spacing: -.055em; line-height: 1.05; }
.login-card h1 span { color: var(--accent); }
.login-copy { max-width: 290px; margin: 15px 0 32px; font-size: 14px; }
.stack-form { display: grid; gap: 10px; }
label { color: var(--muted); font-size: 12px; font-weight: 650; }
input { width: 100%; color: var(--text); border: 1px solid var(--border); border-radius: 9px; background: rgba(6, 9, 15, .57); transition: border-color .15s, box-shadow .15s, background .15s; }
input:focus { border-color: var(--accent); background: rgba(6, 9, 15, .78); box-shadow: 0 0 0 3px rgba(156, 229, 123, .1); outline: none; }
.stack-form input { height: 48px; padding: 0 44px 0 14px; }
.password-field { position: relative; }
.icon-button { position: absolute; top: 50%; right: 7px; width: 32px; height: 32px; transform: translateY(-50%); color: var(--muted); border: 0; border-radius: 6px; background: transparent; font-size: 13px; }
.icon-button:hover { color: var(--text); background: var(--surface-hover); }
.primary-button, .danger-button, .quiet-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 38px; padding: 0 15px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 700; transition: transform .15s, background .15s, border-color .15s, color .15s; }
.primary-button { color: var(--accent-ink); background: var(--accent); }
.primary-button:hover { background: var(--accent-strong); transform: translateY(-1px); }
.primary-button.wide { width: 100%; height: 47px; margin-top: 10px; }
.primary-button.wide span:last-child { margin-left: auto; font-size: 18px; line-height: 0; }
.quiet-button { color: var(--muted); border-color: var(--border); background: rgba(14, 19, 29, .7); }
.quiet-button:hover { color: var(--text); border-color: #3c4a63; background: var(--surface-hover); }
.danger-button { color: var(--danger); border-color: rgba(255, 141, 147, .28); background: var(--danger-soft); }
.danger-button:hover { color: #ffb1b5; border-color: rgba(255, 141, 147, .52); background: rgba(255, 141, 147, .17); }
.form-error { min-height: 17px; margin: 1px 0 0; color: var(--danger); font-size: 12px; line-height: 1.45; }
.login-footnote { display: flex; align-items: center; gap: 9px; margin: 42px 0 0; color: var(--faint); font-size: 11px; }

.app-layout { width: min(100%, 1260px); min-height: 100vh; margin: 0 auto; padding: 0 42px 48px; }
.app-header { display: flex; align-items: center; justify-content: space-between; height: 82px; border-bottom: 1px solid rgba(146, 164, 195, .1); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 17px; font-weight: 750; letter-spacing: -.03em; text-decoration: none; }
.wordmark-symbol { width: 27px; height: 27px; border-radius: 8px; font-size: 14px; }
.header-actions, .connection-indicator, .terminal-heading, .terminal-actions, .toolbar, .modal-actions { display: flex; align-items: center; }
.header-actions { gap: 18px; }
.connection-indicator { gap: 8px; color: var(--muted); font-size: 11px; }
.sessions-view { padding-top: 70px; }
.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.page-intro h1 { margin: 0; font-size: clamp(30px, 5vw, 47px); letter-spacing: -.06em; line-height: 1; }
.page-intro .subtle { margin: 13px 0 0; font-size: 14px; }
.create-button { height: 42px; padding: 0 17px; }
.plus { font-size: 21px; font-weight: 350; line-height: 0; }
.toolbar { gap: 10px; margin-top: 51px; }
.search-field { position: relative; display: flex; flex: 1; align-items: center; min-width: 0; }
.search-field input { height: 42px; padding: 0 37px; font-size: 13px; }
.search-icon { position: absolute; z-index: 1; left: 14px; color: var(--faint); font-size: 22px; line-height: 1; transform: rotate(-20deg); }
.search-field kbd { position: absolute; right: 12px; padding: 2px 5px; color: var(--faint); border: 1px solid var(--border); border-radius: 4px; font-size: 10px; }
.refresh-button { height: 42px; }
.refresh-icon { font-size: 18px; line-height: 0; }
.section-status { min-height: 21px; margin-top: 24px; color: var(--muted); font-size: 12px; }
.sessions-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 13px; }
.session-card { position: relative; display: flex; min-height: 174px; flex-direction: column; padding: 20px; border: 1px solid var(--border-soft); border-radius: 13px; background: linear-gradient(145deg, rgba(21, 27, 40, .87), rgba(13, 18, 27, .72)); transition: border-color .16s, background .16s, transform .16s; }
.session-card:hover, .session-card:focus-within { border-color: rgba(156, 229, 123, .42); background: var(--surface-hover); transform: translateY(-2px); }
.session-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.session-card h2 { overflow: hidden; margin: 0; color: var(--text); font-size: 17px; letter-spacing: -.03em; text-overflow: ellipsis; white-space: nowrap; }
.session-status { display: inline-flex; align-items: center; flex-shrink: 0; gap: 6px; padding: 4px 7px; color: var(--muted); border-radius: 5px; background: rgba(7, 10, 16, .45); font-size: 10px; }
.session-status.attached { color: var(--accent); }
.session-command { overflow: hidden; min-height: 20px; margin: 12px 0 0; color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.session-command::before { margin-right: 7px; color: var(--accent); content: "›"; font-weight: 800; }
.session-card-footer { display: flex; align-items: end; justify-content: space-between; gap: 10px; min-height: 52px; margin-top: auto; padding-top: 16px; }
.session-meta { display: flex; gap: 12px; color: var(--faint); font-size: 11px; }
.session-meta strong { color: var(--muted); font-weight: 650; }
.card-actions { display: flex; gap: 5px; }
.card-open { min-height: 30px; padding: 0 10px; font-size: 11px; }
.card-delete { min-width: 30px; min-height: 30px; padding: 0; color: var(--faint); border: 0; border-radius: 6px; background: transparent; font-size: 16px; }
.card-delete:hover { color: var(--danger); background: var(--danger-soft); }
.empty-state { padding: 54px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: 13px; text-align: center; }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--text); font-size: 14px; }

.terminal-view { padding-top: 30px; }
.terminal-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; min-height: 48px; }
.back-button { justify-self: start; border-color: transparent; background: transparent; }
.terminal-heading { justify-content: center; gap: 9px; }
.terminal-prompt { color: var(--accent); font-family: monospace; font-size: 25px; line-height: 0; }
.terminal-heading h1 { max-width: min(38vw, 300px); overflow: hidden; margin: 0; font-size: 16px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.terminal-state { color: var(--muted); font-size: 10px; }
.terminal-state.connected { color: var(--accent); }
.terminal-state.error { color: var(--danger); }
.terminal-actions { justify-content: end; gap: 6px; }
.terminal-actions .quiet-button, .terminal-actions .danger-button { min-height: 32px; padding: 0 10px; font-size: 10px; }
.terminal-shell { position: relative; height: min(69vh, 720px); min-height: 360px; margin-top: 23px; padding: 25px; overflow: hidden; border: 1px solid #202a3a; border-radius: 12px; background: #05070c; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025), 0 20px 48px rgba(0, 0, 0, .22); }
.terminal-shell:focus-within { border-color: rgba(156, 229, 123, .42); }
.terminal-hint { position: absolute; top: 14px; right: 17px; color: #3d4b5e; font-size: 10px; pointer-events: none; }
.terminal-output { width: 100%; height: 100%; }
.terminal-output .xterm { height: 100%; }
.terminal-output .xterm-viewport { scrollbar-color: #354259 #080b12; }
.terminal-note { margin: 13px 3px 0; color: var(--faint); font-size: 10px; }
@keyframes blink { 50% { opacity: 0; } }

.modal { width: min(calc(100% - 28px), 420px); padding: 0; color: var(--text); border: 1px solid #303b4f; border-radius: 15px; background: var(--surface-solid); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(3, 5, 9, .72); backdrop-filter: blur(5px); }
.modal-card { position: relative; display: grid; gap: 9px; padding: 30px; }
.modal-card h2 { margin: 0 0 2px; font-size: 25px; letter-spacing: -.045em; }
.modal-card h2 span { color: var(--danger); }
.modal-copy { margin: 0 0 14px; font-size: 12px; }
.modal-card input { height: 43px; padding: 0 12px; }
.modal-card textarea { width: 100%; min-height: 130px; padding: 11px 12px; resize: vertical; color: var(--text); border: 1px solid var(--border); border-radius: 7px; outline: none; background: #0b1019; font: 12px/1.5 "SFMono-Regular", Consolas, monospace; }
.modal-card textarea:focus { border-color: rgba(156, 229, 123, .55); box-shadow: 0 0 0 3px rgba(156, 229, 123, .08); }
.modal-actions { justify-content: end; gap: 8px; margin-top: 10px; }
.modal-close { position: absolute; top: 15px; right: 16px; width: 29px; height: 29px; color: var(--muted); border: 0; border-radius: 6px; background: transparent; font-size: 21px; line-height: 1; }
.modal-close:hover { color: var(--text); background: var(--surface-hover); }

.toast-region { position: fixed; z-index: 10; top: 18px; right: 18px; display: grid; gap: 8px; width: min(360px, calc(100% - 36px)); }
.toast { padding: 12px 14px; color: var(--text); border: 1px solid var(--border); border-radius: 8px; background: #171e2d; box-shadow: var(--shadow); font-size: 12px; }
.toast.error { color: #ffdadd; border-color: rgba(255, 141, 147, .38); background: #24161d; }

@media (max-width: 720px) {
  .app-layout { padding: 0 18px 32px; }
  .app-header { height: 68px; }
  .connection-label { display: none; }
  .sessions-view { padding-top: 44px; }
  .page-intro { align-items: start; flex-direction: column; }
  .create-button { width: 100%; }
  .toolbar { margin-top: 31px; }
  .refresh-button { width: 42px; padding: 0; }
  .refresh-button span:last-child { display: none; }
  .terminal-toolbar { grid-template-columns: auto 1fr auto; gap: 8px; }
  .terminal-heading { min-width: 0; justify-content: start; }
  .terminal-heading h1 { max-width: 32vw; }
  .terminal-state { display: none; }
  .terminal-actions { gap: 4px; }
  .terminal-actions .quiet-button { width: 33px; padding: 0; overflow: hidden; font-size: 0; }
  .terminal-actions .quiet-button::first-letter { font-size: 15px; }
  #copy-button::before { content: "⧉"; font-size: 15px; }
  #paste-button::before { content: "▣"; font-size: 14px; }
  #reconnect-button::before { content: "↻"; font-size: 15px; }
  #fullscreen-button::before { content: "⛶"; font-size: 15px; }
  .terminal-actions .danger-button { width: 33px; padding: 0; overflow: hidden; font-size: 0; }
  .terminal-actions .danger-button::before { content: "×"; font-size: 17px; }
  .terminal-shell { height: calc(100vh - 190px); min-height: 300px; padding: 17px 14px; }
  .terminal-hint { display: none; }
}
@media (max-width: 440px) {
  .login-card { padding: 31px 24px; }
  .wordmark { font-size: 15px; }
  .page-intro h1 { font-size: 34px; }
  .sessions-list { grid-template-columns: 1fr; }
  .terminal-toolbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .back-button { width: 33px; padding: 0; font-size: 0; }
  .back-button span:first-child { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
