:root {
  color-scheme: light;
  --ink: #17171b;
  --muted: #707078;
  --subtle: #f6f6f7;
  --line: #e6e6e9;
  --panel: #ffffff;
  --violet: #7455e8;
  --blue: #4a8ff5;
  --green: #2b9a66;
  --amber: #bd791b;
  --danger: #c45151;
  --gradient: linear-gradient(135deg, #7656e8 0%, #4a8ff5 100%);
  --shadow: 0 20px 60px rgba(31, 28, 52, 0.1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--panel); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.eyebrow { margin: 0 0 8px; color: var(--violet); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.gradient-text { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Qofi Portal sign-in pattern */
.auth-page { display: grid; min-height: 100%; place-items: center; padding: 24px; background: #fff; }
.auth-card { display: grid; width: min(100%, 480px); justify-items: center; padding: 56px 32px; text-align: center; }
.auth-brand-mark, .mini-brand { display: grid; place-items: center; background: var(--gradient); color: #fff; font-weight: 900; box-shadow: 0 12px 32px rgba(105, 81, 226, .25); }
.auth-brand-mark { width: 58px; height: 58px; margin-bottom: 25px; border-radius: 17px; font-size: 22px; }
.auth-card h1 { max-width: 420px; margin: 4px 0 28px; font-size: clamp(32px, 8vw, 46px); line-height: 1.06; letter-spacing: -.045em; }
.auth-loading p { margin: 0; color: var(--muted); font-size: 13px; font-weight: 750; }
.google-login-button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 11px; padding: 0 22px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(30,30,40,.06); font-size: 14px; font-weight: 750; text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.google-login-button:hover { transform: translateY(-1px); border-color: #c9c8d0; box-shadow: 0 7px 20px rgba(30,30,40,.09); }
.google-login-button svg { width: 20px; height: 20px; }
.login-error { margin: 20px 0 0; color: var(--danger); font-size: 13px; }

/* First-run setup */
.onboarding-page { min-height: 100dvh; padding: clamp(28px, 6vw, 72px) 20px; background: #fafafd; }
.onboarding-card { width: min(100%, 760px); margin: 0 auto; padding: clamp(26px, 5vw, 54px); border: 1px solid var(--line); border-radius: 28px; background: #fff; box-shadow: var(--shadow); }
.onboarding-card > .auth-brand-mark { margin-bottom: 25px; }
.onboarding-card h1 { max-width: 650px; margin: 0 0 14px; font-size: clamp(34px, 7vw, 58px); line-height: 1; letter-spacing: -.05em; }
.onboarding-lede { max-width: 620px; margin: 0 0 30px; color: var(--muted); font-size: 16px; line-height: 1.55; }
.onboarding-card form { display: grid; gap: 25px; }
.setup-field { display: grid; gap: 8px; }
.setup-field > span, .starting-level-fieldset legend { font-size: 13px; font-weight: 850; }
.setup-field input, .settings-dialog select { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; outline: 0; }
.setup-field input:focus, .settings-dialog select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(116,85,232,.12); }
.starting-level-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.starting-level-fieldset > p { margin: 7px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.level-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.level-options label { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: start; gap: 10px; min-height: 76px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.level-options label:hover, .level-options label:has(input:checked) { border-color: rgba(116,85,232,.7); background: #f7f5ff; }
.level-options input { margin-top: 3px; accent-color: var(--violet); }
.level-options span { display: grid; gap: 4px; }
.level-options strong { font-size: 13px; }
.level-options small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.onboarding-card .primary-button { justify-self: start; min-width: 180px; }
.form-error { margin: -8px 0 0; color: var(--danger); font-size: 12px; }

/* App shell */
.workspace { display: grid; grid-template-columns: 292px minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.sidebar { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--line); background: #f9f9fa; }
.brand-row { display: flex; align-items: center; gap: 11px; height: 70px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.mini-brand { width: 34px; height: 34px; flex: none; border-radius: 10px; font-size: 14px; }
.brand-row > div { display: grid; gap: 2px; }
.brand-row strong { font-size: 14px; letter-spacing: -.01em; }
.brand-row span:not(.mini-brand) { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.icon-button { display: grid; width: 38px; height: 38px; flex: none; place-items: center; border: 0; border-radius: 10px; background: transparent; font-size: 20px; }
.icon-button:hover { background: var(--subtle); }
.new-session { padding: 20px 16px 17px; }
.new-session p, .history-heading { margin: 0 0 10px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.duration-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.duration-grid button { display: grid; gap: 1px; min-height: 55px; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; font-weight: 850; }
.duration-grid button:hover { border-color: var(--violet); box-shadow: 0 4px 14px rgba(70,60,120,.08); }
.duration-grid button.recommended { border-color: rgba(116,85,232,.35); background: #f6f3ff; color: #6245d0; }
.duration-grid span { color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.history-section { display: flex; min-height: 0; flex: 1; flex-direction: column; padding: 4px 9px 8px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 7px 8px; }
.text-button, .sign-out { border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.text-button:hover, .sign-out:hover { color: var(--ink); }
.session-history { display: grid; gap: 5px; overflow-y: auto; }
.history-empty { padding: 20px 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.history-item { display: grid; gap: 8px; width: 100%; padding: 11px 10px; border: 0; border-radius: 12px; background: transparent; text-align: left; }
.history-item:hover, .history-item[data-selected="true"] { background: #fff; box-shadow: 0 2px 10px rgba(28,27,37,.06); }
.history-item-top, .history-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-item strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.history-item time, .history-meta { color: var(--muted); font-size: 10px; }
.history-meta b { color: var(--amber); font-weight: 750; }
.history-item[data-status="completed"] .history-meta b { color: var(--green); }
.track { overflow: hidden; width: 100%; height: 5px; border: 0; border-radius: 99px; appearance: none; background: #e9e8ec; }
.track::-webkit-progress-bar { border-radius: inherit; background: #e9e8ec; }
.track::-webkit-progress-value { border-radius: inherit; background: var(--gradient); transition: width .35s ease; }
.track::-moz-progress-bar { border-radius: inherit; background: var(--gradient); }
.sidebar-footer { display: grid; gap: 4px; padding: 10px; border-top: 1px solid var(--line); }
.user-card { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 7px; border: 0; border-radius: 12px; background: transparent; text-align: left; }
.user-card:hover { background: #fff; }
.avatar-fallback, .user-avatar { width: 36px; height: 36px; border-radius: 50%; }
.avatar-fallback { display: grid; place-items: center; background: #e8e3ff; color: #6044cb; font-size: 13px; font-weight: 850; }
.user-avatar { object-fit: cover; }
.user-card > span:nth-child(3) { display: grid; gap: 2px; min-width: 0; }
.user-card strong, .user-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card strong { font-size: 12px; }
.user-card small { color: var(--muted); font-size: 10px; }
.sign-out { justify-self: start; padding: 4px 9px; }

/* Scorecard home */
.main-pane { position: relative; min-width: 0; height: 100dvh; overflow-y: auto; background: #fff; }
.home-view { width: min(900px, calc(100% - 48px)); margin: 0 auto; padding: clamp(60px, 10vh, 105px) 0 70px; }
.welcome-block { max-width: 680px; margin-bottom: 38px; }
.welcome-block h1 { margin: 0 0 13px; font-size: clamp(38px, 6vw, 62px); line-height: 1; letter-spacing: -.055em; }
.welcome-block > p:last-child { max-width: 590px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.progress-card { padding: 25px; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 35px rgba(27,25,44,.06); }
.progress-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.progress-heading div { display: grid; gap: 5px; }
.progress-heading span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.progress-heading strong { font-size: clamp(24px, 5vw, 36px); letter-spacing: -.035em; }
.progress-heading .next-level { text-align: right; }
.progress-heading .next-level strong { font-size: 18px; }
.track.large { height: 9px; }
.progress-card > p { margin: 11px 0 0; color: var(--muted); font-size: 12px; }
.system-notice { margin-top: 16px; padding: 13px 16px; border: 1px solid #f0d6ad; border-radius: 12px; background: #fff8ed; color: #815213; font-size: 13px; line-height: 1.5; }
.skill-summary { margin-top: 42px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-title h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.section-title > span { color: var(--muted); font-size: 11px; }
.domain-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.domain-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 5px 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; }
.domain-card strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.domain-card b { color: var(--muted); font-size: 11px; }
.domain-card .track { grid-column: 1 / -1; height: 4px; }
.domain-card[data-status="validated"] .track::-webkit-progress-value { background: var(--green); }
.domain-card[data-status="validated"] .track::-moz-progress-bar { background: var(--green); }

/* Chat/session surface */
.session-view { display: flex; height: 100%; flex-direction: column; overflow: hidden; }
.session-header { display: flex; min-height: 70px; align-items: center; gap: 13px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.session-identity { display: grid; min-width: 0; flex: 1; gap: 3px; }
.session-identity strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.session-identity span { color: var(--muted); font-size: 11px; }
.session-state { padding: 6px 9px; border-radius: 99px; background: #fff4df; color: var(--amber); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.session-state[data-status="completed"] { background: #eaf7f0; color: var(--green); }
.session-progress-wrap { padding: 12px 25px 0; }
.session-progress-copy { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.session-track { height: 6px; }
.conversation { display: flex; width: min(780px, calc(100% - 40px)); min-height: 0; flex: 1; flex-direction: column; gap: 22px; margin: 0 auto; padding: 38px 0 30px; overflow-y: auto; }
.welcome-message { display: grid; max-width: 610px; align-self: center; gap: 12px; margin: auto 0; text-align: center; }
.welcome-message .voice-mark { display: grid; width: 54px; height: 54px; margin: 0 auto 4px; place-items: center; border-radius: 50%; background: var(--gradient); box-shadow: 0 10px 30px rgba(94,75,200,.22); color: #fff; }
.welcome-message h2 { margin: 0; font-size: 27px; letter-spacing: -.035em; }
.welcome-message p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.target-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px; }
.target-pills span { padding: 6px 9px; border-radius: 99px; background: #f0edff; color: #6147c6; font-size: 10px; font-weight: 750; }
.message { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 12px; max-width: 690px; }
.message[data-role="Learner"] { grid-template-columns: minmax(0,1fr); align-self: flex-end; }
.message-avatar { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: var(--gradient); color: #fff; font-size: 11px; font-weight: 850; }
.message-body { padding: 9px 0; line-height: 1.58; }
.message-body p { margin: 0; white-space: pre-wrap; }
.message[data-role="Learner"] .message-body { padding: 11px 14px; border-radius: 17px 17px 4px 17px; background: #f0f0f2; }
.evaluation-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fbfbfc; }
.evaluation-card h3 { margin: 0 0 7px; font-size: 14px; }
.evaluation-card p, .evaluation-card li { color: var(--muted); font-size: 12px; line-height: 1.5; }
.session-controls { padding: 10px 22px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); text-align: center; backdrop-filter: blur(14px); }
.session-controls > #tutor-status { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.control-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; }
.voice-button, .finish-button, .secondary-button, .primary-button { min-height: 44px; border-radius: 99px; padding: 0 18px; font-size: 13px; font-weight: 800; }
.voice-button { display: inline-flex; align-items: center; gap: 9px; border: 0; background: var(--gradient); color: #fff; box-shadow: 0 7px 20px rgba(96,73,200,.2); }
.voice-button[data-active="true"] { background: #222228; }
.mic-icon { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: rgba(255,255,255,.19); font-size: 7px; animation: none; }
.voice-button[data-active="true"] .mic-icon { animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { transform: scale(1.22); background: #ef6969; } }
.secondary-button { border: 1px solid var(--line); background: #fff; }
.finish-button { border: 0; background: #edf7f1; color: var(--green); }
.finish-button:disabled, button:disabled { cursor: not-allowed; opacity: .46; }
.composer { display: flex; width: min(700px, 100%); margin: 0 auto; padding: 8px 8px 8px 14px; align-items: end; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 4px 18px rgba(30,28,45,.06); }
.composer textarea { min-width: 0; max-height: 130px; flex: 1; resize: none; border: 0; outline: 0; font-size: 14px; line-height: 1.45; }
.composer button { width: 37px; height: 37px; flex: none; border: 0; border-radius: 12px; background: #202025; color: #fff; font-size: 17px; }
.ai-voice-disclosure { margin: 7px 0 0; color: #929198; font-size: 9px; }
.audio-prompt-tray { display: grid; gap: 8px; margin-top: 13px; }
.audio-prompt { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; width: fit-content; max-width: 100%; padding: 9px 10px; border: 1px solid #ddd9f2; border-radius: 12px; background: #faf9ff; }
.audio-target { color: #282330; font-size: 14px; font-weight: 750; }
.listen-button { min-height: 34px; padding: 0 12px; border: 1px solid rgba(116,85,232,.28); border-radius: 99px; background: #fff; color: #6147c6; font-size: 11px; font-weight: 800; }
.listen-button:hover { border-color: var(--violet); background: #f3f0ff; }
.sentence-audio-prompt { display: grid; width: min(100%, 620px); }
.pronunciation-words { display: flex; flex-wrap: wrap; align-items: start; gap: 8px; }
.pronunciation-word { display: grid; min-width: 46px; justify-items: center; gap: 5px; }
.karaoke-word { padding: 3px 5px; border-radius: 6px; font-size: 16px; font-weight: 760; transition: background .14s, color .14s, transform .14s; }
.karaoke-word[data-active="true"] { background: var(--gradient); color: #fff; transform: translateY(-1px); }
.word-listen-button { display: grid; width: 27px; height: 24px; place-items: center; border: 1px solid #ddd9f2; border-radius: 8px; background: #fff; color: #6147c6; font-size: 9px; }
.word-listen-button:hover { border-color: var(--violet); background: #f3f0ff; }
.full-sentence-button { justify-self: start; }
.activity-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.activity-action { min-height: 40px; padding: 0 16px; border-radius: 12px; font-size: 12px; font-weight: 800; }
.continue-button { border: 0; background: var(--gradient); color: #fff; box-shadow: 0 5px 15px rgba(96,73,200,.16); }
.choice-button { border: 1px solid #d8d5e6; background: #fff; color: #3f3856; }
.choice-button:hover { border-color: var(--violet); background: #f7f5ff; }

/* Settings */
.settings-dialog { width: min(92vw, 500px); padding: 0; border: 0; border-radius: 20px; box-shadow: var(--shadow); }
.settings-dialog::backdrop { background: rgba(20,19,30,.38); backdrop-filter: blur(3px); }
.settings-dialog form { display: grid; gap: 16px; padding: 26px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.settings-dialog form > p { margin: -5px 0 2px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.settings-dialog label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; }
.settings-dialog input, .settings-dialog select { min-height: 45px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; outline: 0; }
.settings-dialog input:focus, .settings-dialog select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(116,85,232,.12); }
.primary-button { border: 0; background: var(--gradient); color: #fff; }

@media (max-width: 800px) {
  .mobile-only { display: grid !important; }
  .workspace { display: block; }
  .sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(88vw, 310px); transform: translateX(-105%); box-shadow: 20px 0 50px rgba(20,18,35,.13); transition: transform .22s ease; }
  .sidebar[data-open="true"] { transform: translateX(0); }
  .brand-row #close-sidebar { margin-left: auto; }
  .sidebar-backdrop { position: fixed; z-index: 20; inset: 0; display: block; border: 0; background: rgba(20,19,28,.35); }
  .main-pane { height: 100dvh; }
  .mobile-header { display: grid; grid-template-columns: 38px 1fr auto; height: 59px; align-items: center; padding: 0 12px; border-bottom: 1px solid var(--line); }
  .mobile-header strong { text-align: center; font-size: 13px; }
  .level-chip { padding: 5px 8px; border-radius: 99px; background: #f0edff; color: #6247c8; font-size: 10px; font-weight: 800; }
  .home-view { width: min(100% - 30px, 720px); padding: 45px 0 50px; }
  .welcome-block { margin-bottom: 28px; }
  .welcome-block h1 { font-size: 42px; }
  .domain-grid { grid-template-columns: 1fr; }
  .session-view { height: calc(100dvh - 59px); }
  .session-header { min-height: 58px; padding: 0 12px; }
  .conversation { width: calc(100% - 26px); padding: 25px 0 20px; }
  .session-progress-wrap { padding-inline: 15px; }
  .session-controls { padding-inline: 12px; }
}

@media (max-width: 480px) {
  .onboarding-page { padding: 0; background: #fff; }
  .onboarding-card { min-height: 100dvh; padding: 28px 18px 40px; border: 0; border-radius: 0; box-shadow: none; }
  .onboarding-card h1 { font-size: 39px; }
  .level-options { grid-template-columns: 1fr; }
  .onboarding-card .primary-button { width: 100%; }
  .auth-card { padding-inline: 8px; }
  .auth-card h1 { font-size: 36px; }
  .progress-card { padding: 19px; }
  .progress-heading { align-items: start; }
  .progress-heading strong { font-size: 27px; }
  .progress-heading .next-level strong { font-size: 15px; }
  .section-title { align-items: center; }
  .session-state { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .control-row { display: grid; grid-template-columns: 1fr 1fr; }
  .voice-button { grid-column: 1 / -1; justify-content: center; }
  .control-row .hidden + .finish-button { grid-column: 1 / -1; }
}
