/* ===== Theme tokens ===== */
:root {
  --bg: #05080d;
  --panel: rgba(8, 14, 20, 0.92);
  --fg: #00ff9c;
  --fg-dim: #5c8a74;
  --accent: #00d9ff;
  --path: #7aa2ff;
  --warn: #ffcc00;
  --err: #ff4d6d;
  --text: #c9f7e2;
  --border: rgba(0, 255, 156, 0.25);
  --glow: 0 0 8px rgba(0, 255, 156, 0.45);
}
[data-theme="amber"] {
  --fg: #ffb000; --fg-dim: #8a6a2c; --accent: #ffd479; --text: #ffe6b3;
  --border: rgba(255, 176, 0, 0.25); --glow: 0 0 8px rgba(255, 176, 0, 0.45);
}
[data-theme="cyan"] {
  --fg: #00e5ff; --fg-dim: #3f7c86; --accent: #a78bfa; --text: #d6f8ff;
  --border: rgba(0, 229, 255, 0.25); --glow: 0 0 8px rgba(0, 229, 255, 0.45);
}
[data-theme="red"] {
  --fg: #ff3b5c; --fg-dim: #8a4050; --accent: #ff9f43; --text: #ffd9df;
  --border: rgba(255, 59, 92, 0.25); --glow: 0 0 8px rgba(255, 59, 92, 0.45);
}

/* ===== Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
}
body { display: flex; align-items: center; justify-content: center; padding: 24px; overflow: hidden; }
#matrix { position: fixed; inset: 0; z-index: 0; opacity: 0.16; }

/* ===== Window ===== */
.window {
  position: relative; z-index: 1;
  width: min(1000px, 100%);
  height: min(720px, calc(100vh - 48px));
  height: min(720px, calc(100dvh - 48px));
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), var(--glow);
  overflow: hidden;
  backdrop-filter: blur(4px);
}
/* CRT scanlines */
.window::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
}

.titlebar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  font-size: 12px; color: var(--fg-dim);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.red { background: #ff5f57; } .yellow { background: #febc2e; } .green { background: #28c840; }
.title { flex: 1; text-align: center; }
.status { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--fg); letter-spacing: 1px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--fg); box-shadow: var(--glow); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ===== Terminal ===== */
#terminal {
  flex: 1; overflow-y: auto; padding: 16px 18px; cursor: text;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.line { white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
#input-line { display: flex; gap: 8px; align-items: center; }
#prompt { white-space: nowrap; }
#cmd {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
  color: var(--text); font: inherit; caret-color: var(--fg);
}

.p-user { color: var(--fg); } .p-host { color: var(--accent); } .p-path { color: var(--path); }
.p-ai { color: var(--accent); } .p-warn { color: var(--warn); }
.h { color: var(--fg); font-weight: 700; text-shadow: var(--glow); }
.dim { color: var(--fg-dim); } .ok { color: var(--fg); } .warn { color: var(--warn); } .err { color: var(--err); }
.accent { color: var(--accent); }
.ai { color: var(--text); border-left: 2px solid var(--accent); padding-left: 10px; margin: 4px 0; }
a { color: var(--accent); }
.cmd-name { color: var(--fg); cursor: pointer; text-decoration: none; }
.cmd-name:hover { text-decoration: underline; }
.banner { color: var(--fg); text-shadow: var(--glow); font-size: 13px; line-height: 1.15; }
.banner-sm { display: none; color: var(--fg); text-shadow: var(--glow); font-weight: 700; }
.thinking::after { content: ""; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ===== Quick command bar (great on mobile) ===== */
#quick {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
}
#quick button {
  font: inherit; font-size: 12px; color: var(--fg);
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 10px; cursor: pointer; transition: all 0.15s;
}
#quick button:hover, #quick button:focus-visible { background: var(--fg); color: var(--bg); outline: none; }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  html, body { font-size: 13px; }
  body { padding: 0; }
  .window { height: 100vh; height: 100dvh; border-radius: 0; border: 0; }
  .title { display: none; }
  .banner { display: none; }
  .banner-sm { display: block; }
  #cmd { font-size: 16px; } /* prevents iOS zoom on focus */
}

@media (prefers-reduced-motion: reduce) {
  .pulse, .thinking::after { animation: none; }
}
