:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #10151d;
  --line: #252d39;
  --text: #f4f7fb;
  --muted: #8d99a9;
  --gold: #f1c84b;
  --green: #4ade80;
  --red: #fb7185;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none;
  background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.auth-shell {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 10%, rgba(241, 200, 75, .12), transparent 38%),
    var(--bg);
}
.auth-card {
  width: min(100%, 390px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 21, 29, .96);
  box-shadow: 0 28px 90px rgba(0,0,0,.45);
}
.mark, .brand-mark {
  display: inline-grid;
  place-items: center;
  color: #0c0e11;
  background: var(--gold);
  font-weight: 900;
}
.mark { width: 44px; height: 44px; border-radius: 11px; font-size: 24px; }
.eyebrow { margin: 22px 0 7px; color: var(--gold); font-size: 11px; letter-spacing: .18em; font-weight: 800; }
h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.muted { color: var(--muted); line-height: 1.5; font-size: 14px; }
label { display: block; margin: 24px 0 8px; color: #cbd3dd; font-size: 13px; font-weight: 650; }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #090d13;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(241, 200, 75, .12); }
.auth-card button {
  width: 100%; margin-top: 14px; border: 0; border-radius: 10px; padding: 13px;
  color: #111; background: var(--gold); font-weight: 800; cursor: pointer;
}
.auth-card button:disabled { opacity: .55; cursor: wait; }
.auth-card .secondary { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.error { min-height: 20px; margin: 14px 0 0; color: var(--red); font-size: 13px; }
.passkey-dialog {
  width: min(calc(100% - 28px), 410px); padding: 30px; border: 1px solid #4e4630;
  border-radius: 18px; color: var(--text); background: #10151d;
  box-shadow: 0 30px 100px rgba(0,0,0,.7);
}
.passkey-dialog::backdrop { background: rgba(2, 5, 9, .82); backdrop-filter: blur(5px); }
.passkey-dialog h2 { margin: 8px 0 0; font-size: 25px; letter-spacing: -.025em; }
.passkey-dialog button {
  width: 100%; margin-top: 12px; border: 0; border-radius: 10px; padding: 14px;
  color: #111; background: var(--gold); font-weight: 800; cursor: pointer;
}
.passkey-dialog button:disabled { opacity: .55; cursor: wait; }

.console-shell { height: 100%; height: 100dvh; display: grid; grid-template-rows: 48px minmax(0, 1fr) auto; }
header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: #0c1016;
}
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; font-size: 13px; font-weight: 750; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; font-size: 13px; }
.terminal-tabs {
  min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 5px;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
}
.terminal-tabs::-webkit-scrollbar { display: none; }
.terminal-tab {
  flex: 0 0 auto; max-width: 160px; height: 32px; display: flex; align-items: center; gap: 7px;
  padding: 0 8px 0 11px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); background: #111720; cursor: pointer; scroll-snap-align: nearest;
}
.terminal-tab.active { color: var(--text); border-color: #5d5230; background: #1d1c17; }
.terminal-tab-label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.terminal-tab-close {
  width: 18px; height: 18px; display: grid; place-items: center; border-radius: 5px;
  color: #778291; font-size: 16px; line-height: 1;
}
.terminal-tab-close:hover { color: var(--text); background: #303744; }
.new-terminal { flex: 0 0 auto; color: #111; border-color: var(--gold); background: var(--gold); font-size: 19px; font-weight: 800; }
.actions { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
.status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.status.online i { background: var(--green); box-shadow: 0 0 0 3px rgba(74, 222, 128, .12); }
.status.offline i { background: var(--red); }
.icon-button, .keybar button {
  border: 1px solid var(--line); background: #131923; color: #d7dee8; border-radius: 7px; cursor: pointer;
}
.icon-button { min-width: 33px; height: 31px; padding: 0 9px; font-size: 12px; }
#terminal { min-width: 0; min-height: 0; padding: 7px 8px 2px; background: #080b10; }
#terminal .xterm { height: 100%; }
#terminal .xterm-viewport { scrollbar-color: #343d4b transparent; scrollbar-width: thin; }
.keybar {
  display: flex; gap: 6px; overflow-x: auto; padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); background: #0c1016; scrollbar-width: none;
}
.keybar::-webkit-scrollbar { display: none; }
.keybar button { flex: 0 0 auto; min-width: 49px; padding: 8px 10px; font-size: 12px; touch-action: manipulation; }
.keybar button:active, .icon-button:active { background: #252e3b; transform: translateY(1px); }

.install-prompt {
  position: fixed; z-index: 20; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 480px); transform: translateX(-50%);
  display: grid; grid-template-columns: 46px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid #343d4b; border-radius: 16px;
  background: rgba(16, 21, 29, .98); box-shadow: 0 20px 70px rgba(0, 0, 0, .62);
}
.install-prompt img { border-radius: 11px; }
.install-copy { min-width: 0; display: grid; gap: 3px; }
.install-copy strong { font-size: 14px; }
.install-copy span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.install-prompt button {
  min-height: 40px; border: 0; border-radius: 9px; padding: 0 14px;
  color: #111; background: var(--gold); font-size: 13px; font-weight: 800; cursor: pointer;
}
.install-prompt .install-dismiss { min-width: 32px; padding: 0; color: var(--muted); background: transparent; font-size: 24px; }

@media (display-mode: standalone) {
  .install-prompt { display: none !important; }
}

@media (min-width: 760px) {
  .keybar { display: none; }
  .console-shell { grid-template-rows: 48px minmax(0, 1fr); }
}
@media (max-width: 600px) {
  header { gap: 5px; padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
  .brand > span:last-child { display: none; }
  .terminal-tab { max-width: 112px; padding-left: 8px; }
  .terminal-tab-label { max-width: 72px; }
  .actions { gap: 4px; }
  .icon-button { min-width: 31px; padding: 0 7px; }
}

@media (max-width: 480px) {
  .auth-shell { padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); }
  .auth-card { padding: 27px 22px; }
  input { min-height: 48px; font-size: 16px; }
  .auth-card button { min-height: 48px; }
  .status > span { display: none; }
  #terminal { padding-left: 4px; padding-right: 4px; }
  .install-prompt {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .install-prompt img { width: 42px; height: 42px; }
  .install-prompt .install-dismiss { position: absolute; top: -8px; right: -6px; background: #222a35; border: 1px solid var(--line); }
}
