:root {
  color-scheme: dark;
  --bg: var(--platform-bg, #070a11);
  --surface: var(--platform-surface, #101521);
  --surface-2: #161d2c;
  --line: rgba(255, 255, 255, 0.09);
  --text: var(--platform-text, #f5f7ff);
  --muted: var(--platform-muted, #919aaf);
  --accent: var(--platform-accent, #4b7cff);
  --accent-2: #75a0ff;
  --good: #4dd5a3;
  --warn: #f2b94b;
  --danger: #ff7085;
  --body-gradient: #0b0f18;
  --card-bg: linear-gradient(155deg, rgba(24, 31, 48, .96), rgba(13, 18, 29, .96));
  --field-bg: #161d2c;
  --field-text: #f5f7ff;
  --field-placeholder: #919aaf;
  --secondary-text: #dbe3f9;
  --secondary-bg: #1a2232;
  --panel-bg: rgba(22, 29, 44, .78);
  --transcript-text: #d7deef;
  --content-text: #cbd3e7;
  --privacy-text: #b9c6e6;
  --footer-text: #7f899f;
  --demo-bg: rgba(27, 35, 53, .78);
  --finish-text: #ffc1ca;
  --finish-bg: rgba(255, 112, 133, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--platform-bg, #f3f6fb);
  --surface: var(--platform-surface, #ffffff);
  --surface-2: #edf2fa;
  --line: rgba(20, 35, 65, .15);
  --text: var(--platform-text, #172033);
  --muted: var(--platform-muted, #59677f);
  --accent: var(--platform-accent, #315fe8);
  --accent-2: #315fe8;
  --body-gradient: #ffffff;
  --card-bg: linear-gradient(155deg, rgba(255, 255, 255, .99), rgba(239, 244, 252, .99));
  --field-bg: #ffffff;
  --field-text: #111827;
  --field-placeholder: #667085;
  --secondary-text: #25324a;
  --secondary-bg: #e8eef8;
  --panel-bg: rgba(235, 241, 250, .96);
  --transcript-text: #1d2939;
  --content-text: #344054;
  --privacy-text: #344b72;
  --footer-text: #667085;
  --demo-bg: #e9eff8;
  --finish-text: #9f1239;
  --finish-bg: #ffe4e9;
  --good: #087a55;
  --warn: #9a5b00;
  --danger: #c7374f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 5%, rgba(61, 104, 228, .16), transparent 28rem),
    linear-gradient(180deg, var(--body-gradient) 0%, var(--bg) 48%);
  font-size: 16px;
}
button, select, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px)) 22px calc(20px + max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px)));
}
.app-header {
  min-height: 76px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
  background: linear-gradient(145deg, #5b8bff, #315ce5);
  box-shadow: 0 9px 26px rgba(55, 96, 230, .35);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.app-header h1 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.app-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.silent-badge {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.view { padding: 42px 0 24px; }
.setup-view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; }
.status-orb {
  position: relative;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
}
.status-orb span { position: absolute; border-radius: 999px; border: 1px solid rgba(95, 138, 255, .34); }
.status-orb span:nth-child(1) { inset: 0; animation: breathe 3s infinite ease-in-out; }
.status-orb span:nth-child(2) { inset: 10px; background: rgba(68, 112, 240, .14); }
.status-orb span:nth-child(3) { width: 13px; height: 13px; background: var(--accent-2); border: 0; box-shadow: 0 0 20px var(--accent); }
@keyframes breathe { 50% { transform: scale(.88); opacity: .45; } }
.eyebrow { margin: 0 0 10px; color: var(--accent-2); font-size: 12px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.intro-copy h2, .summary-view h2 { margin: 0; font-size: clamp(27px, 7vw, 42px); line-height: 1.05; letter-spacing: -.045em; }
.intro-copy > p:last-child { max-width: 580px; margin: 17px 0 0; color: var(--muted); line-height: 1.55; }
.setup-card, .transcript-card, .answer-card, .summary-view article {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card-bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .24);
}
.setup-card { display: grid; gap: 14px; padding: 18px; }
.setup-card label > span, .demo-console > label, .control-group > label, .control-group legend { display: block; margin: 0 0 8px 3px; color: var(--muted); font-size: 13px; }
.control-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.grade-options { display: grid; grid-template-columns: repeat(7, minmax(38px, 1fr)); gap: 6px; }
.grade-options button { min-height: 43px; border: 1px solid var(--line); border-radius: 12px; color: var(--field-text); background: var(--field-bg); font-weight: 680; }
.grade-options button[aria-checked="true"] { border-color: transparent; color: white; background: var(--accent); box-shadow: 0 8px 20px rgba(49, 95, 232, .24); }
.subject-control { display: grid; grid-template-columns: 1fr; gap: 8px; }
.subject-control > label { margin-bottom: 0; }
select, input, textarea {
  width: 100%;
  min-height: 49px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  color: var(--field-text);
  caret-color: var(--accent);
  background: var(--field-bg);
  padding: 0 14px;
}
textarea { min-height: 94px; padding-block: 12px; resize: vertical; }
select option, select optgroup { color: var(--field-text); background: var(--field-bg); }
input::placeholder, textarea::placeholder { color: var(--field-placeholder); opacity: 1; }
select:disabled, input:disabled, textarea:disabled { color: var(--muted); background: var(--surface-2); opacity: .72; cursor: not-allowed; }
select:focus, input:focus, textarea:focus { border-color: rgba(93, 135, 255, .75); box-shadow: 0 0 0 3px rgba(69, 113, 238, .13); }
.privacy-note { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px; border-radius: 13px; background: rgba(75, 124, 255, .09); color: var(--privacy-text); }
.privacy-note > span { color: var(--accent-2); }
.privacy-note p { margin: 0; font-size: 12px; line-height: 1.5; }
.capability { min-height: 34px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.provider-status { margin: -4px 0 0; color: var(--accent-2); font-size: 12px; }
.error { margin: 0; padding: 11px; border: 1px solid rgba(255, 112, 133, .25); border-radius: 12px; color: #ffabb7; background: rgba(255, 112, 133, .08); font-size: 13px; }
.device-data-card { display: grid; gap: 10px; margin-top: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-bg); }
.device-data-card strong, .device-data-card span { display: block; }
.device-data-card strong { font-size: 13px; }
.device-data-card span, .device-data-card p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.device-data-actions { display: flex; gap: 8px; }
.device-data-actions button, .history-item button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface); font-size: 11px; }
.history-list { display: grid; gap: 7px; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.history-item strong { font-size: 12px; }
.history-item span { margin-top: 2px; }
.history-actions { display: flex; gap: 6px; }
.primary-button, .secondary-button, .finish-button, .expand-button {
  min-height: 49px;
  border: 0;
  border-radius: 14px;
  font-weight: 720;
}
.primary-button { color: white; background: linear-gradient(135deg, #507fff, #3565ec); box-shadow: 0 14px 30px rgba(47, 95, 232, .27); }
.primary-button:hover { filter: brightness(1.08); }
.secondary-button { color: var(--secondary-text); background: var(--secondary-bg); border: 1px solid var(--line); }
.finish-button { color: var(--finish-text); background: var(--finish-bg); border: 1px solid rgba(255, 112, 133, .28); }
.record-dot, .live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 112, 133, .12); }

.live-view { padding-top: 22px; }
.teacher-tools { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel-bg); }
.teacher-tools strong, .teacher-tools span { display: block; }
.teacher-tools strong { font-size: 13px; }
.teacher-tools span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.teacher-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.teacher-actions button { min-height: 33px; padding: 0 10px; border: 1px solid rgba(104, 141, 255, .35); border-radius: 10px; color: var(--text); background: rgba(75, 124, 255, .1); font-size: 11px; }
.teacher-actions button[aria-pressed="true"] { color: white; background: var(--accent); }
.teacher-actions button:disabled { opacity: .5; cursor: wait; }
.session-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.session-bar strong { color: var(--text); font-weight: 650; }
.session-bar time { font-variant-numeric: tabular-nums; font-size: 18px; color: var(--text); }
.transcript-card { min-height: 210px; padding: 18px; }
.card-label-row, .answer-topline { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.listening-pill { color: var(--good); }
.transcript-history { min-height: 76px; margin: 24px 0 8px; color: var(--transcript-text); font-size: 18px; line-height: 1.52; white-space: pre-wrap; }
.interim-transcript { min-height: 22px; margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.waveform { height: 28px; display: flex; align-items: center; gap: 5px; overflow: hidden; opacity: .72; }
.waveform i { width: 3px; height: 6px; border-radius: 4px; background: var(--accent-2); animation: wave 1.3s ease-in-out infinite; }
.waveform i:nth-child(2n) { animation-delay: -.25s; }
.waveform i:nth-child(3n) { animation-delay: -.58s; }
.waveform i:nth-child(4n) { animation-delay: -.78s; }
@keyframes wave { 50% { height: 26px; } }
.demo-console { margin: 12px 0; padding: 14px; border: 1px dashed rgba(116, 151, 255, .35); border-radius: 16px; background: var(--demo-bg); }
.demo-console > div { display: grid; grid-template-columns: 1fr 45px; gap: 8px; }
.demo-console button { border: 0; border-radius: 13px; color: white; background: var(--accent); font-size: 22px; }
.demo-console p { margin: 9px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.answer-card { margin-top: 12px; padding: 19px; border-color: rgba(83, 130, 255, .35); }
.answer-card.fresh { animation: reveal .25s ease-out; }
@keyframes reveal { from { transform: translateY(7px); opacity: .2; } }
.confidence-track { height: 3px; margin: 9px 0 18px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; }
.confidence-track i { display: block; height: 100%; transition: width .25s ease; }
.confidence-track i[data-level="high"] { background: var(--good); }
.confidence-track i[data-level="medium"] { background: var(--warn); }
.confidence-track i[data-level="low"] { background: var(--danger); }
.direct-answer { margin: 0; font-size: clamp(20px, 5vw, 27px); line-height: 1.3; font-weight: 680; letter-spacing: -.02em; }
.expand-button { min-height: auto; margin-top: 18px; padding: 8px 0; color: var(--accent-2); background: transparent; }
.answer-details { padding-top: 4px; }
.answer-details ul, .summary-view ul { padding-left: 22px; color: var(--content-text); line-height: 1.52; }
.answer-details li + li, .summary-view li + li { margin-top: 7px; }
.follow-up { display: grid; gap: 6px; margin-top: 15px; padding: 13px; border-left: 3px solid var(--accent); background: rgba(75, 124, 255, .08); color: var(--muted); line-height: 1.42; }
.follow-up strong { color: var(--text); }
.session-actions { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 0; background: linear-gradient(180deg, transparent, var(--bg) 24%); }

.summary-view { text-align: center; }
.summary-icon { width: 58px; height: 58px; margin: 0 auto 24px; display: grid; place-items: center; border-radius: 20px; color: var(--good); background: rgba(77, 213, 163, .12); font-size: 28px; }
.summary-meta { color: var(--muted); }
.summary-view article { margin-top: 14px; padding: 18px; text-align: left; }
.summary-view h3 { margin: 0; font-size: 14px; }
.summary-warning { margin: 16px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.summary-view > .primary-button { width: 100%; }
.homework-card { display: grid; gap: 10px; }
.homework-card p { margin: 0; color: var(--muted); font-size: 11px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
footer { padding: 24px 0 10px; border-top: 1px solid var(--line); color: var(--footer-text); text-align: center; font-size: 11px; line-height: 1.45; }

@media (min-width: 680px) {
  .app-shell { padding-inline: 34px; }
  .setup-view { grid-template-columns: .84fr 1.16fr; align-items: start; padding-top: 72px; }
  .status-orb { grid-column: 1; }
  .intro-copy { grid-column: 1; }
  .setup-card { grid-column: 2; grid-row: 1 / span 2; }
}

@media (max-width: 520px) {
  .teacher-tools { align-items: stretch; flex-direction: column; }
  .teacher-actions { justify-content: stretch; }
  .teacher-actions button { flex: 1; }
  .grade-options { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
