:root {
  color-scheme: dark;
  --bg: #070c16;
  --surface: rgba(13, 22, 38, 0.86);
  --surface-strong: #101b30;
  --surface-soft: rgba(19, 31, 53, 0.64);
  --line: rgba(137, 170, 214, 0.15);
  --line-strong: rgba(137, 170, 214, 0.26);
  --text: #e9f2ff;
  --muted: #8294ae;
  --muted-strong: #a8b8cd;
  --cyan: #66e3dc;
  --cyan-strong: #20c7c0;
  --amber: #ffbd6b;
  --red: #ff737f;
  --green: #76e3a4;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 18px;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.app-background { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.grid-lines {
  position: absolute; inset: 0; opacity: 0.24;
  background-image: linear-gradient(rgba(119, 156, 204, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(119, 156, 204, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}
.glow { position: absolute; width: 560px; height: 560px; border-radius: 50%; filter: blur(90px); opacity: 0.13; }
.glow-one { top: -260px; right: -180px; background: #147d9b; }
.glow-two { bottom: -300px; left: -240px; background: #2a397f; }

.app-shell { width: min(1480px, calc(100% - 56px)); margin: 0 auto; padding: 22px 0 20px; }
.topbar, .app-footer, .intro-row, .panel-heading, .button-row, .quick-footer, .terminal-footnote { display: flex; align-items: center; justify-content: space-between; }
.topbar { min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--cyan); border: 1px solid rgba(102, 227, 220, 0.32); border-radius: 10px; background: rgba(102, 227, 220, 0.07); box-shadow: 0 0 24px rgba(102, 227, 220, 0.11); }
.brand-mark svg { width: 21px; height: 21px; }
.brand strong { display: block; font-family: var(--mono); font-size: 14px; letter-spacing: 0.02em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-family: var(--mono); font-size: 8px; letter-spacing: 0.17em; }
.topbar-meta { display: flex; align-items: center; gap: 20px; color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; }
.offline-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--green); }
.pulse-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 4px rgba(118, 227, 164, 0.1); }
.version-label { color: #61738f; }

.intro-row { gap: 28px; padding: 72px 2px 38px; align-items: flex-end; }
.eyebrow, .section-kicker { margin: 0; color: var(--cyan); font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.2em; }
.eyebrow span { padding: 0 8px; color: #47677c; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 760px; margin-bottom: 16px; font-size: clamp(39px, 5vw, 70px); line-height: 0.98; letter-spacing: -0.06em; font-weight: 650; }
h1 em { color: var(--cyan); font-style: normal; }
.intro-copy { max-width: 600px; margin-bottom: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.support-card { display: flex; align-items: flex-start; gap: 13px; width: min(335px, 100%); padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(13, 22, 38, 0.6); }
.support-icon { display: grid; place-items: center; flex: 0 0 auto; width: 29px; height: 29px; color: var(--cyan); font-size: 22px; border: 1px solid rgba(102, 227, 220, 0.3); border-radius: 9px; }
.support-card strong { display: block; margin: 1px 0 5px; color: var(--muted-strong); font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; }
.support-card p { margin-bottom: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.support-card.support-error { border-color: rgba(255, 115, 127, 0.32); }
.support-card.support-error .support-icon { color: var(--red); border-color: rgba(255, 115, 127, 0.32); }

.workspace-grid { display: grid; grid-template-columns: minmax(330px, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }
.side-column { display: grid; gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.connection-panel, .quick-panel { padding: 22px; }
.terminal-panel { min-height: 700px; padding: 22px; }
.panel-heading { gap: 15px; align-items: flex-start; }
.compact-heading, .terminal-heading { align-items: center; }
.panel-heading h2, .dialog-heading h2 { margin: 7px 0 0; color: var(--text); font-size: 17px; letter-spacing: -0.025em; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.status-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--muted); }
.status-connected { color: var(--green); border-color: rgba(118, 227, 164, 0.24); background: rgba(118, 227, 164, 0.06); }
.status-connected .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(118, 227, 164, 0.1); }
.status-connecting { color: var(--amber); border-color: rgba(255, 189, 107, 0.25); background: rgba(255, 189, 107, 0.06); }
.status-connecting .status-dot { background: var(--amber); animation: blink 1s infinite; }
.status-error { color: var(--red); border-color: rgba(255, 115, 127, 0.26); background: rgba(255, 115, 127, 0.06); }
.status-error .status-dot { background: var(--red); }
@keyframes blink { 50% { opacity: 0.28; } }

.port-card { display: grid; gap: 5px; margin: 23px 0 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(7, 12, 22, 0.42); }
.port-card-label, .config-heading, .field span, .line-ending-hint { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; }
.port-card strong { overflow: hidden; color: var(--muted-strong); font-family: var(--mono); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.port-card small { color: #5f718b; font-size: 10px; }
.button-row { gap: 8px; }
.connection-actions { align-items: stretch; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 10px; color: var(--text); font-size: 11px; font-weight: 700; transition: 160ms ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { border-color: rgba(102, 227, 220, 0.42); color: #071718; background: var(--cyan); box-shadow: 0 8px 24px rgba(32, 199, 192, 0.12); }
.button-primary:hover:not(:disabled) { background: #8bf1e9; box-shadow: 0 12px 30px rgba(32, 199, 192, 0.2); }
.button-secondary { border-color: var(--line-strong); color: var(--muted-strong); background: rgba(255, 255, 255, 0.025); }
.button-secondary:hover:not(:disabled) { border-color: rgba(137, 170, 214, 0.48); color: var(--text); background: rgba(255, 255, 255, 0.055); }
.connection-actions .button-primary { flex: 1; }
.button-icon { font-size: 15px; line-height: 1; }
.config-block { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.config-heading { display: flex; justify-content: space-between; align-items: center; }
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 9px; margin-top: 13px; }
.field { display: grid; gap: 7px; }
.field-wide { grid-column: span 2; }
.field input, .field select, .composer-input-wrap { min-height: 38px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text); background: rgba(6, 12, 23, 0.68); }
.field input, .field select { width: 100%; padding: 0 10px; font-family: var(--mono); font-size: 11px; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #7d93ad 50%), linear-gradient(135deg, #7d93ad 50%, transparent 50%); background-position: calc(100% - 14px) 16px, calc(100% - 10px) 16px; background-repeat: no-repeat; background-size: 4px 4px, 4px 4px; }
.field input:focus, .field select:focus, .composer-input-wrap:focus-within { border-color: rgba(102, 227, 220, 0.55); box-shadow: 0 0 0 3px rgba(102, 227, 220, 0.07); }
.text-button { padding: 0; border: 0; color: #7d95b0; background: transparent; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.text-button:hover { color: var(--cyan); }

.panel-description { margin: 13px 0 15px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.icon-button { display: grid; place-items: center; width: 29px; height: 29px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--cyan); background: rgba(102, 227, 220, 0.06); font-size: 20px; line-height: 1; }
.icon-button:hover { border-color: rgba(102, 227, 220, 0.5); background: rgba(102, 227, 220, 0.13); }
.quick-command-list { display: grid; gap: 7px; }
.quick-command { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: rgba(255, 255, 255, 0.025); transition: 160ms ease; }
.quick-command:hover { border-color: var(--line); background: rgba(255, 255, 255, 0.05); }
.quick-send { min-width: 0; display: grid; gap: 4px; padding: 10px 11px; border: 0; color: var(--text); text-align: left; background: transparent; }
.quick-send strong { overflow: hidden; color: var(--cyan); font-family: var(--mono); font-size: 10px; letter-spacing: 0.11em; text-overflow: ellipsis; white-space: nowrap; }
.quick-send code { overflow: hidden; color: var(--muted); font-family: var(--mono); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.quick-actions { display: flex; gap: 3px; padding-right: 7px; }
.quick-actions button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; color: #667a96; background: transparent; font-family: var(--mono); font-size: 11px; }
.quick-actions button:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.quick-footer { gap: 12px; margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.saved-note { color: #667b97; font-family: var(--mono); font-size: 9px; }
.saved-check { color: var(--green); }

.terminal-heading { margin-bottom: 16px; }
.terminal-toolbar { display: flex; align-items: center; gap: 13px; }
.toggle-control { display: inline-flex; align-items: center; gap: 7px; color: #7f93ad; font-family: var(--mono); font-size: 9px; cursor: pointer; }
.toggle-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { display: inline-flex; align-items: center; width: 27px; height: 16px; padding: 2px; border-radius: 99px; background: #25334b; transition: 160ms ease; }
.toggle-thumb { width: 12px; height: 12px; border-radius: 99px; background: #7488a0; transition: 160ms ease; }
.toggle-control input:checked + .toggle-track { background: rgba(102, 227, 220, 0.35); }
.toggle-control input:checked + .toggle-track .toggle-thumb { transform: translateX(11px); background: var(--cyan); }
.toolbar-divider { width: 1px; height: 18px; background: var(--line); }
.terminal-window { position: relative; min-height: 560px; max-height: 560px; overflow: auto; padding: 19px 17px; border: 1px solid rgba(126, 164, 207, 0.15); border-radius: 12px; background: #060b14; box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.22); scrollbar-color: #253b58 transparent; }
.terminal-window::-webkit-scrollbar { width: 8px; }
.terminal-window::-webkit-scrollbar-thumb { border-radius: 99px; background: #263b57; }
.terminal-empty { display: grid; place-items: center; min-height: 510px; color: #637692; text-align: center; }
.terminal-empty strong { margin-top: 13px; color: #9aacc3; font-family: var(--mono); font-size: 11px; font-weight: 500; }
.terminal-empty p { margin: 7px 0 0; color: #586d89; font-size: 11px; }
.terminal-cursor { display: block; color: var(--cyan); font-family: var(--mono); font-size: 32px; line-height: 1; animation: blink 1.05s infinite; }
.log-line { display: grid; grid-template-columns: 86px 34px minmax(0, 1fr); gap: 10px; padding: 4px 0; font-family: var(--mono); font-size: 11px; line-height: 1.48; white-space: pre-wrap; word-break: break-word; }
.log-time { color: #4d627f; }
.log-direction { font-size: 9px; font-weight: 700; letter-spacing: 0.11em; }
.log-text { color: #b4c5db; }
.log-line.log-tx .log-direction { color: var(--cyan); }
.log-line.log-tx .log-text { color: #d9fffb; }
.log-line.log-rx .log-direction { color: var(--green); }
.log-line.log-system .log-direction { color: var(--amber); }
.log-line.log-system .log-text { color: #a9b6c9; }
.command-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; margin-top: 14px; }
.composer-input-wrap { display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.prompt-symbol { color: var(--cyan); font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; }
.composer-input-wrap input { min-width: 0; flex: 1; height: 36px; padding: 0; border: 0; outline: 0; color: #d9fffb; background: transparent; font-family: var(--mono); font-size: 12px; }
.composer-input-wrap input::placeholder { color: #566b88; }
.line-ending-hint { color: #55708d; letter-spacing: 0.08em; }
.send-button { min-width: 112px; }
.terminal-footnote { justify-content: flex-start; gap: 19px; margin-top: 9px; padding: 0 2px; color: #506480; font-family: var(--mono); font-size: 9px; }
kbd { padding: 2px 5px; border: 1px solid var(--line-strong); border-radius: 4px; color: #91a5bf; background: rgba(255, 255, 255, 0.04); font-family: var(--mono); font-size: 9px; }

.app-footer { margin-top: 19px; padding: 0 3px; color: #435873; font-family: var(--mono); font-size: 8px; letter-spacing: 0.13em; }
.app-footer span:last-child { color: #59708c; }

.command-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 17px; color: var(--text); background: #101b30; box-shadow: 0 28px 100px rgba(0, 0, 0, 0.6); }
.command-dialog::backdrop { background: rgba(3, 7, 13, 0.76); backdrop-filter: blur(4px); }
.command-dialog form { display: grid; gap: 18px; padding: 23px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-close { color: var(--muted); background: transparent; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.toast { position: fixed; right: 26px; bottom: 25px; z-index: 5; max-width: min(360px, calc(100% - 52px)); padding: 11px 14px; border: 1px solid rgba(102, 227, 220, 0.34); border-radius: 10px; color: var(--text); background: #13253a; box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35); font-family: var(--mono); font-size: 10px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { border-color: rgba(255, 115, 127, 0.4); }

@media (max-width: 980px) {
  .app-shell { width: min(100% - 32px, 700px); }
  .intro-row { display: grid; grid-template-columns: 1fr; gap: 24px; padding-top: 50px; }
  .support-card { width: min(100%, 430px); }
  .workspace-grid { grid-template-columns: 1fr; }
  .terminal-panel { min-height: 0; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 22px, 480px); padding-top: 12px; }
  .topbar-meta { display: none; }
  .intro-row { padding: 45px 0 26px; }
  h1 { font-size: 42px; }
  .connection-panel, .quick-panel, .terminal-panel { padding: 16px; }
  .panel-heading { align-items: flex-start; }
  .status-badge { font-size: 8px; }
  .connection-actions { display: grid; grid-template-columns: 1fr; }
  .terminal-heading { display: grid; gap: 14px; }
  .terminal-toolbar { flex-wrap: wrap; gap: 10px; }
  .terminal-window { min-height: 460px; max-height: 460px; padding: 14px 11px; }
  .terminal-empty { min-height: 420px; }
  .log-line { grid-template-columns: 72px 30px minmax(0, 1fr); gap: 7px; font-size: 10px; }
  .command-composer { grid-template-columns: 1fr; }
  .send-button { width: 100%; }
  .app-footer { display: grid; gap: 7px; }
}
