:root {
  color-scheme: dark;
  --bg: #05090c;
  --panel: #0b1217;
  --panel-2: #101a20;
  --line: rgba(255, 255, 255, 0.1);
  --muted: #8ea0a8;
  --text: #f5f8f6;
  --lime: #bcff55;
  --mint: #55f2c2;
  --coral: #ff765d;
  --cyan: #73d5ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1060px;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, rgba(66, 164, 131, 0.12), transparent 28%),
    radial-gradient(circle at 88% 78%, rgba(255, 118, 93, 0.09), transparent 28%),
    var(--bg);
  color: var(--text);
}

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

.app-shell {
  width: 100vw;
  min-height: 100vh;
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  min-height: 66px;
  display: grid;
  grid-template-columns: 1fr minmax(360px, 1.25fr) 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0 2px 14px;
}

.brand-lockup, .top-actions, .lesson-title, .stage-head, .debate-head,
.message-meta, .director-bar, .settings-head, .settings-foot, .avatar-upload-row {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 12px; }
.brand-mark { width: 39px; height: 39px; position: relative; display: flex; gap: 3px; align-items: flex-end; justify-content: center; padding-bottom: 7px; border: 1px solid rgba(188,255,85,.35); border-radius: 12px; background: rgba(188,255,85,.08); }
.brand-mark span { width: 5px; border-radius: 5px; background: var(--lime); box-shadow: 0 0 12px rgba(188,255,85,.55); }
.brand-mark span:nth-child(1) { height: 12px; }
.brand-mark span:nth-child(2) { height: 21px; }
.brand-mark span:nth-child(3) { height: 16px; }
.eyebrow, .section-kicker { margin: 0 0 3px; color: var(--lime); font: 650 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; }
.brand-lockup h1 { margin: 0; font-size: 19px; letter-spacing: .04em; }

.lesson-title { justify-self: center; gap: 10px; }
.lesson-title span { border: 1px solid rgba(255,255,255,.16); color: #bdc8cd; border-radius: 999px; padding: 5px 10px; font-size: 11px; }
.lesson-title strong { font-size: 15px; font-weight: 600; letter-spacing: .05em; }

.top-actions { justify-self: end; gap: 8px; }
.status-pill { height: 34px; padding: 0 12px; display: flex; align-items: center; gap: 8px; color: #c7d0d3; border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 999px; font-size: 11px; }
.status-pill i, .live-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 12px var(--lime); }
.status-pill.live i { background: var(--mint); }
.icon-btn { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 10px; cursor: pointer; transition: .2s ease; }
.icon-btn:hover { background: rgba(255,255,255,.09); transform: translateY(-1px); }
.icon-btn svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.classroom-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(470px, 1.05fr) minmax(540px, .95fr);
  gap: 16px;
}

.avatar-stage, .debate-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(10, 17, 22, .92);
  box-shadow: var(--shadow);
}

.avatar-stage {
  isolation: isolate;
  min-height: 600px;
  background:
    linear-gradient(180deg, rgba(5,10,12,.05), rgba(5,10,12,.44)),
    radial-gradient(circle at 50% 45%, rgba(36, 95, 76, .35), transparent 43%),
    #030607;
}

.stage-noise { position: absolute; inset: 0; z-index: -1; opacity: .22; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 34px 34px; mask-image: linear-gradient(to bottom, #000, transparent 85%); }
.stage-head { position: absolute; z-index: 8; top: 24px; left: 27px; right: 27px; justify-content: space-between; }
.live-dot { display: inline-flex; align-items: center; gap: 8px; color: #9aabb2; font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.stage-head h2 { margin: 7px 0 0; font-size: 18px; }
.voice-viz { height: 30px; display: flex; align-items: center; gap: 3px; opacity: .38; }
.voice-viz span { width: 3px; height: 6px; background: var(--mint); border-radius: 4px; }
.speaking .voice-viz { opacity: 1; }
.speaking .voice-viz span { animation: voice 560ms ease-in-out infinite alternate; }
.speaking .voice-viz span:nth-child(2) { animation-delay: 90ms; }
.speaking .voice-viz span:nth-child(3) { animation-delay: 180ms; }
.speaking .voice-viz span:nth-child(4) { animation-delay: 270ms; }
.speaking .voice-viz span:nth-child(5) { animation-delay: 360ms; }
@keyframes voice { to { height: 25px; } }

.avatar-glow { position: absolute; width: 390px; height: 390px; top: 17%; left: 50%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle, rgba(85,242,194,.22), rgba(48,104,84,.08) 45%, transparent 70%); filter: blur(5px); transition: opacity .3s ease; }
.avatar-orbit { position: absolute; left: 50%; top: 42%; border: 1px solid rgba(85,242,194,.19); border-radius: 50%; transform: translate(-50%,-50%); }
.orbit-one { width: 430px; height: 430px; animation: orbit-pulse 4s ease-in-out infinite; }
.orbit-two { width: 520px; height: 520px; border-style: dashed; opacity: .4; animation: orbit-spin 30s linear infinite; }
@keyframes orbit-pulse { 50% { width: 454px; height: 454px; opacity: .55; } }
@keyframes orbit-spin { to { transform: translate(-50%,-50%) rotate(360deg); } }
.unity-avatar-shell { position: absolute; z-index: 3; inset: 0; overflow: hidden; }
.unity-avatar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; background: #030607; transition: opacity .35s ease; }
.avatar-image { position: absolute; z-index: 1; left: 50%; top: 5%; width: min(63%, 440px); height: 83%; object-fit: cover; object-position: center 24%; transform: translateX(-50%); filter: saturate(.95) contrast(1.04); transition: opacity .3s ease; }
.avatar-loading { position: absolute; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; max-width: 82%; padding: 10px 14px; color: #bfd0d4; border: 1px solid rgba(85,242,194,.22); border-radius: 999px; background: rgba(5,12,15,.82); backdrop-filter: blur(14px); font-size: 11px; transition: opacity .25s ease; }
.avatar-loading-ring { width: 15px; height: 15px; flex: 0 0 auto; border: 2px solid rgba(85,242,194,.2); border-top-color: var(--mint); border-radius: 50%; animation: avatar-loader-spin .8s linear infinite; }
.avatar-ready .unity-avatar-canvas { opacity: 1; }
.avatar-ready .avatar-image, .avatar-ready .avatar-loading { opacity: 0; pointer-events: none; }
.avatar-failed .avatar-loading-ring { animation: none; border-color: var(--coral); }
.avatar-failed .avatar-loading { color: #ffd7d0; border-color: rgba(255,118,93,.32); }
@keyframes avatar-loader-spin { to { transform: rotate(360deg); } }
.avatar-floor { position: absolute; z-index: 4; left: 15%; right: 15%; bottom: 20%; height: 90px; background: radial-gradient(ellipse, rgba(85,242,194,.13), transparent 67%); filter: blur(9px); }

.stance-card { position: absolute; z-index: 7; left: 26px; top: 102px; width: 175px; padding: 12px 14px; border-left: 2px solid var(--lime); border-radius: 0 10px 10px 0; background: rgba(5,10,12,.62); backdrop-filter: blur(12px); }
.stance-card span { display: block; color: #819299; font-size: 9px; letter-spacing: .13em; text-transform: uppercase; margin-bottom: 5px; }
.stance-card strong { display: block; font-size: 11px; line-height: 1.55; }

.subtitle-card { position: absolute; z-index: 9; left: 27px; right: 27px; bottom: 24px; min-height: 97px; padding: 16px 19px 15px; border: 1px solid rgba(255,255,255,.15); border-radius: 15px; background: linear-gradient(115deg, rgba(10,18,22,.94), rgba(16,29,31,.86)); backdrop-filter: blur(20px); box-shadow: 0 12px 35px rgba(0,0,0,.38); }
.subtitle-card::before { content:""; position:absolute; left:0; top:18px; bottom:18px; width:3px; background: var(--lime); border-radius: 4px; box-shadow: 0 0 16px rgba(188,255,85,.4); }
.speaker-label { color: var(--lime); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.subtitle-card p { margin: 7px 0 0; font-size: clamp(15px, 1.22vw, 19px); font-weight: 560; line-height: 1.65; letter-spacing: .02em; }

.debate-panel { min-height: 600px; display: flex; flex-direction: column; padding: 22px; background: linear-gradient(155deg, rgba(14,22,27,.97), rgba(7,12,15,.97)); }
.debate-head { justify-content: space-between; }
.debate-head h2, .settings-head h2 { margin: 0; font-size: 21px; }
.round-timer { display: flex; align-items: baseline; gap: 7px; padding: 8px 11px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 10px; }
.round-timer span { color: var(--muted); font-size: 10px; }
.round-timer strong { font: 600 16px/1 ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.round-timer.running strong { color: var(--lime); }

.topic-card { margin-top: 14px; padding: 14px 15px 12px; border: 1px solid rgba(188,255,85,.15); background: linear-gradient(110deg, rgba(188,255,85,.075), rgba(255,255,255,.025)); border-radius: 13px; }
.topic-index { color: var(--lime); font: 650 9px ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.topic-card h3 { margin: 7px 0 11px; max-width: 92%; font-size: 14px; line-height: 1.5; }
.stance-switch { display: flex; gap: 6px; }
.stance-switch button { padding: 6px 10px; color: #91a0a6; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 10px; cursor: pointer; }
.stance-switch button.active { color: #10170e; border-color: var(--lime); background: var(--lime); font-weight: 700; }

.conversation { flex: 1; min-height: 145px; margin: 13px -4px 8px 0; padding-right: 7px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.message { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 9px 0 11px; }
.message + .message { border-top: 1px solid rgba(255,255,255,.06); }
.message-avatar { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(188,255,85,.24); color: var(--lime); background: rgba(188,255,85,.08); border-radius: 9px; font-size: 9px; font-weight: 800; }
.student-message .message-avatar { color: #101416; border-color: var(--coral); background: var(--coral); }
.message-meta { gap: 8px; margin-bottom: 4px; }
.message-meta strong { font-size: 11px; }
.message-meta span { color: #69787e; font-size: 9px; }
.message p { margin: 0; color: #cfdbde; font-size: 12px; line-height: 1.62; }
.message.thinking p { color: #7e9097; }
.thinking-dots span { display: inline-block; width: 4px; height: 4px; margin-left: 3px; border-radius: 50%; background: var(--lime); animation: dots .8s infinite alternate; }
.thinking-dots span:nth-child(2) { animation-delay: .18s; }
.thinking-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes dots { to { opacity:.25; transform:translateY(-3px); } }

.quick-prompts { display: flex; gap: 6px; overflow: hidden; margin-bottom: 9px; }
.quick-prompts button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 7px 9px; color: #8fa0a7; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.025); cursor: pointer; font-size: 9px; transition: .2s; }
.quick-prompts button:hover { color: var(--text); border-color: rgba(188,255,85,.28); background: rgba(188,255,85,.06); }

.ask-box { display: grid; grid-template-columns: 42px 1fr auto; gap: 8px; align-items: center; padding: 7px; border: 1px solid rgba(255,255,255,.14); border-radius: 13px; background: rgba(3,7,9,.6); transition: .2s; }
.ask-box:focus-within { border-color: rgba(188,255,85,.38); box-shadow: 0 0 0 3px rgba(188,255,85,.04); }
.mic-btn { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; background: rgba(255,255,255,.05); cursor: pointer; }
.mic-btn svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.mic-btn.listening { color: #0b1113; background: var(--coral); border-color: var(--coral); animation: mic-pulse 1.2s infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 7px rgba(255,118,93,.12); } }
.ask-box textarea { width: 100%; max-height: 58px; resize: none; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; line-height: 1.45; }
.ask-box textarea::placeholder { color: #66777e; }
.send-btn { height: 40px; display: flex; align-items: center; gap: 7px; padding: 0 14px; border: 0; border-radius: 9px; color: #11160c; background: var(--lime); font-size: 11px; font-weight: 800; cursor: pointer; }
.send-btn:disabled { opacity: .45; cursor: wait; }
.send-btn svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.director-bar { gap: 7px; margin-top: 10px; }
.director-bar button { flex: 1; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.035); color: #9ba9ae; cursor: pointer; font-size: 9px; white-space: nowrap; }
.director-bar button:hover { color: var(--text); background: rgba(255,255,255,.07); }
.director-bar .director-primary { flex: 1.2; color: #11160d; border-color: var(--lime); background: var(--lime); font-weight: 800; }
.play-icon { margin-right: 3px; font-size: 8px; }

.settings-dialog { width: min(680px, calc(100vw - 60px)); padding: 0; border: 1px solid rgba(255,255,255,.15); border-radius: 20px; color: var(--text); background: #0d161b; box-shadow: 0 35px 100px rgba(0,0,0,.75); }
.settings-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(7px); }
.settings-card { padding: 26px; }
.settings-head { justify-content: space-between; margin-bottom: 22px; }
.dialog-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.04); font-size: 22px; cursor:pointer; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-grid label { display: grid; gap: 7px; color: #98a8ae; font-size: 11px; }
.settings-grid input, .settings-grid textarea { width:100%; border:1px solid var(--line); border-radius:10px; outline:0; padding:11px 12px; color:var(--text); background:rgba(0,0,0,.2); }
.settings-grid input:focus, .settings-grid textarea:focus { border-color: rgba(188,255,85,.42); }
.full-field { grid-column: 1/-1; }
.avatar-upload-row { gap: 16px; margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.upload-preview { width: 68px; height: 68px; flex: 0 0 auto; overflow:hidden; border-radius: 12px; background:#020303; }
.upload-preview img { width:100%; height:100%; object-fit:cover; object-position:center 22%; }
.avatar-upload-row strong { font-size: 12px; }
.avatar-upload-row p { margin:5px 0 10px; color:#86979e; font-size:10px; line-height:1.5; }
.upload-btn { display:inline-block; padding:7px 11px; border:1px solid rgba(188,255,85,.3); border-radius:8px; color:var(--lime); font-size:10px; cursor:pointer; }
.voice-settings { margin: 0 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.voice-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.voice-select-label, .voice-sliders label { display: grid; gap: 7px; color: #98a8ae; font-size: 11px; }
.voice-row select { width: 100%; border: 1px solid var(--line); border-radius: 10px; outline: 0; padding: 10px 11px; color: var(--text); background: #111b21; }
.test-voice-btn { height: 39px; padding: 0 14px; border: 1px solid rgba(188,255,85,.3); border-radius: 9px; color: var(--lime); background: rgba(188,255,85,.06); font-size: 10px; font-weight: 800; cursor: pointer; }
.voice-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.voice-sliders input { accent-color: var(--lime); }
.settings-foot { justify-content:space-between; gap:20px; padding-top:16px; border-top:1px solid var(--line); }
.settings-foot span { color:#74858c; font-size:10px; }
.save-settings { padding:10px 15px; border:0; border-radius:9px; color:#11160c; background:var(--lime); font-size:11px; font-weight:800; cursor:pointer; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 10px 15px; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; color: #eaf1ee; background: rgba(10,17,21,.94); box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 11px; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

@media (max-height: 760px) {
  .app-shell { padding: 12px 16px 15px; gap: 10px; }
  .topbar { min-height: 56px; padding-bottom: 9px; }
  .avatar-stage, .debate-panel { min-height: 540px; }
  .debate-panel { padding: 16px; }
  .topic-card { margin-top: 9px; padding: 10px 12px; }
  .topic-card h3 { margin: 5px 0 8px; }
  .conversation { margin-top: 7px; }
  .message { padding: 6px 0 7px; }
  .quick-prompts { margin-bottom: 6px; }
  .director-bar { margin-top: 7px; }
  .subtitle-card { bottom: 18px; min-height: 82px; padding-top: 12px; padding-bottom: 12px; }
}

@media (min-width: 1700px) {
  .app-shell { max-width: 1800px; margin: 0 auto; padding: 24px 30px 28px; }
  .debate-panel { padding: 28px; }
  .message p, .ask-box textarea { font-size: 14px; }
  .topic-card h3 { font-size: 17px; }
}
