:root {
  --bg: #080909;
  --panel: #0f1112;
  --panel-line: #1f2224;
  --red: #e03131;
  --amber: #f2b705;
  --white: #eef1f3;
  --muted: #6b7074;
  --green: #35d07f;
  --font-display: "Space Grotesk", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-mono);
  min-height: 100vh;
  overflow-x: hidden;
}

#field {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.55;
  pointer-events: none;
}

.scanline {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.015) 0px,
    rgba(255, 255, 255, 0.015) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.hud-bar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--panel-line);
  backdrop-filter: blur(2px);
}

.hud-id {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(53, 208, 127, 0.6);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(53, 208, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0); }
}

.hud-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 3px;
  color: var(--white);
}
.hud-tag {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.hud-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.hud-meta .sep { color: var(--panel-line); }
#mode-badge {
  color: var(--amber);
  border: 1px solid var(--panel-line);
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 1px;
  font-size: 10px;
}

.deck {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cell-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 10px;
  font-family: var(--font-mono);
}
.cell-label .muted {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.cell-label.standalone { margin-bottom: 14px; }

.cell {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  position: relative;
}
.cell::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px;
  width: 14px; height: 14px;
  border-top: 1px solid var(--red);
  border-left: 1px solid var(--red);
}
.cell::after {
  content: "";
  position: absolute;
  bottom: -1px; right: -1px;
  width: 14px; height: 14px;
  border-bottom: 1px solid var(--red);
  border-right: 1px solid var(--red);
}

.hero-model {
  width: 100%;
  height: 340px;
  background: radial-gradient(ellipse at center, #15181a 0%, #0a0b0c 100%);
}
.mesh-caption {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.readout {
  font-size: 12px;
  line-height: 2.1;
  color: var(--white);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-line);
}
.readout .k { color: var(--muted); display: inline-block; width: 92px; }
.readout .v { color: var(--green); }

.mesh-modal-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 6, 6, 0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.mesh-modal-overlay[hidden] { display: none; }
.mesh-modal {
  padding: 20px; max-width: 560px; width: 100%;
}
.mesh-modal-close {
  position: absolute; top: 10px; right: 12px;
  background: transparent; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; line-height: 1;
}
.mesh-modal-close:hover { color: var(--red); }

.row-operate {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 18px;
}
.tasks-cell, .chat-cell { padding: 16px; display: flex; flex-direction: column; }

.tasks { overflow-y: auto; max-height: 420px; }
.task-section { margin-bottom: 14px; }
.task-section h4 {
  font-size: 10px; color: var(--muted); margin: 0 0 6px 0;
  text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
}
.task-item {
  display: flex; gap: 10px; padding: 5px 0;
  font-size: 12px; align-items: flex-start;
}
.task-item .tag {
  flex-shrink: 0; font-size: 10px; padding: 1px 5px; border-radius: 2px;
  font-weight: 600; letter-spacing: 0.5px; margin-top: 1px;
}
.task-item.done .tag { color: var(--muted); border: 1px solid var(--panel-line); }
.task-item:not(.done) .tag { color: var(--amber); border: 1px solid rgba(242,183,5,0.3); }
.task-item.done { opacity: 0.4; }
.task-item .t-title { color: var(--white); font-weight: 500; }
.task-item .t-text { color: var(--muted); display: block; font-size: 11px; margin-top: 1px; }

.chat-log {
  flex: 1; overflow-y: auto; min-height: 220px; max-height: 360px;
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px;
  padding-right: 4px;
}
.msg {
  font-size: 12.5px; line-height: 1.5; max-width: 92%;
  white-space: pre-wrap;
}
.msg .who {
  display: block; font-size: 10px; letter-spacing: 1px;
  margin-bottom: 3px; font-weight: 600;
}
.msg.friday { align-self: flex-start; color: var(--white); }
.msg.friday .who { color: var(--red); }
.msg.user { align-self: flex-end; color: var(--white); text-align: right; }
.msg.user .who { color: var(--amber); }
.msg.error { align-self: flex-start; color: #ff8a8a; }
.msg.error .who { color: var(--red); }
.msg.thinking .who { color: var(--muted); }
.msg.thinking { color: var(--muted); }
.cursor-blink { display: inline-block; animation: blink 1s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

.chat-form {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--panel-line); padding-top: 10px;
}
.prompt-glyph { color: var(--red); font-family: var(--font-mono); }
.chat-form input {
  flex: 1; background: transparent; border: none; color: var(--white);
  font-family: var(--font-mono); font-size: 12.5px; outline: none;
}
.chat-form input::placeholder { color: var(--muted); }
.chat-form button {
  background: transparent; border: 1px solid var(--panel-line); color: var(--amber);
  border-radius: 3px; padding: 4px 10px; cursor: pointer; font-family: var(--font-mono);
}
.chat-form button:hover { border-color: var(--amber); }
.chat-form button:disabled { color: var(--muted); border-color: var(--panel-line); cursor: not-allowed; }

.projects { display: flex; flex-direction: column; border: 1px solid var(--panel-line); }
.project-row {
  display: grid;
  grid-template-columns: 180px 1fr 140px;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-line);
  background: var(--panel);
  align-items: start;
}
.project-row:last-child { border-bottom: none; }
.project-row:hover { background: #141618; }
.project-row.has-mesh { cursor: pointer; }
.project-row.has-mesh .p-name::after {
  content: " \25CF";
  color: var(--red);
  font-size: 9px;
  vertical-align: super;
}
.p-name { font-family: var(--font-display); font-weight: 500; font-size: 14px; }
.p-status {
  font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
  display: inline-block; margin-top: 4px; color: var(--muted);
}
.p-status.active { color: var(--green); }
.p-status.prototype { color: var(--amber); }
.p-gate {
  display: block; font-size: 9px; letter-spacing: 0.5px;
  margin-top: 6px; padding: 1px 6px; border-radius: 2px; width: fit-content;
}
.p-gate.locked { color: var(--muted); border: 1px solid var(--panel-line); }
.p-gate.unlocked { color: var(--green); border: 1px solid rgba(53,208,127,0.3); }
.p-summary { font-size: 12px; color: var(--muted); line-height: 1.5; }
.p-summary .tag {
  display: inline-block; font-size: 9px; color: var(--muted);
  border: 1px solid var(--panel-line); padding: 1px 6px; border-radius: 2px;
  margin: 6px 6px 0 0;
}
.p-links { display: flex; flex-direction: column; gap: 4px; text-align: right; }
.p-links a { color: var(--amber); font-size: 11px; text-decoration: none; }
.p-links a:hover { text-decoration: underline; }

.admin-btn {
  position: fixed; bottom: 18px; right: 18px; z-index: 30;
  background: var(--panel); border: 1px solid var(--panel-line); color: var(--muted);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px;
  padding: 8px 14px; border-radius: 4px; cursor: pointer;
}
.admin-btn:hover { color: var(--amber); border-color: var(--amber); }
.admin-btn.is-admin { color: var(--green); border-color: rgba(53,208,127,0.4); }

.admin-modal-overlay {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(5, 6, 6, 0.82);
  display: flex; align-items: center; justify-content: center;
}
.admin-modal-overlay[hidden] { display: none; }
.admin-modal {
  padding: 24px 28px; text-align: center; width: 260px;
}
.admin-modal h3 {
  font-family: var(--font-display); font-size: 15px; letter-spacing: 1px;
  margin: 0 0 4px 0;
}
.admin-modal p { color: var(--muted); font-size: 11px; margin: 0 0 16px 0; }
.admin-modal input {
  background: #0a0b0c; border: 1px solid var(--panel-line); color: var(--white);
  font-family: var(--font-mono); padding: 8px 12px; font-size: 14px;
  letter-spacing: 4px; text-align: center; width: 140px; outline: none;
}
.admin-modal input:focus { border-color: var(--amber); }
.admin-modal button {
  display: block; margin: 14px auto 0; background: transparent;
  border: 1px solid var(--panel-line); color: var(--amber); padding: 7px 18px;
  font-family: var(--font-mono); cursor: pointer; border-radius: 3px;
}
.admin-modal button:hover { border-color: var(--amber); }
.admin-modal .err { color: var(--red); font-size: 11px; margin-top: 8px; min-height: 14px; }

@media (max-width: 860px) {
  .row-operate { grid-template-columns: 1fr; }
  .project-row { grid-template-columns: 1fr; }
  .p-links { text-align: left; }
}
