:root {
  color-scheme: dark;
  --bg: #060a13;
  --bg-soft: #0a101d;
  --panel: #0c1422;
  --panel-raised: #111c2e;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.24);
  --text: #e7eef9;
  --muted: #8494ab;
  --muted-soft: #5d6c83;
  --accent: #38e0c8;
  --accent-soft: rgba(56, 224, 200, 0.14);
  --accent-blue: #5ea8ff;
  --danger: #ff6b81;
  --warn: #ffc857;
  --radius-lg: 16px;
  --radius-md: 10px;
  --font-mono: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(1100px 620px at 12% -12%, rgba(56, 224, 200, 0.13), transparent 60%),
    radial-gradient(900px 560px at 105% 0%, rgba(94, 168, 255, 0.12), transparent 58%),
    radial-gradient(800px 500px at 50% 120%, rgba(94, 168, 255, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 0%, black, transparent 78%);
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100dvh;
  max-width: 2400px;
  margin: 0 auto;
  padding: 18px clamp(12px, 2.2vw, 26px) 14px;
}

/* ------------------------------------------------------------------ */
/* Top bar                                                             */
/* ------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--accent);
  background:
    linear-gradient(145deg, rgba(56, 224, 200, 0.16), rgba(94, 168, 255, 0.08)),
    var(--panel);
  border: 1px solid rgba(56, 224, 200, 0.28);
  box-shadow: 0 0 28px rgba(56, 224, 200, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand-text p {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(12, 20, 34, 0.72);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(255, 200, 87, 0.12);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.status-pill[data-state="online"] {
  color: #bff7ee;
  border-color: rgba(56, 224, 200, 0.32);
  background: rgba(56, 224, 200, 0.09);
}

.status-pill[data-state="online"] .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 224, 200, 0.14), 0 0 12px rgba(56, 224, 200, 0.8);
  animation: pulse 2.4s ease-in-out infinite;
}

.status-pill[data-state="offline"] {
  color: #ffc2cb;
  border-color: rgba(255, 107, 129, 0.3);
  background: rgba(255, 107, 129, 0.08);
}

.status-pill[data-state="offline"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.12);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(12, 20, 34, 0.72);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease, color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: rgba(56, 224, 200, 0.34);
  background: rgba(56, 224, 200, 0.08);
  color: #d8fffa;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid rgba(56, 224, 200, 0.6);
  outline-offset: 2px;
}

.btn .icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-accent {
  border-color: rgba(94, 168, 255, 0.45);
  background: linear-gradient(180deg, rgba(94, 168, 255, 0.22), rgba(56, 224, 200, 0.1));
  color: #eaf4ff;
}

.btn-accent:hover {
  border-color: rgba(94, 168, 255, 0.7);
  background: linear-gradient(180deg, rgba(94, 168, 255, 0.32), rgba(56, 224, 200, 0.16));
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  border-color: var(--line);
  background: rgba(12, 20, 34, 0.72);
  color: var(--text);
}

/* ------------------------------------------------------------------ */
/* Terminal                                                            */
/* ------------------------------------------------------------------ */

.terminal-shell {
  display: flex;
  flex: 1;
  min-height: 0;
}

.terminal-frame {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #05080f;
  box-shadow:
    0 30px 80px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.02),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.terminal-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 90px rgba(56, 224, 200, 0.045);
}

.terminal-chrome {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  background: linear-gradient(180deg, rgba(17, 28, 46, 0.9), rgba(10, 16, 29, 0.9));
}

.window-dots {
  display: flex;
  gap: 7px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #263246;
}

.dot-red {
  background: #ff5f57;
}

.dot-yellow {
  background: #febc2e;
}

.dot-green {
  background: #28c840;
}

.chrome-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.chrome-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

.terminal-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.terminal {
  position: absolute;
  inset: 0;
  padding: 12px 14px 14px;
}

.terminal .xterm {
  height: 100%;
}

.terminal .xterm-viewport {
  background-color: transparent !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

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

.terminal .xterm-viewport::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  background-clip: content-box;
}

.terminal .xterm-viewport::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
  background-clip: content-box;
}

.terminal-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(5, 8, 15, 0.78);
  backdrop-filter: blur(6px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.terminal-overlay[hidden] {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.terminal-overlay p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-align: center;
  padding: 0 20px;
}

.overlay-hint {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

.overlay-action {
  margin-top: 6px;
  height: 34px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid rgba(56, 224, 200, 0.38);
  background: rgba(56, 224, 200, 0.12);
  color: #d8fffa;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.overlay-action:hover {
  background: rgba(56, 224, 200, 0.2);
  border-color: rgba(56, 224, 200, 0.6);
}

.terminal-overlay.is-idle .spinner {
  display: none;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(56, 224, 200, 0.16);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------ */
/* Status bar                                                          */
/* ------------------------------------------------------------------ */

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  min-height: 20px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

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

.stat {
  white-space: nowrap;
}

.stat.is-online {
  color: var(--accent);
}

.stat.is-offline {
  color: var(--danger);
}

.sep {
  width: 1px;
  height: 10px;
  background: var(--line-strong);
}

/* ------------------------------------------------------------------ */
/* Responsive / fullscreen                                             */
/* ------------------------------------------------------------------ */

@media (max-width: 860px) {
  .brand-text p {
    display: none;
  }

  .btn-label {
    display: none;
  }

  .btn {
    width: 34px;
    padding: 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .app {
    gap: 10px;
    padding: 12px clamp(8px, 2vw, 16px) 10px;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 10px;
  }

  .status-pill {
    height: 30px;
    padding: 0 10px;
  }

  .status-label {
    display: none;
  }

  .status-pill::after {
    content: "";
    width: 0;
  }

  .chrome-badge {
    display: none;
  }

  .terminal {
    padding: 8px 9px 10px;
  }

  .statusbar {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
  }

  #stat-shell,
  #stat-host + .sep {
    display: none;
  }
}

@media (max-width: 400px) {
  .brand-mark {
    display: none;
  }

  .statusbar .status-group:last-child .sep:first-child {
    display: none;
  }
}

.terminal-frame:fullscreen {
  border-radius: 0;
  border: 0;
}

.terminal-frame:fullscreen .terminal-chrome {
  padding-right: 18px;
}

/* ------------------------------------------------------------------ */
/* Clipboard toast & paste modal                                       */
/* ------------------------------------------------------------------ */

.clipboard-toast {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 6;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(56, 224, 200, 0.38);
  background: rgba(11, 19, 33, 0.92);
  backdrop-filter: blur(6px);
  color: #bff7ee;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.clipboard-toast[hidden] {
  display: none;
}

.paste-modal {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 8, 15, 0.75);
  backdrop-filter: blur(5px);
}

.paste-modal[hidden] {
  display: none;
}

.paste-modal-card {
  width: min(480px, 100%);
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.paste-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.paste-modal-head strong {
  font-size: 0.9rem;
  color: var(--text);
}

.paste-modal-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.paste-modal-close:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.paste-modal-hint {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.45;
}

.paste-modal-hint kbd {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: rgba(6, 10, 19, 0.8);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text);
}

#paste-modal-input {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #05080f;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
}

#paste-modal-input:focus {
  border-color: rgba(56, 224, 200, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 224, 200, 0.12);
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
