[data-screen="text-input"]{gap:12px}
[data-screen="text-input"] label{display:grid;gap:6px}
[data-screen="text-input"] label>.small{font-size:15px;line-height:1.25;color:var(--text)}
[data-screen="text-input"] label>.small b{font-weight:650}
#text-condition{resize:none}
#text-answer.math-rich-input{min-height:52px}
[data-screen="text-input"] .btn.primary{margin-top:4px}
.btn[aria-busy="true"]{opacity:.66;cursor:wait;pointer-events:none}

.math-rows-editor{min-height:104px!important;padding:9px 12px!important}
.math-row{min-height:26px!important;height:auto!important;padding:0!important;line-height:1.12!important}
.math-row + .math-row{margin-top:1px!important}
.math-rows-placeholder{left:12px!important;top:11px!important;gap:0!important;line-height:1.16!important}
.math-rows-editor:not(.has-value) .math-rows-placeholder{opacity:1!important}
.math-rows-editor:focus-within:not(.has-value) .math-rows-placeholder{opacity:.42!important}
.math-rows-editor.has-value .math-rows-placeholder{opacity:0!important}

.math-box{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-size:15px;line-height:1.5}
.student-error{background:var(--card)}
[data-screen="correct"] #correct-final-answer{font-size:16px;font-weight:500}
[data-screen="text-input"] .title{font-size:19px}
[data-screen="text-input"] .subtitle{line-height:1.4}
.screen-body{padding-bottom:20px}
.callout{line-height:1.45}
.btn{transition:background .15s ease,border-color .15s ease,transform .1s ease,opacity .15s ease}
.btn:active{transform:scale(.992)}

[data-screen="tutor"] .tutor-input-toolbar{justify-content:flex-start;margin:0 0 -6px}
[data-screen="tutor"] .tutor-math-toggle{background:var(--accent-soft);color:var(--text);padding:8px 11px;border-radius:10px}
[data-screen="tutor"] .tutor-math-toggle:hover{filter:brightness(.97)}

.markdown-body{font-size:15px;line-height:1.58;overflow-wrap:anywhere}
.markdown-body>*:first-child{margin-top:0}.markdown-body>*:last-child{margin-bottom:0}
.markdown-body p{margin:0 0 10px}
.markdown-body h1,.markdown-body h2,.markdown-body h3{font-size:16px;line-height:1.35;margin:16px 0 8px;font-weight:750}
.markdown-body ul,.markdown-body ol{margin:8px 0 12px;padding-left:22px}
.markdown-body li{margin:5px 0;padding-left:2px}.markdown-body strong{font-weight:750}
.markdown-body code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;background:color-mix(in srgb,var(--text) 6%,transparent);border-radius:6px;padding:1px 5px;font-size:.92em}
.markdown-body blockquote{margin:10px 0;padding:8px 12px;border-left:3px solid var(--border);color:var(--muted)}
.markdown-body .katex-display{overflow-x:auto;overflow-y:hidden;margin:12px 0}
.chat-row.assistant .bubble{padding:14px 15px}.chat-row.user .bubble{white-space:pre-wrap}

.history-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}
.history-heading-copy{min-width:0}
.history-select-trigger{width:44px;height:44px;flex:0 0 44px;border:0;background:transparent;border-radius:12px;color:var(--muted);display:grid;place-items:center;transition:background .18s ease,color .18s ease,transform .18s ease}
.history-select-trigger:hover{background:var(--accent-soft);color:var(--text)}
.history-select-trigger:active{transform:scale(.94)}
.history-select-trigger svg{width:20px;height:20px;display:block}
.history-selection-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;overflow:hidden;max-height:0;opacity:0;transform:translateY(-5px);transition:max-height .22s ease,opacity .18s ease,transform .22s ease}
.history-selection-bar.active{max-height:58px;opacity:1;transform:translateY(0);margin-top:2px}
.history-selection-actions{display:flex;gap:8px}
.history-selection-actions button{min-height:40px;border:0;background:transparent;border-radius:10px;padding:8px 10px;color:var(--muted)}
.history-selection-actions button:not(:disabled):hover{background:var(--accent-soft);color:var(--text)}
.history-selection-actions button:disabled{opacity:.35;cursor:default}
.history-selection-actions .delete-selected{font-weight:700;color:var(--text)}
.history-item{position:relative;padding:0!important;overflow:hidden;transition:background .2s ease,border-color .2s ease,box-shadow .2s ease,transform .2s ease}
.history-main{display:block;width:100%;min-height:88px;padding:14px 48px 14px 14px;border:0;background:transparent;color:var(--text);text-align:left;cursor:pointer}
.history-item.selectable{cursor:pointer}
.history-item.selected{background:var(--accent-soft);box-shadow:0 7px 22px rgba(17,24,39,.07);transform:translateY(-1px)}
.history-item.selected .history-title{transform:translateX(2px)}
.history-title{font-weight:700;line-height:1.35;transition:transform .2s ease}.history-sub{margin-top:5px}.history-date{margin-top:10px;font-size:12px;color:var(--muted)}
.history-menu,.history-check{position:absolute;right:8px;top:8px;width:40px;height:40px;border:0;background:transparent;border-radius:10px;line-height:1;color:var(--muted);display:grid;place-items:center;transition:background .18s ease,color .18s ease,transform .2s ease,opacity .18s ease}
.history-menu{font-size:20px}.history-menu:hover{background:var(--accent-soft)}
.history-check{pointer-events:none}
.history-check-box{width:20px;height:20px;border:1.5px solid var(--border);border-radius:7px;display:grid;place-items:center;background:var(--panel);transition:background .18s ease,border-color .18s ease,transform .18s ease}
.history-item.selected .history-check-box{background:var(--accent);border-color:var(--accent);transform:scale(1.04)}
.history-check-box svg{width:13px;height:13px;opacity:0;transform:scale(.55);color:var(--accent-text);transition:opacity .16s ease,transform .18s ease}
.history-item.selected .history-check-box svg{opacity:1;transform:scale(1)}

:root{
  --app-viewport-height:100vh;
  --app-safe-top:env(safe-area-inset-top,0px);
  --app-safe-right:env(safe-area-inset-right,0px);
  --app-safe-bottom:env(safe-area-inset-bottom,0px);
  --app-safe-left:env(safe-area-inset-left,0px);
}
.phone,.screen{min-height:var(--app-viewport-height)}
.header{padding-top:calc(14px + var(--app-safe-top));padding-left:calc(16px + var(--app-safe-left));padding-right:calc(16px + var(--app-safe-right))}
.screen-body{padding-left:calc(16px + var(--app-safe-left));padding-right:calc(16px + var(--app-safe-right))}
.bottom-nav{padding-left:calc(8px + var(--app-safe-left));padding-right:calc(8px + var(--app-safe-right));padding-bottom:calc(8px + var(--app-safe-bottom))}
.dev-status{top:calc(8px + var(--app-safe-top));right:calc(8px + var(--app-safe-right))}

@media(prefers-reduced-motion:reduce){
  .btn,.history-item,.history-title,.history-check-box,.history-check-box svg,.history-selection-bar,.history-select-trigger{transition:none!important}
}
