:root {
  --bg: #090d14;
  --surface: #121a27;
  --surface-2: #182233;
  --border: rgba(148, 179, 214, 0.16);
  --text: #e8f1fb;
  --muted: #8ea2b8;
  --cyan: #38e8ff;
  --accent: #0ea5e9;
  --green: #34d399;
  --amber: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(56, 232, 255, 0.1);
  color: var(--cyan);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.85em;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.eyebrow {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: var(--cyan);
}

.back-link {
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.86rem;
  margin-top: 4px;
}
.back-link:hover { color: var(--cyan); }

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.bolt { color: var(--cyan); }
.top-actions { display: flex; gap: 10px; align-items: center; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 0.15s, background 0.15s;
}
.btn.small { padding: 6px 11px; font-size: 0.8rem; border-radius: 8px; }
.btn.full { width: 100%; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }
.btn.danger { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.35); color: #fca5a5; }
.btn.danger:hover { background: rgba(248, 113, 113, 0.24); }
.btn.warn { background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, 0.35); color: #fde68a; }

.badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-block;
}
.badge.ok { background: rgba(52, 211, 153, 0.14); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.35); }
.badge.warn { background: rgba(251, 191, 36, 0.15); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.35); }
.badge.muted { background: rgba(255, 255, 255, 0.06); color: var(--muted); border: 1px solid var(--border); }

/* Form */
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; font-weight: 600; color: #cfe0f4; }
.field input, .field textarea {
  width: 100%;
  background: #0b111c;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 12px;
  outline: none;
}
.field input:focus, .field textarea:focus {
  border-color: var(--cyan);
}

.alert.error {
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  font-size: 0.86rem;
}

/* Stages List */
.stages-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.stage-main { flex: 1; min-width: 260px; }
.stage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stage-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  background: rgba(56, 232, 255, 0.14);
  color: var(--cyan);
  padding: 3px 8px;
  border-radius: 7px;
  font-weight: 700;
}
.stage-title { font-weight: 700; font-size: 1.04rem; }
.stage-prompt {
  color: #c8d9ec;
  white-space: pre-wrap;
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.answer-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.answer-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: #86efac;
  padding: 2px 8px;
  border-radius: 6px;
}
.stage-sub { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }
.stage-actions { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }

/* Table */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}
tr:last-child td { border-bottom: none; }
.action-group { display: flex; gap: 6px; flex-wrap: wrap; }
.play-link {
  color: var(--cyan);
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}
.play-link:hover { text-decoration: underline; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.modal-card.wide { max-width: 720px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.icon-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.transcript-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 4px;
}
.t-msg {
  padding: 10px 13px;
  border-radius: 10px;
  max-width: 85%;
  white-space: pre-wrap;
  font-size: 0.88rem;
}
.t-msg.tesla {
  align-self: flex-start;
  background: #182533;
  border: 1px solid rgba(56, 232, 255, 0.2);
}
.t-msg.player {
  align-self: flex-end;
  background: #2b5278;
}
.t-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 90;
  background: #162436;
  border: 1px solid var(--cyan);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
