:root { --mimi-vh: 1vh; --mimi-svh: 1vh; }
@supports (height: 1dvh) { :root { --mimi-vh: 1dvh; --mimi-svh: 1svh; } }
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #2e3438; background: #fffdfa; font-synthesis: none;
  --paper: #fffdfa; --soft: #f4f1eb; --ink: #2e3438; --muted: #67747c;
  --red: #ac263b; --red-dark: #902034; --red-soft: #faecef;
  --teal: #48636d; --teal-soft: #eaf0ef; --gold-line: #dfd3bd; --line: #e5e0d7;
  --serif: "Georgia", "Times New Roman", serif;
}
.student-entry { min-height: calc(100 * var(--mimi-svh)); padding: max(24px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) max(32px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left)); }
.student-entry > .wordmark { display: block; text-align: center; color: var(--ink); text-decoration: none; margin-bottom: 32px; }
.student-entry > section { max-width: 480px; margin: 0 auto; }
.student-entry h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(28px,7vw,36px); }
.student-entry p { overflow-wrap: anywhere; }
.student-entry button { min-height: 48px; width: 100%; margin: 8px 0; }
.student-entry input { margin-bottom: 16px; }
.student-entry audio, .student-entry progress { width: 100%; margin: 16px 0; }
.student-entry details { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.student-entry summary { min-height: 48px; cursor: pointer; }
.account-label { text-align: center; margin: 10px 20px; color: var(--teal); font-size: 14px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 12px; min-height: 44px; padding: 10px 16px; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.45; touch-action: manipulation; transition: background .15s, border-color .15s; }
button:hover:not(:disabled) { background: var(--soft); }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--teal); outline-offset: 4px; }
button svg { width: 21px; height: 21px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
input, select, textarea { width: 100%; min-width: 0; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; }
textarea { resize: vertical; line-height: 1.65; }
label { display: block; font-size: 14px; margin: 0 0 8px; }
h1, h2, h3, p { margin-top: 0; }
p { line-height: 1.65; }
[hidden] { display: none !important; }
[inert] { pointer-events: none; }
.mimi-app, .main-surface { height: var(--app-height,calc(100 * var(--mimi-vh))); min-height: 0; }
.mimi-app { overflow: hidden; }
[data-coach-viewport] { position: fixed; top: var(--app-offset-top,0px); left: 0; right: 0; height: var(--app-height); }
.main-surface { display: flex; flex-direction: column; }
.app-header { min-height: 80px; flex-shrink: 0; margin: 0 clamp(20px,4vw,80px); padding: max(10px,env(safe-area-inset-top)) 0 10px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; border-bottom: 1px solid var(--gold-line); }
.header-button { justify-self: start; border: 0; padding: 8px 12px; color: var(--teal); white-space: nowrap; }
.header-button:last-child { justify-self: end; }
.header-button svg { width: 19px; height: 19px; }
.wordmark { font-family: var(--serif); font-size: 30px; letter-spacing: -.04em; font-weight: 400; color: var(--red); }
.icon-button { width: 44px; padding: 10px; border: 0; border-radius: 50%; flex-shrink: 0; }
.conversation-space { width: min(800px,100%); flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 auto; padding: 0 28px; }
.conversation-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--line) transparent; overscroll-behavior: contain; padding: 16px 8px 20px; }
.empty-conversation { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8px 0; }
.empty-conversation h1 { font-family: var(--serif); font-size: clamp(28px,2.5vw,36px); line-height: 1.25; font-weight: 400; letter-spacing: -.035em; margin: 30px 0 0; text-wrap: balance; }
.mimi-portrait { position: relative; width: clamp(180px,calc(28 * var(--mimi-vh)),272px); aspect-ratio: 1; flex-shrink: 0; border-radius: 50%; padding: 7px; border: 1px solid var(--gold-line); background: var(--paper); box-shadow: 0 10px 30px #59452b06; transition: box-shadow .12s linear, border-color .2s; }
.mimi-portrait img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.mimi-portrait[data-phase="listening"] { border-color: #8caaab; box-shadow: 0 0 0 var(--input-spread,2px) #48636d12; }
.mimi-portrait:is([data-phase="listening"],[data-phase="speaking"])::before { content: ""; position: absolute; inset: -8px; border: 1px solid #97b0b2; border-radius: 50%; pointer-events: none; }
.mimi-portrait[data-phase="listening"]::before { animation: listening-ring 3s ease-in-out infinite; }
.mimi-portrait[data-phase="speaking"] { border-color: #8caaab; }
.mimi-portrait[data-phase="speaking"]::before { animation: speaking-ring 1.4s ease-out infinite; }
.mimi-signal { position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); display: none; align-items: center; justify-content: center; gap: 3px; width: 60px; height: 34px; background: var(--paper); border: 1px solid var(--line); border-radius: 99px; box-shadow: 0 3px 9px #463b2c06; color: var(--teal); }
.mimi-portrait:is([data-phase="listening"],[data-phase="thinking"],[data-phase="speaking"]) .mimi-signal { display: flex; }
.mimi-portrait.compact .mimi-signal { width: 48px; height: 28px; bottom: -12px; }
.call-presence { display: flex; flex-shrink: 0; justify-content: center; padding: 10px 0 24px; }
.mimi-portrait.compact { width: 86px; padding: 3px; }
.welcome-view .conversation-space { justify-content: safe center; overflow-y: auto; padding-top: 24px; padding-bottom: 36px; }
.welcome-view .conversation-scroll { flex: 0 0 auto; overflow: visible; padding: 0 8px; }
.welcome-view .conversation-bottom { padding: 30px 8px 0; }
.welcome-view:not(.call-active) .call-controls { flex-direction: column; gap: 10px; }
.call-active.welcome-view .conversation-space { justify-content: initial; overflow: hidden; padding-top: 0; padding-bottom: 0; }
.call-active.welcome-view .conversation-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; justify-content: safe center; }
.call-active.welcome-view .conversation-bottom { padding: 20px 8px max(28px,env(safe-area-inset-bottom)); }
.conversation-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 28px; }
.message { max-width: 92%; padding: 0; }
.message-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; line-height: 1.75; }
.student-message { align-self: flex-end; background: var(--soft); border-radius: 18px 18px 4px 18px; padding: 12px 20px 16px; min-width: 100px; }
.coach-message { align-self: flex-start; padding: 4px 4px 8px; }
.coach-message .message-heading { color: var(--teal); font-weight: 600; }
.message-edit { width: 32px; min-height: 32px; height: 32px; padding: 7px; }
.message-edit svg { width: 15px; height: 15px; }
.message-note { display: block; font-size: 12px; color: var(--muted); margin-top: 7px; }
.empty-filter { text-align: center; color: var(--muted); padding: 60px 0; }
.conversation-bottom { flex-shrink: 0; width: 100%; background: var(--paper); padding: 20px 8px max(28px,env(safe-area-inset-bottom)); }
.primary { background: var(--red); border-color: var(--red); color: #fff; }
.primary:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }
.start-button { font-size: 16px; min-height: 54px; min-width: 224px; border-radius: 99px; padding: 14px 32px; }
.call-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.control { min-width: 86px; min-height: 54px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 99px; background: var(--soft); color: var(--teal); }
.end-control { order: 5; color: var(--red); background: var(--red-soft); border-color: transparent; }
.end-control:hover:not(:disabled) { background: #f4dfe4; }
.voice-feedback { display: flex; align-items: center; justify-content: center; min-height: 30px; gap: 10px; margin: 0 0 22px; font-size: 14px; color: var(--teal); }
.input-wave { width: 28px; height: 28px; display: inline-flex; justify-content: center; align-items: center; gap: 3px; color: var(--teal); }
.input-wave i, .mimi-signal i { display: block; width: 3px; height: 3px; border-radius: 4px; background: currentColor; transition: height .12s linear; }
:is(.mimi-portrait,.voice-feedback)[data-phase="listening"] i { height: var(--bar-height,3px); }
:is(.mimi-portrait,.voice-feedback)[data-phase="thinking"] i { width: 4px; height: 4px; animation: thinking-dot 1.2s ease-in-out infinite; }
:is(.mimi-portrait,.voice-feedback)[data-phase="thinking"] i:nth-child(2) { animation-delay: .16s; }
:is(.mimi-portrait,.voice-feedback)[data-phase="thinking"] i:nth-child(3) { animation-delay: .32s; }
:is(.mimi-portrait,.voice-feedback)[data-phase="thinking"] i:nth-child(n+4) { display: none; }
:is(.mimi-portrait,.voice-feedback)[data-phase="speaking"] i { height: 16px; animation: speaking-bar .72s ease-in-out infinite alternate; }
:is(.mimi-portrait,.voice-feedback)[data-phase="speaking"] i:nth-child(1) { height: 10px; animation-delay: -.2s; }
:is(.mimi-portrait,.voice-feedback)[data-phase="speaking"] i:nth-child(2) { animation-delay: -.55s; }
:is(.mimi-portrait,.voice-feedback)[data-phase="speaking"] i:nth-child(3) { height: 22px; animation-delay: -.1s; }
:is(.mimi-portrait,.voice-feedback)[data-phase="speaking"] i:nth-child(4) { animation-delay: -.4s; }
:is(.mimi-portrait,.voice-feedback)[data-phase="speaking"] i:nth-child(5) { height: 10px; animation-delay: -.7s; }
@keyframes listening-ring { 0%,100% { opacity: .2; } 50% { opacity: .65; } }
@keyframes thinking-dot { 0%,60%,100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes speaking-bar { from { transform: scaleY(.35); } to { transform: scaleY(1); } }
@keyframes speaking-ring { from { transform: scale(1); opacity: .55; } to { transform: scale(1.08); opacity: 0; } }
.text-button { padding: 4px 0; min-height: 44px; border: 0; border-radius: 4px; font-size: 14px; text-decoration: underline; text-decoration-color: var(--gold-line); text-underline-offset: 4px; }
.text-button:hover:not(:disabled) { background: transparent; text-decoration-color: currentColor; }
.after-call { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.after-call button { font-size: 14px; text-decoration: none; color: var(--teal); }
.composer-area { width: min(640px,100%); margin: 0 auto 16px; }
.text-composer { padding: 8px; border: 1px solid var(--line); border-radius: 28px; background: #fff; box-shadow: 0 3px 12px #463b2c05; transition: border-color .18s, box-shadow .18s; }
.text-composer:focus-within { border-color: #97a9ac; box-shadow: 0 0 0 3px #48636d0a; }
.composer-entry { display: flex; align-items: flex-end; gap: 10px; }
.text-composer textarea { display: block; flex: 1; min-width: 0; min-height: 44px; max-height: min(160px,calc(24 * var(--mimi-vh))); border: 0; border-radius: 0; background: transparent; resize: none; padding: 10px 0 10px 12px; font-size: 16px; line-height: 24px; scrollbar-width: thin; overflow-y: hidden; }
.text-composer textarea:focus-visible { outline: none; }
.text-composer textarea::placeholder { color: #7b8387; opacity: 1; }
.send-button { width: 44px; min-height: 44px; height: 44px; padding: 10px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--red); color: #fff; }
.send-button:hover:not(:disabled) { background: var(--red-dark); }
.send-button:disabled { background: var(--soft); color: #9ba1a2; opacity: 1; }
.send-button svg { width: 22px; height: 22px; stroke-width: 2; }
.composer-hint { margin: 12px 0 0; text-align: center; font-size: 12px; line-height: 1.5; color: var(--muted); }
.error-notice, .draft-error { font-size: 14px; line-height: 1.6; color: var(--red-dark); background: var(--red-soft); border-radius: 10px; padding: 12px 16px; margin: 0 0 14px; overflow-wrap: anywhere; }
.error-notice .text-button { color: inherit; margin-left: 12px; }
.sound-button { display: flex; margin: 0 auto 16px; }
.panel-shade { position: fixed; inset: 0; background: #2e343829; z-index: 9; }
.side-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px,100%); z-index: 10; background: var(--paper); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -12px 0 50px #2926230a; padding-bottom: env(safe-area-inset-bottom); }
.side-panel-left { left: 0; right: auto; border-left: 0; border-right: 1px solid var(--line); box-shadow: 12px 0 50px #2926230a; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(20px,env(safe-area-inset-top)) 24px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.panel-header h2 { font-size: 20px; font-weight: 500; margin: 0; }
.panel-body { padding: 24px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.panel-body form { display: flex; flex-direction: column; gap: 12px; }
.panel-body form label { margin: 6px 0 0; }
.panel-body form > .primary { align-self: flex-start; margin-top: 10px; }
.panel-note { font-size: 14px; line-height: 1.7; color: var(--muted); margin: 18px 0; }
.panel-divider { height: 1px; background: var(--line); margin: 28px 0; }
.settings-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 0 0 28px; }
.settings-actions button { justify-content: space-between; text-align: left; border: 0; }
.history-list { margin: 18px 0; }
.history-list button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; padding: 16px 12px; gap: 7px; text-align: left; margin-bottom: 5px; }
.history-list [aria-current="true"] { background: var(--soft); }
.history-list strong { font-weight: 500; font-size: 15px; overflow-wrap: anywhere; }
.history-list span { font-size: 12px; color: var(--muted); }
.new-conversation { width: 100%; justify-content: flex-start; color: var(--teal); }
.record-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.panel-call { padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); font-size: 14px; flex-shrink: 0; }
.admin-link { display: flex; justify-content: space-between; min-height: 44px; padding: 16px; margin-top: 24px; border-top: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
/* Phone layout is the default on every screen. */
  .app-header { min-height: 68px; margin: 0 16px; gap: 8px; }
  .header-button { padding: 8px 4px; gap: 6px; font-size: 13px; }
  .header-button svg { width: 18px; height: 18px; }
  .wordmark { font-size: 28px; }
  .conversation-space { padding: 0 20px; }
  .welcome-view .conversation-space { padding-bottom: max(44px,env(safe-area-inset-bottom)); }
  .mimi-portrait { width: clamp(168px,calc(28 * var(--mimi-vh)),252px); }
  .empty-conversation h1 { font-size: 30px; max-width: 300px; margin-top: 28px; }
  .start-button { width: min(280px,100%); min-height: 56px; }
  .conversation-scroll { padding: 10px 0 18px; }
  .conversation-lines { gap: 22px; }
  .message { max-width: 96%; }
  .message p { font-size: 16px; }
  .student-message { padding: 10px 16px 14px; }
  .conversation-bottom { padding: 14px 0 max(20px,env(safe-area-inset-bottom)); }
  .call-controls { gap: 8px; }
  .control { min-height: 48px; min-width: 74px; padding: 12px; font-size: 13px; }
  .text-composer textarea { padding-left: 10px; }
  .after-call { gap: 16px; }
  .panel-header { padding: max(16px,env(safe-area-inset-top)) 20px 16px; }
  .panel-body { padding: 20px; }
  .call-active.welcome-view .conversation-bottom { padding: 14px 0 max(20px,env(safe-area-inset-bottom)); }
@media (max-height: 650px) {
  .app-header { min-height: 58px; }
  .welcome-view .conversation-space { padding-top: 12px; padding-bottom: 20px; }
  .mimi-portrait { width: 148px; padding: 4px; }
  .empty-conversation h1 { font-size: 26px; margin-top: 20px; }
  .welcome-view .conversation-bottom { padding-top: 22px; }
  .conversation-bottom { padding-top: 12px; padding-bottom: 14px; }
  .call-presence { padding: 8px 4px 20px; }
  .mimi-portrait.compact { width: 56px; }
}
@media (max-height: 450px) {
  .call-presence { display: none; }
  .mimi-portrait { width: 100px; }
  .text-composer textarea { max-height: 72px; }
  .empty-conversation h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* One phone-width column of content on every screen; wide screens just center it. */
.mimi-app { width: 100%; max-width: 800px; margin-inline: auto; }
.student-entry { width: 100%; max-width: 480px; margin-inline: auto; }
button, .icon-button, .message-edit, .text-button { min-height: 48px; }
.icon-button, .message-edit { width: 48px; height: 48px; }
button { font-size: 15px; }
button:active:not(:disabled) { opacity: .78; }
.app-header { min-height: 64px; }
.conversation-space { width: 100%; padding-inline: max(16px,env(safe-area-inset-left)) max(16px,env(safe-area-inset-right)); }
.mimi-portrait { width: clamp(128px,calc(26 * var(--mimi-vh)),184px); }
.empty-conversation h1 { font-size: 28px; margin-top: 24px; }
.start-button { width: 100%; min-width: 0; }
.side-panel, .side-panel-left { left: 50%; right: auto; transform: translateX(-50%); width: min(480px,100%); height: var(--app-height,calc(100 * var(--mimi-vh))); bottom: auto; border: 0; }
.panel-body { flex: 1; padding-bottom: max(24px,env(safe-area-inset-bottom)); }
.call-active .control { padding: 10px; }
.student-entry .account-number { font-size: 48px; font-weight: 600; letter-spacing: .2em; text-align: center; color: var(--red); user-select: all; }
@media (max-height: 450px) {
  .mimi-portrait { width: 96px; }
  .account-label { margin-block: 4px; }
  .conversation-bottom, .call-active.welcome-view .conversation-bottom { padding-top: 8px; padding-bottom: max(8px,env(safe-area-inset-bottom)); }
  .voice-feedback { margin-bottom: 8px; }
}

/* Use the actual space above the keyboard: iOS does not resize vh or
   height media queries when only the visual viewport becomes smaller. */
[data-compact-viewport="true"] .app-header { min-height: 48px; padding-block: 0; }
[data-compact-viewport="true"] .account-label,
[data-compact-viewport="true"] .call-presence,
[data-compact-viewport="true"] .empty-conversation,
[data-compact-viewport="true"] .composer-hint,
[data-compact-viewport="true"] .after-call { display: none; }
[data-compact-viewport="true"] .mimi-app .conversation-space { padding: 0 12px; overflow: hidden; }
[data-compact-viewport="true"] .mimi-app .conversation-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0; }
[data-compact-viewport="true"] .mimi-app .conversation-bottom { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 6px 8px; padding: 6px 0; }
[data-compact-viewport="true"] .conversation-bottom > * { grid-column: 1 / -1; margin: 0; }
[data-compact-viewport="true"] .conversation-bottom > .composer-area { grid-column: 1; width: 100%; }
[data-compact-viewport="true"] .conversation-bottom > .call-controls { grid-column: 2; }
[data-compact-viewport="true"] .start-button,
[data-compact-viewport="true"] .control { min-height: 48px; min-width: 0; max-width: 88px; padding: 8px; font-size: 13px; }
[data-compact-viewport="true"] .start-button svg,
[data-compact-viewport="true"] .control svg { display: none; }
[data-compact-viewport="true"] .text-composer { padding: 4px; border-radius: 20px; }
[data-compact-viewport="true"] .composer-entry { gap: 4px; }
[data-compact-viewport="true"] .text-composer textarea { max-height: min(96px,calc(var(--app-height) * .22)); }
[data-compact-viewport="true"] .voice-feedback { min-height: 20px; font-size: 12px; }
[data-compact-viewport="true"] .input-wave { height: 20px; }
[data-compact-viewport="true"] .error-notice,
[data-compact-viewport="true"] .draft-error { max-height: 56px; overflow-y: auto; padding: 6px 10px; }
