:root {
  --bg: #08111f;
  --bg-soft: #10203a;
  --card: rgba(8, 17, 31, 0.74);
  --card-strong: rgba(10, 23, 42, 0.92);
  --line: rgba(196, 221, 255, 0.14);
  --text: #eef5ff;
  --muted: #a7b7d1;
  --accent: #5dd0ff;
  --accent-strong: #88f0ba;
  --danger: #ff9494;
  --shadow: 0 32px 80px rgba(0, 0, 0, 0.34);
  --font-display: "Segoe UI Variable Display", "Trebuchet MS", "Gill Sans", sans-serif;
  --font-body: "Segoe UI Variable Text", "Verdana", "Tahoma", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(93, 208, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(136, 240, 186, 0.16), transparent 26%),
    linear-gradient(180deg, #06101d 0%, #0c1730 44%, #091120 100%);
}

.site-body { position: relative; overflow-x: hidden; }

.ambient {
  position: fixed; width: 28rem; height: 28rem;
  border-radius: 999px; filter: blur(48px); opacity: 0.4; pointer-events: none;
}
.ambient-left { top: -8rem; left: -10rem; background: rgba(93, 208, 255, 0.3); }
.ambient-right { right: -8rem; bottom: -10rem; background: rgba(136, 240, 186, 0.26); }

.shell, .admin-shell {
  position: relative; z-index: 1;
  max-width: 1200px; margin: 0 auto; padding: 32px 20px 64px;
}

.hero-card, .interview-panel, .voice-panel, .summary-panel, .admin-login-card, .admin-panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 32, 58, 0.78), rgba(8, 17, 31, 0.92));
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
}

.hero-card {
  display: grid; grid-template-columns: 1.15fr 0.85fr;
  gap: 28px; padding: 32px; border-radius: 32px; align-items: center;
}

.hero-copy h1, .admin-login-card h1, .admin-header h1 {
  margin: 0 0 16px; font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 4.4rem); line-height: 0.98; letter-spacing: -0.04em;
}

.lede { max-width: 64ch; color: var(--muted); font-size: 1rem; line-height: 1.6; }

.eyebrow {
  margin: 0 0 12px; color: var(--accent-strong);
  text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.76rem;
}

.start-form { margin-top: 24px; }

.auth-step { margin-bottom: 8px; }
.auth-error { color: var(--danger); font-size: 0.88rem; margin-top: 8px; }
.auth-hint { color: var(--muted); font-size: 0.92rem; margin: 0 0 12px; }
.auth-greeting { font-size: 1.15rem; margin-bottom: 20px; }
.auth-greeting strong { color: var(--accent); }

.field { display: grid; gap: 10px; margin-bottom: 16px; }
.field span, .field-label { color: var(--muted); font-size: 0.92rem; }
.field-label { display: block; margin-bottom: 8px; }

input, textarea, button, a { font: inherit; }

input, textarea {
  width: 100%; border: 1px solid rgba(196, 221, 255, 0.18); border-radius: 18px;
  background: rgba(7, 14, 27, 0.7); color: var(--text); padding: 15px 18px;
  outline: none; transition: border-color 180ms ease;
}
input:focus, textarea:focus { border-color: rgba(93, 208, 255, 0.8); }
textarea { resize: vertical; }

/* --- Mode selector --- */
.mode-selector { margin-bottom: 20px; }

.mode-buttons {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}

.mode-button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; border-radius: 18px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  color: var(--muted); cursor: pointer;
  transition: all 200ms ease;
}
.mode-button:hover { border-color: rgba(93, 208, 255, 0.4); color: var(--text); }
.mode-button.is-active {
  border-color: rgba(93, 208, 255, 0.8); background: rgba(93, 208, 255, 0.12);
  color: var(--text); font-weight: 600;
}

.actions-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.primary-button, .secondary-button, .ghost-button, .as-link {
  display: inline-flex; justify-content: center; align-items: center;
  border-radius: 999px; padding: 14px 22px; border: 1px solid transparent;
  text-decoration: none; cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-button, .as-link {
  background: linear-gradient(135deg, var(--accent) 0%, #a1f7d3 100%);
  color: #03111f; font-weight: 700;
}

.secondary-button, .ghost-button {
  border-color: rgba(196, 221, 255, 0.18); background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.danger-button {
  display: inline-flex; justify-content: center; align-items: center;
  border-radius: 999px; padding: 14px 22px;
  border: 1px solid rgba(255, 148, 148, 0.45); background: rgba(255, 148, 148, 0.12);
  color: #ffdede; cursor: pointer;
}

.ghost-link { color: var(--text); text-decoration: none; }

.primary-button:hover, .secondary-button:hover, .ghost-button:hover,
.danger-button:hover, .as-link:hover, .ghost-link:hover { transform: translateY(-1px); }

.primary-button:disabled, .secondary-button:disabled {
  opacity: 0.4; cursor: not-allowed; transform: none !important;
}

/* --- Hero orb --- */
.hero-visual { display: grid; justify-items: center; gap: 22px; }

.voice-orb {
  position: relative; width: min(22rem, 70vw); aspect-ratio: 1;
  display: grid; place-items: center;
}

.voice-orb-core {
  width: 40%; aspect-ratio: 1; border-radius: 999px;
  background: radial-gradient(circle at 40% 40%, #ff4444 0%, #cc0000 35%, #880000 60%, #220000 100%);
  box-shadow: 0 0 80px rgba(255, 0, 0, 0.6), 0 0 160px rgba(200, 0, 0, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.4);
  animation: pulse 4s ease-in-out infinite;
}

.voice-ring {
  position: absolute; inset: 16%; border-radius: 999px;
  border: 1px solid rgba(255, 0, 0, 0.18);
}
.voice-ring-a { animation: ring 4.5s linear infinite; }
.voice-ring-b { inset: 6%; animation: ring 6.2s linear infinite reverse; }
.voice-ring-c { inset: -2%; border-color: rgba(255, 0, 0, 0.1); animation: ring 8s linear infinite; }

/* ===== TEXT MODE ===== */
.interview-panel, .summary-panel, .admin-login-card, .admin-panel {
  margin-top: 26px; border-radius: 30px; padding: 24px;
}

.panel-top, .admin-header, .detail-header, .sidebar-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
}
.panel-top h2, .detail-header h2, .sidebar-head h2 {
  margin: 4px 0 0; font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2.4rem);
}
.panel-meta { display: flex; gap: 12px; }

.status-chip, .meta-item {
  border-radius: 20px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04); padding: 14px 16px;
}
.status-chip strong, .meta-item strong { display: block; margin-top: 4px; font-size: 1rem; }
.status-label, .meta-item span, .detail-meta { color: var(--muted); font-size: 0.86rem; }

.progress-track {
  margin: 22px 0; height: 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 220ms ease;
}

.transcript, .detail-transcript { display: grid; gap: 14px; }
.transcript { margin-bottom: 18px; }

.bubble {
  max-width: 80%; padding: 16px 18px; border-radius: 22px;
  border: 1px solid var(--line); line-height: 1.55;
}
.bubble.assistant { background: rgba(255, 255, 255, 0.05); justify-self: start; }
.bubble.user { background: rgba(93, 208, 255, 0.12); justify-self: end; }
.bubble-meta {
  display: block; margin-bottom: 6px; color: var(--muted);
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
}

/* Text composer */
.text-composer {
  display: flex; gap: 10px; align-items: end;
  border: 1px solid var(--line); border-radius: 22px;
  background: rgba(255, 255, 255, 0.035); padding: 12px;
}
.text-composer textarea {
  flex: 1; border-radius: 14px; padding: 12px 14px; resize: none;
  min-height: 44px;
}
.text-composer .primary-button { padding: 12px 20px; white-space: nowrap; }
.text-composer .secondary-button { padding: 12px 16px; white-space: nowrap; font-size: 0.9rem; }

/* ===== VOICE MODE ===== */
.voice-panel {
  margin-top: 26px; border-radius: 30px; padding: 0; overflow: hidden;
}

.voice-stage {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 80vh; padding: 40px 20px;
  position: relative;
}

.voice-orb-large {
  position: relative; width: min(20rem, 60vw); aspect-ratio: 1;
  display: grid; place-items: center; margin-bottom: 32px;
}

.voice-orb-large .voice-orb-core {
  width: 45%; transition: all 400ms ease;
  background: radial-gradient(circle at 40% 40%, #ff4444 0%, #cc0000 35%, #880000 60%, #220000 100%);
  box-shadow: 0 0 80px rgba(255, 0, 0, 0.6), 0 0 160px rgba(200, 0, 0, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.4);
}

/* Voice phases: orb reacts */
[data-phase="idle"] .voice-orb-core {
  box-shadow: 0 0 80px rgba(255, 0, 0, 0.5), 0 0 160px rgba(200, 0, 0, 0.2);
  animation: pulse 4s ease-in-out infinite;
}

[data-phase="recording"] .voice-orb-core {
  background: radial-gradient(circle at 35% 35%, #ffffff, #ffcece 28%, #ff8888 60%, #7a2020 100%);
  box-shadow: 0 0 80px rgba(255, 148, 148, 0.6);
  animation: pulse 1.2s ease-in-out infinite;
}
[data-phase="recording"] .voice-ring {
  border-color: rgba(255, 148, 148, 0.4);
}

[data-phase="speaking"] .voice-orb-core {
  background: radial-gradient(circle at 40% 40%, #ff2222 0%, #dd0000 30%, #990000 55%, #330000 100%);
  box-shadow: 0 0 100px rgba(255, 0, 0, 0.8), 0 0 200px rgba(200, 0, 0, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

[data-phase="processing"] .voice-orb-core,
[data-phase="transcribing"] .voice-orb-core {
  box-shadow: 0 0 40px rgba(167, 183, 209, 0.4);
  animation: pulse 2.5s ease-in-out infinite;
  opacity: 0.7;
}

.voice-status-large {
  color: var(--muted); font-size: 1.1rem;
  text-align: center; margin-bottom: 28px;
  min-height: 1.5em;
}

.voice-controls {
  display: flex; gap: 12px; align-items: center; margin-bottom: 24px;
}

.mic-button-large {
  width: 72px; height: 72px; border-radius: 999px;
  border: 2px solid rgba(93, 208, 255, 0.5);
  background: rgba(93, 208, 255, 0.12);
  color: var(--text); cursor: pointer;
  display: grid; place-items: center;
  transition: all 200ms ease;
}
.mic-button-large:hover { transform: scale(1.05); border-color: var(--accent); }

.mic-button-large.is-recording {
  border-color: rgba(255, 148, 148, 0.8);
  background: rgba(255, 148, 148, 0.2);
  animation: pulseBtn 1.2s ease-in-out infinite;
}

.mic-button-large:disabled {
  opacity: 0.3; cursor: not-allowed; transform: none !important;
  animation: none !important;
}

.voice-secondary {
  border: 1px solid rgba(196, 221, 255, 0.18);
  background: rgba(255, 255, 255, 0.04); color: var(--muted);
  border-radius: 999px; padding: 10px 18px; cursor: pointer;
  font-size: 0.86rem; transition: all 180ms ease;
}
.voice-secondary:hover { color: var(--text); border-color: rgba(196, 221, 255, 0.35); }

.voice-meta {
  display: flex; gap: 20px; color: var(--muted); font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* ===== Favorites survey ===== */
.favorites-panel {
  margin-top: 26px; border-radius: 30px; padding: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 32, 58, 0.78), rgba(8, 17, 31, 0.92));
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.favorites-header { margin-bottom: 24px; }
.favorites-header h2 {
  margin: 0 0 8px; font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2.4rem);
}
.favorites-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 24px;
}
.favorites-group h3 { margin: 0 0 10px; font-size: 1rem; color: var(--accent); }
.favorites-group input {
  width: 100%; margin-bottom: 8px;
  border-radius: 14px; padding: 10px 14px; font-size: 0.92rem;
}
.favorites-footer {
  display: flex; justify-content: center; gap: 12px;
}

@media (max-width: 720px) {
  .favorites-grid { grid-template-columns: 1fr; }
}

/* ===== Mini-games ===== */
@font-face {
  font-family: "Pixel";
  src: local("Courier New"), local("Consolas"), local("monospace");
}
.minigame-panel {
  margin-top: 26px; border-radius: 30px; padding: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 32, 58, 0.78), rgba(8, 17, 31, 0.92));
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
  display: flex; flex-direction: column; align-items: center;
}
.minigame-header { text-align: center; margin-bottom: 16px; width: 100%; }
.pixel-title {
  font-family: "Courier New", "Consolas", monospace;
  font-size: clamp(1.3rem, 3vw, 2rem); margin: 0;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}
.pixel-text { font-family: "Courier New", "Consolas", monospace; font-size: 0.9rem; }
.pixel-desc {
  font-family: "Courier New", "Consolas", monospace;
  font-size: 0.92rem; color: var(--muted); text-align: center;
  max-width: 420px; margin: 0 auto 16px; line-height: 1.5;
}
.pixel-btn {
  font-family: "Courier New", "Consolas", monospace !important;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.minigame-panel canvas {
  image-rendering: pixelated; image-rendering: crisp-edges;
  border: 2px solid rgba(255, 255, 255, 0.1); border-radius: 8px;
  background: #111; max-width: 100%; height: auto;
}
.minigame-ui {
  margin-top: 20px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.dictator-slider-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
}
.dictator-slider-row span { min-width: 80px; text-align: right; }
.pixel-slider {
  flex: 1; accent-color: #ff4444; height: 8px; cursor: pointer;
}
.dictator-amounts {
  display: flex; justify-content: space-between; width: 100%;
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255,255,255,0.03);
}
.dictator-amounts strong { color: #ff8888; }
.trolley-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ===== BFI-2 Test ===== */
.bfi2-panel {
  margin-top: 26px; border-radius: 30px; padding: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 32, 58, 0.78), rgba(8, 17, 31, 0.92));
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.bfi2-header { margin-bottom: 24px; }
.bfi2-header h2 {
  margin: 0 0 8px; font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2.4rem);
}
.bfi2-questions { display: grid; gap: 16px; margin-bottom: 24px; }
.bfi2-item {
  border: 1px solid var(--line); border-radius: 18px;
  background: rgba(255, 255, 255, 0.03); padding: 16px 18px;
  transition: border-color 200ms ease;
}
.bfi2-item.answered { border-color: rgba(93, 208, 255, 0.3); }
.bfi2-item-text {
  font-size: 1rem; margin-bottom: 10px; line-height: 1.5;
}
.bfi2-item-text .bfi2-num {
  color: var(--accent); font-weight: 700; margin-right: 6px;
}
.bfi2-scale {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.bfi2-option {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 4px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  color: var(--muted); font-size: 0.82rem; text-align: center;
  cursor: pointer; transition: all 180ms ease;
  line-height: 1.25;
}
@media (max-width: 600px) {
  .bfi2-scale {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .bfi2-option {
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    justify-content: flex-start;
  }
}
.bfi2-option:hover { border-color: rgba(93, 208, 255, 0.4); color: var(--text); }
.bfi2-option.selected {
  border-color: rgba(93, 208, 255, 0.8); background: rgba(93, 208, 255, 0.15);
  color: var(--text); font-weight: 600;
}
.bfi2-option input { display: none; }
.bfi2-footer {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.bfi2-results {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-top: 16px;
}
.bfi2-result-card {
  border: 1px solid var(--line); border-radius: 18px;
  background: rgba(255, 255, 255, 0.04); padding: 16px;
  text-align: center;
}
.bfi2-result-card h4 { margin: 0 0 8px; color: var(--accent); }
.bfi2-result-score { font-size: 2rem; font-weight: 700; }
.bfi2-result-bar {
  margin-top: 8px; height: 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.bfi2-result-fill {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 400ms ease;
}

/* ===== Summary ===== */
.summary-panel { display: grid; gap: 16px; margin-top: 26px; border-radius: 30px; padding: 24px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.summary-card, .detail-summary, .json-box, .admin-sidebar, .admin-detail {
  border: 1px solid var(--line); border-radius: 24px;
  background: rgba(255, 255, 255, 0.04); padding: 18px;
  min-width: 0; overflow: hidden;
}
.summary-card h3, .detail-summary h3 { margin-top: 0; }
.summary-list { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }

.summary-actions {
  display: flex; justify-content: center; gap: 12px; padding-top: 8px;
}
.summary-hint {
  text-align: center; color: var(--muted); font-size: 0.88rem; margin-top: 4px;
}

.hidden { display: none !important; }

/* ===== Admin ===== */
.admin-panel { overflow: hidden; }
.admin-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; margin-top: 18px; min-width: 0; }
.interview-list { display: grid; gap: 10px; margin-top: 16px; }
.interview-item {
  width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 18px;
  background: rgba(7, 14, 27, 0.64); color: var(--text); padding: 14px; cursor: pointer;
}
.interview-item.is-active { border-color: rgba(93, 208, 255, 0.8); background: rgba(93, 208, 255, 0.12); }
.interview-item strong, .detail-summary strong { display: block; margin-bottom: 6px; }
.interview-item span { display: block; color: var(--muted); font-size: 0.86rem; }
.detail-summary { margin: 18px 0; }
.detail-transcript .bubble { max-width: 100%; }
.json-box pre { white-space: pre-wrap; word-break: break-word; color: var(--muted); }

/* ===== Admin favorites ===== */
.fav-admin-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 12px;
}
.fav-admin-grid strong { color: var(--accent); }

/* ===== Admin BFI-2 table ===== */
.bfi2-table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
}
.bfi2-table th, .bfi2-table td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
}
.bfi2-table th { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; }
.bfi2-admin-bar {
  height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.bfi2-admin-fill {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

/* ===== Animations ===== */
@keyframes pulse {
  0%, 100% { transform: scale(0.96); }
  50% { transform: scale(1.04); }
}
@keyframes ring {
  from { transform: rotate(0deg) scale(0.96); }
  to { transform: rotate(360deg) scale(1.04); }
}
@keyframes wave {
  0%, 100% { height: 8px; }
  50% { height: 28px; }
}
@keyframes waveSlow {
  0%, 100% { height: 6px; opacity: 0.5; }
  50% { height: 18px; opacity: 1; }
}
@keyframes pulseBtn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 148, 148, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(255, 148, 148, 0); }
}

/* ===== Responsive ===== */
@media (max-width: 920px) {
  .hero-card, .admin-layout { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell, .admin-shell { padding: 20px 14px 48px; }
  .hero-card, .interview-panel, .voice-panel, .summary-panel, .admin-login-card, .admin-panel {
    padding: 18px; border-radius: 24px;
  }
  .panel-top, .admin-header, .detail-header, .sidebar-head { flex-direction: column; align-items: stretch; }
  .bubble { max-width: 100%; }
  .voice-stage { min-height: 70vh; }
  .text-composer { flex-direction: column; }
  .text-composer textarea { width: 100%; }
  .text-composer .primary-button,
  .text-composer .secondary-button { width: 100%; }
  .admin-panel { padding: 14px; }
  .admin-sidebar, .admin-detail { padding: 14px; border-radius: 18px; }
  .interview-item { padding: 12px; border-radius: 14px; word-break: break-word; }
  .detail-header { gap: 12px; }
  .detail-header .actions-row { flex-direction: column; }
  .detail-header .actions-row > * { width: 100%; text-align: center; }
  .fav-admin-grid { grid-template-columns: 1fr; }
  .bfi2-table th, .bfi2-table td { padding: 8px 6px; font-size: 0.82rem; }
  .json-box pre { font-size: 0.72rem; }
}
