/* ============================================================
   AP127 Assistant — cockpit / instrument-panel aesthetic
   Deep navy night-flight background, phosphor-amber accents,
   flight-strip chat bubbles. Fonts: Chakra Petch / Sora / JetBrains Mono
   ============================================================ */
:root {
  --bg: #0a0f16;
  --bg-2: #0e1721;
  --panel: #101b27;
  --panel-edge: #1d2f40;
  --ink: #d7e3ec;
  --ink-dim: #7d93a4;
  --amber: #ffb000;          /* phosphor instrument glow */
  --amber-soft: #ffcf6b;
  --cyan: #4fd1e0;
  --green: #5dd39e;          /* serviceable / go */
  --red: #ff5c6c;            /* grounded / no-go */
  --user: #14283a;
  --grid: rgba(79, 209, 224, 0.045);
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.75);
  --r: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Sora", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 176, 0, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(79, 209, 224, 0.06), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: clamp(12px, 3vw, 40px);
  overflow-x: hidden;
}

/* Subtle navigation-grid texture over the whole field */
.grid-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 30%, transparent 85%);
}
/* Slow CRT-style sweep */
.scanline {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: linear-gradient(rgba(255,255,255,0.025), transparent 4px);
  background-size: 100% 5px;
  opacity: 0.4;
}

/* ---- Console shell ---- */
.console {
  position: relative; z-index: 2;
  width: min(820px, 100%);
  display: flex; flex-direction: column;
  height: calc(100vh - clamp(24px, 6vw, 80px));
  max-height: 980px;
  background: linear-gradient(180deg, rgba(16,27,39,0.92), rgba(10,15,22,0.96));
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.03);
  overflow: hidden;
}

/* ---- Header ---- */
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(180deg, #0d1825, #0a121c);
  border-bottom: 1px solid var(--panel-edge);
  position: relative;
}
.panel-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  opacity: 0.5;
}
.head-id { display: flex; align-items: baseline; gap: 14px; }
.callsign {
  font-family: "Chakra Petch", sans-serif; font-weight: 700;
  font-size: 1.5rem; letter-spacing: 2px; color: var(--ink);
  text-shadow: 0 0 18px rgba(255,176,0,0.15);
}
.callsign .accent { color: var(--amber); }
.title {
  font-family: "Chakra Petch", sans-serif; font-weight: 500;
  font-size: 0.7rem; letter-spacing: 4px; color: var(--ink-dim);
}
.head-status {
  display: flex; align-items: center; gap: 8px;
  font-family: "JetBrains Mono", monospace; font-size: 0.68rem;
  letter-spacing: 2px; color: var(--ink-dim);
  border: 1px solid var(--panel-edge); border-radius: 100px;
  padding: 5px 12px; background: rgba(0,0,0,0.25);
}
.head-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 10px var(--green);
}
.head-status.busy .dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---- Transcript ---- */
.log {
  flex: 1; overflow-y: auto;
  padding: 24px 20px 8px;
  display: flex; flex-direction: column; gap: 18px;
  scrollbar-width: thin; scrollbar-color: var(--panel-edge) transparent;
}
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: var(--panel-edge); border-radius: 4px; }

.msg { display: flex; gap: 12px; max-width: 92%; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.msg.user { margin-left: auto; flex-direction: row-reverse; }

.avatar {
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Chakra Petch", sans-serif; font-size: 0.9rem;
  background: radial-gradient(circle at 30% 25%, #16283a, #0b141d);
  border: 1px solid var(--panel-edge); color: var(--amber);
  box-shadow: 0 0 14px rgba(255,176,0,0.12);
}
.msg.user .avatar { color: var(--cyan); }

/* Flight-strip bubbles */
.bubble {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-left: 3px solid var(--amber);
  border-radius: var(--r);
  padding: 12px 15px;
  font-size: 0.93rem; line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
  white-space: pre-wrap; word-break: break-word;
}
.msg.user .bubble {
  background: var(--user); border-left: none; border-right: 3px solid var(--cyan);
}
.bubble p + p { margin-top: 8px; }
.bubble strong { color: var(--amber-soft); font-weight: 600; }
.bubble code {
  font-family: "JetBrains Mono", monospace; font-size: 0.84em;
  background: rgba(79,209,224,0.1); color: var(--cyan);
  padding: 1px 6px; border-radius: 3px;
}
.bubble .hint { color: var(--ink-dim); font-size: 0.82rem; }

/* blinking cursor while streaming */
.bubble.streaming::after {
  content: "▋"; color: var(--amber); animation: blink 1s steps(2) infinite; margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---- Chips ---- */
.chips {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 4px;
}
.chip {
  font-family: "JetBrains Mono", monospace; font-size: 0.72rem; letter-spacing: 0.5px;
  color: var(--ink-dim); background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-edge); border-radius: 100px;
  padding: 7px 13px; cursor: pointer; transition: all 0.18s ease;
  white-space: nowrap;
}
.chip:hover { color: var(--bg); background: var(--amber); border-color: var(--amber); box-shadow: 0 0 16px rgba(255,176,0,0.3); }

/* ---- Composer ---- */
.composer {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 16px 6px; padding: 6px 6px 6px 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--panel-edge); border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255,176,0,0.2), 0 0 22px -6px rgba(255,176,0,0.3); }
.prompt-glyph { font-family: "JetBrains Mono", monospace; color: var(--amber); font-size: 1.1rem; }
#input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--ink); font-family: "Sora", sans-serif; font-size: 0.95rem; padding: 10px 0;
}
#input::placeholder { color: var(--ink-dim); }
#send {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 6px; border: none; cursor: pointer;
  color: var(--bg); background: var(--amber);
  transition: transform 0.15s, box-shadow 0.2s; box-shadow: 0 0 18px -4px var(--amber);
}
#send:hover { transform: translateX(2px) translateY(-1px); }
#send:disabled { background: var(--panel-edge); color: var(--ink-dim); box-shadow: none; cursor: not-allowed; transform: none; }

.foot {
  text-align: center; font-family: "JetBrains Mono", monospace;
  font-size: 0.62rem; letter-spacing: 1px; color: var(--ink-dim);
  padding: 4px 0 14px; opacity: 0.7;
}

@media (max-width: 560px) {
  .title { display: none; }
  .msg { max-width: 100%; }
  .chip:nth-child(n+4) { display: none; }
}
