:root {
  color-scheme: dark;
  --bg: #050908;
  --panel: #0a1210;
  --panel2: #0e1915;
  --line: #173328;
  --text: #d8fbe9;
  --muted: #7ca995;
  --accent: #55f29a;
  --accent2: #0f6d3e;
  --danger: #ff5f6d;
  --terminal: #9dffc7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 0%, rgba(27, 86, 59, .18), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

body { min-height: 100dvh; }

button, input { font: inherit; }

.shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px;
}

.hidden { display: none !important; }

.login-card {
  max-width: 520px;
  margin: 8vh auto 0;
  background: rgba(10, 18, 16, .94);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
}

.eyebrow {
  color: var(--accent);
  font-size: .76rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(1.6rem, 5vw, 2.5rem);
}

.sub {
  margin: 0 0 28px;
  color: var(--muted);
}

label {
  display: block;
  margin: 16px 0 7px;
  color: var(--muted);
  font-size: .84rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #07100d;
  color: var(--text);
  border-radius: 12px;
  padding: 14px 15px;
  outline: none;
}

input:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(85,242,154,.08);
}

button {
  border: 0;
  border-radius: 11px;
  padding: 11px 14px;
  cursor: pointer;
}

.primary {
  width: 100%;
  margin-top: 22px;
  background: var(--accent);
  color: #031009;
  font-weight: 800;
}

.ghost {
  background: #101b17;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger {
  background: #2a1014;
  color: #ffb4bc;
  border: 1px solid #6b242e;
}

.error {
  min-height: 1.4em;
  margin-top: 14px;
  color: #ff9da7;
  font-size: .88rem;
}

.terminal-view {
  height: calc(100dvh - 36px);
  min-height: 520px;
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(6, 13, 10, .96);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.identity {
  margin-top: 4px;
  color: var(--text);
  font-size: .95rem;
}

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

.statusrow {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  color: var(--muted);
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7d8d84;
}

.dot.ready { background: var(--accent); }
.dot.connected { background: #ffe17a; }

.terminal {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 18px;
  color: var(--terminal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  outline: none;
  font-size: clamp(.86rem, 3.6vw, 1rem);
  line-height: 1.45;
  caret-color: var(--accent);
  background:
    linear-gradient(rgba(255,255,255,.015) 50%, transparent 50%);
  background-size: 100% 4px;
  box-shadow:
    inset 0 12px 24px rgba(0,0,0,.18),
    inset 0 -12px 24px rgba(0,0,0,.18);
}

.terminal::-webkit-scrollbar {
  width: 12px;
}

.terminal::-webkit-scrollbar-track {
  background: #07100d;
  border-left: 1px solid var(--line);
}

.terminal::-webkit-scrollbar-thumb {
  background: #1d5e43;
  border: 3px solid #07100d;
  border-radius: 999px;
}

.terminal::-webkit-scrollbar-thumb:hover {
  background: #2a7b59;
}

.terminal {
  scrollbar-color: #1d5e43 #07100d;
  scrollbar-width: thin;
}

.terminal:focus {
  box-shadow: inset 0 0 0 1px rgba(85,242,154,.18);
}

.keyboard-capture {
  position: absolute;
  width: 2px;
  height: 2px;
  opacity: .01;
  pointer-events: none;
  left: 8px;
  bottom: 8px;
}

footer {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
  background: var(--panel);
}

@media (max-width: 640px) {
  .shell { padding: 0; }
  .terminal-view {
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .topbar { align-items: flex-start; }
  .actions { flex-direction: column; }
  .actions button { padding: 9px 10px; font-size: .76rem; }
  .login-card { margin: 5vh 14px 0; padding: 22px; }
}


.topbar {
  backdrop-filter: blur(10px);
}

.statusrow {
  min-height: 38px;
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.015);
}

.statusrow::before {
  content: "LINK";
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .12em;
  margin-right: 2px;
}

footer {
  display: flex;
  align-items: center;
  min-height: 38px;
}

@media (min-width: 641px) {
  .shell {
    height: 100dvh;
    padding-top: 18px;
    padding-bottom: 18px;
  }
}


.connection-help {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: #091610;
}

.connection-help-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.help-label {
  color: var(--accent);
  font-size: .68rem;
  letter-spacing: .13em;
}

.help-call {
  color: var(--muted);
  font-size: .82rem;
}

.help-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.help-command {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .08em;
}

.help-command code {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #06100c;
  color: var(--accent);
  font-family: inherit;
  letter-spacing: normal;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 14px;
  overflow-y: auto;
  background: rgba(0, 5, 3, .82);
  backdrop-filter: blur(7px);
}

.modal-panel {
  width: min(100%, 600px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #08110e;
  box-shadow: 0 25px 80px rgba(0,0,0,.55);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.modal-head h2 {
  margin: 5px 0 0;
  font-size: 1.15rem;
}

.settings-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: .9rem;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row input[type="range"] {
  flex: 1;
  padding: 0;
}

.range-row output {
  min-width: 50px;
  color: var(--accent);
  text-align: right;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text);
  cursor: pointer;
}

.check-row input {
  width: auto;
}

.compact {
  width: auto;
  min-width: 180px;
}

.form-message {
  min-height: 1.4em;
  margin-top: 10px;
  color: var(--muted);
  font-size: .8rem;
}

.form-message.error-text {
  color: #ff9da7;
}

.form-message.success-text {
  color: var(--accent);
}

@media (max-width: 640px) {
  .connection-help {
    padding: 9px 12px;
  }

  .help-note {
    font-size: .74rem;
  }

  .modal {
    padding: 0;
  }

  .modal-panel {
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}


.settings-copy,
.settings-hint {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}

.settings-hint {
  margin: 10px 0 0;
}

.ampr-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #06100c;
}

.ampr-status-label {
  color: var(--muted);
  font-size: .65rem;
  letter-spacing: .12em;
}

.ampr-status-value {
  margin-top: 3px;
  color: var(--text);
  font-size: .88rem;
}

.ampr-badge {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .08em;
}

.ampr-badge.ready {
  border-color: var(--accent2);
  color: var(--accent);
  background: rgba(85,242,154,.07);
}

.ampr-badge.disabled {
  color: #e4ad71;
}


.enrollment-note {
  margin: 14px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(85, 242, 154, .055);
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.password-rule {
  margin: 7px 0 14px;
  color: var(--muted);
  font-size: .74rem;
}

.enrollment-logout {
  width: 100%;
  margin-top: 10px;
}


.site-return,
.site-return-full {
  border-color: #275744;
  color: var(--accent);
}

.site-return:hover,
.site-return-full:hover {
  background: #10251c;
}

.site-return-full {
  width: 100%;
  margin-top: 10px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  .actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .actions button {
    padding: 9px 10px;
    font-size: .72rem;
  }
}
