/* Quiz and Ask AI screens */
.study { max-width: 820px; }
.study-title { font-family: var(--font-display); font-size: 1.8rem; margin: 0 0 4px; }
.study-title:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.study-intro { margin: 0 0 16px; color: var(--muted); }
.study-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px; display: grid; gap: 8px; }
.study-card h2 { margin: 0; font-size: 1.1rem; }
.study-options { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.study .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.study .stack { display: grid; gap: 14px; }

/* quiz: choosing notes */
.quiz-notes-box { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; background: var(--bg, var(--surface)); }
.quiz-notes { margin: 0; padding: 0; list-style: none; }
.quiz-note { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 400; cursor: pointer; overflow-wrap: anywhere; }

/* quiz: one question */
.quiz-top { display: grid; gap: 6px; margin-bottom: 12px; }
.quiz-top p { margin: 0; }
.quiz-progress { font-weight: 700; }
.quiz-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.quiz-bar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.2s; }
.quiz-fieldset { padding: 16px; margin-bottom: 12px; }
.quiz-question { font-size: 1.25rem; font-weight: 700; line-height: 1.4; padding: 0 6px; overflow-wrap: anywhere; }
.quiz-question:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.quiz-choices { display: grid; gap: 8px; margin-top: 12px; }
.quiz-choice { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 400; cursor: pointer; flex-wrap: wrap; }
.quiz-choice:hover { border-color: var(--brand); }
.quiz-choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.quiz-choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.quiz-letter { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: inline-grid; place-items: center; font-weight: 700; font-size: 0.9rem; flex: none; }
.quiz-choice-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.quiz-mark { font-weight: 700; font-size: 0.875rem; }
.quiz-choice.is-right, .quiz-choice.is-right:has(input:checked) { border-color: var(--c-green); background: color-mix(in srgb, var(--c-green) 14%, var(--surface)); }
.quiz-choice.is-wrong, .quiz-choice.is-wrong:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }
.quiz-feedback { margin-top: 12px; display: grid; gap: 4px; }
.quiz-feedback p, .quiz-review p { margin: 0; }
.quiz-right { color: var(--c-green); font-weight: 700; }
.quiz-wrong { color: var(--danger); font-weight: 700; }
:root[data-theme="dark"] .quiz-right { color: var(--c-green); }
.quiz-score { text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 20px; margin: 12px 0; }
.quiz-score p { margin: 0; }
.quiz-score-number { font-family: var(--font-display); font-size: 3rem; font-weight: 700; }
.quiz-review { padding: 0; margin: 0; list-style: none; display: grid; gap: 10px; }
.quiz-review-q { font-weight: 700; }

/* ask */
.ask { display: flex; flex-direction: column; gap: 12px; }
.ask-context { display: grid; gap: 4px; }
.ask-log { display: grid; gap: 12px; align-content: start; min-height: 220px; }
.ask-empty { text-align: center; display: grid; justify-items: center; gap: 8px; padding: 16px 0; color: var(--muted); }
.ask-empty h2 { margin: 0; color: var(--ink); }
.ask-examples { display: grid; gap: 8px; width: 100%; max-width: 520px; margin: 0; padding: 0; }
.ask-examples .btn { width: 100%; justify-content: flex-start; text-align: left; height: auto; min-height: 44px; padding-block: 8px; }
.ask-msg { scroll-margin-bottom: 200px; border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; max-width: 100%; overflow-wrap: anywhere; }
.ask-user { background: var(--brand-soft); margin-left: 12%; }
.ask-ai { background: var(--surface); margin-right: 4%; }
.ask-who { margin: 0 0 2px; font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.ask-text { margin: 0; white-space: pre-wrap; }
.ask-text.md { white-space: normal; }
.ask-text.md p { margin: 0 0 0.6em; line-height: 1.6; }
.ask-text.md ul, .ask-text.md ol { margin: 0 0 0.6em; padding-left: 1.5em; }
.ask-text.md li { margin: 0.2em 0; line-height: 1.6; }
.ask-text.md .md-code { margin: 0 0 0.6em; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; overflow-x: auto; font-family: "Source Code Pro", Consolas, monospace; }
.ask-text.md code { font-family: "Source Code Pro", Consolas, monospace; background: var(--surface-2); border-radius: 4px; padding: 0.05em 0.3em; }
.ask-text.md pre code { background: none; padding: 0; }
.ask-tools { margin-top: 6px; }
.ask-tools .btn { min-height: 36px; padding-block: 4px; font-size: 0.9rem; }
.ask-error { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ask-error p { margin: 0; }
.ask-composer { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); display: grid; gap: 8px; background: var(--bg, var(--surface)); padding: 10px 0 4px; border-top: 1px solid var(--line); }
.ask-composer textarea { resize: vertical; min-height: 56px; max-height: 40dvh; }
.ask-symbols { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-symbol { min-width: 44px; padding: 0 8px; font-size: 1.1rem; }

@media (min-width: 720px) {
  .ask-composer { bottom: 0; }
}
@media (max-width: 520px) {
  .study-options { grid-template-columns: 1fr; }
  .ask-user { margin-left: 4%; }
}
