:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #0f172a;
  --brand: #3157df;
  --brand-dark: #1d3db4;
  --surface: #f7f8fc;
  --yellow: #fde047;
  --green: #4ade80;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--surface); color: var(--ink); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 10; min-height: 64px; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 2px solid var(--line); background: white;
}
.account-actions { display: flex; align-items: center; gap: 9px; }
.user-name { max-width: 220px; overflow: hidden; color: var(--muted); font-size: .82rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 850; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid var(--line); border-radius: 11px; background: var(--green); box-shadow: 2px 2px 0 var(--line); }
.close-button, .secondary-button { min-height: 44px; padding: 9px 14px; border: 2px solid var(--line); border-radius: 11px; background: white; color: var(--ink); font-weight: 750; box-shadow: 2px 2px 0 rgba(15, 23, 42, .16); }
.close-button:hover, .secondary-button:hover { background: #f1f5f9; }

.shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 48px; }
.auth-shell { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 28px 16px; }
.auth-shell[hidden] { display: none; }
.auth-card { width: min(430px, 100%); display: grid; gap: 17px; padding: 30px; border: 2px solid var(--line); border-radius: 20px; background: white; box-shadow: 6px 6px 0 rgba(15, 23, 42, .15); }
.auth-card h1 { margin: -7px 0 -8px; font-size: 1.85rem; letter-spacing: -.03em; }
.auth-copy { margin: 0 0 5px; color: var(--muted); line-height: 1.5; }
.auth-mark { margin-bottom: 4px; }
.captcha-container { min-height: 58px; overflow: hidden; }
.loading-card { justify-items: center; color: var(--muted); text-align: center; }
.large-spinner { width: 34px; height: 34px; border: 3px solid #cbd5e1; border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.intro { max-width: 720px; }
.intro h1 { margin: 5px 0 8px; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1; letter-spacing: -.045em; }
.intro > p:last-child { margin: 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow { margin: 0; color: var(--brand-dark); font-size: .72rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }

.tool-tabs { display: flex; gap: 9px; margin: 26px 0 16px; overflow-x: auto; padding: 2px 2px 5px; }
.tool-tabs button { min-height: 44px; padding: 10px 18px; border: 2px solid var(--line); border-radius: 999px; background: white; color: var(--ink); font-weight: 800; white-space: nowrap; }
.tool-tabs button.active { background: var(--yellow); box-shadow: 3px 3px 0 var(--line); transform: translateY(-1px); }

.workspace { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(360px, 1.2fr); gap: 18px; align-items: start; }
.generator-card, .result-card { border: 2px solid var(--line); border-radius: 20px; background: white; box-shadow: 5px 5px 0 rgba(15, 23, 42, .14); }
.generator-card { display: grid; gap: 18px; padding: 22px; }
.result-card { min-height: 560px; padding: 22px; }
.form-heading, .result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.form-heading h2, .result-heading h2 { margin: 4px 0 0; font-size: 1.5rem; }
.secure-badge { padding: 5px 9px; border: 1px solid #86efac; border-radius: 999px; background: #dcfce7; color: #166534; font-size: .72rem; font-weight: 800; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 7px; color: #334155; font-size: .85rem; font-weight: 750; }
input, textarea { width: 100%; border: 1.5px solid #cbd5e1; border-radius: 11px; background: white; color: var(--ink); padding: 11px 12px; outline: none; }
textarea { min-height: 132px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49, 87, 223, .15); }

.primary-button { min-height: 50px; border: 2px solid var(--line); border-radius: 12px; background: var(--brand); color: white; font-weight: 850; box-shadow: 3px 3px 0 var(--line); }
.primary-button:hover { background: var(--brand-dark); }
.primary-button:disabled { cursor: wait; opacity: .72; }
.spinner { display: none; width: 18px; height: 18px; margin: auto; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
.primary-button.loading .button-label { display: none; }
.primary-button.loading .spinner { display: block; }
.error { border: 1px solid #fca5a5; border-radius: 10px; background: #fef2f2; color: #991b1b; padding: 11px 12px; font-size: .85rem; font-weight: 650; }

.empty-state { min-height: 510px; display: grid; align-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-state h2 { margin: 12px 0 4px; color: var(--ink); }
.empty-state p { margin: 0; }
.empty-icon { display: grid; place-items: center; width: 58px; height: 58px; border: 2px solid var(--line); border-radius: 17px; background: var(--yellow); color: var(--ink); font-size: 1.8rem; box-shadow: 3px 3px 0 var(--line); }
.result-body { display: grid; gap: 12px; margin-top: 20px; }
.result-item { position: relative; padding: 16px 16px 16px 50px; border: 1px solid #cbd5e1; border-radius: 13px; background: #f8fafc; }
.result-item h3 { margin: 0 0 9px; font-size: 1rem; line-height: 1.4; }
.result-item p, .result-item li { color: #475569; line-height: 1.5; }
.result-item ul, .result-item ol { margin: 7px 0; padding-left: 20px; }
.item-number { position: absolute; top: 15px; left: 14px; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 8px; background: #dbeafe; color: #1e40af; font-size: .78rem; font-weight: 850; }
.answer { margin-bottom: 3px; color: #166534 !important; font-weight: 750; }
.explanation { margin-top: 4px; font-size: .9rem; }
.worksheet-objective { margin: 0; padding: 14px; border-left: 4px solid var(--brand); border-radius: 8px; background: #eff6ff; color: #1e3a8a; font-weight: 700; line-height: 1.5; }
pre { overflow: auto; white-space: pre-wrap; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Teachira workspace: compact controls, generous reading surface. */
:root { --ink: #1a3a6b; --muted: #52647a; --brand: #1a3a6b; --brand-dark: #244e87; --line: #d7e0eb; --surface: #f3f6fa; --teal: #167d74; }
body { line-height: 1.5; }
button, input, textarea { transition: background-color .16s, border-color .16s, box-shadow .16s; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid #167d74; outline-offset: 4px; }
button:disabled { cursor: default; opacity: .55; }
.brand-logo { object-fit: contain; flex-shrink: 0; }
.topbar { border-bottom-width: 1px; }
.shell { width: min(1440px, calc(100% - 48px)); padding-top: 24px; }
.intro h1 { font-size: clamp(1.65rem, 3vw, 2.25rem); line-height: 1.2; letter-spacing: -.035em; }
.intro > p:last-child { font-size: .95rem; }
.eyebrow { color: var(--teal); font-size: .7rem; letter-spacing: .12em; }
.tool-tabs { margin: 22px 0 20px; }
.tool-tabs button { border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; }
.tool-tabs button.active { color: white; background: var(--brand); box-shadow: none; transform: none; }
.workspace { grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); gap: 24px; }
.workspace > *, .field-grid > *, .result-heading > * { min-width: 0; }
.generator-card, .result-card, .auth-card { border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 20px #1a3a6b08; }
.generator-card { position: sticky; top: 88px; gap: 20px; }
.form-heading h2, .result-heading h2 { font-size: 1.2rem; line-height: 1.4; }
.field-grid { grid-template-columns: 1fr; }
input, textarea { font-size: 1rem; font-weight: 400; }
.primary-button { border: 0; box-shadow: none; border-radius: 10px; padding: 12px 16px; }
.close-button, .secondary-button { border: 1px solid var(--line); box-shadow: none; border-radius: 9px; font-size: .82rem; }
.result-card { min-height: 480px; padding: 26px; overflow-wrap: anywhere; }
.result-card { scroll-margin-top: 84px; }
.empty-state { min-height: 426px; padding: 24px; }
.empty-icon { border: 0; box-shadow: none; background: #e7f4f1; color: var(--teal); }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-body { gap: 18px; margin-top: 24px; color: #233650; }
.result-item { padding: 22px; background: white; border-color: var(--line); border-radius: 12px; }
.result-item h3 { font-size: 1.05rem; line-height: 1.6; white-space: pre-wrap; }
.question-label { margin-bottom: 8px; color: var(--teal); font-size: .75rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.quiz-options { display: grid; gap: 8px; list-style: none; padding: 0 !important; margin: 16px 0 !important; }
.quiz-options li { display: flex; align-items: baseline; gap: 12px; padding: 10px 14px; border-radius: 8px; background: var(--surface); }
.option-letter { color: var(--ink); font-weight: 750; flex: 0 0 20px; }
.answer-reveal { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.answer-reveal summary { cursor: pointer; color: var(--teal); font-size: .9rem; font-weight: 700; padding: 8px 0; }
.answer-reveal p { white-space: pre-wrap; }
.flashcard { width: 100%; min-height: 290px; display: grid; align-content: center; justify-items: center; gap: 22px; padding: 32px; border: 1px solid #b7d9d3; border-radius: 16px; background: #f0f9f6; color: var(--ink); }
.flashcard strong { font-size: clamp(1.15rem, 2.5vw, 1.6rem); line-height: 1.5; white-space: pre-wrap; }
.flashcard.is-flipped { background: #eef3fb; border-color: #c6d4e9; }
.flashcard-hint { font-size: .82rem; color: var(--muted); }
.deck-navigation { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.deck-counter { font-size: .9rem; font-variant-numeric: tabular-nums; }
.worksheet-objective { border-left-color: var(--teal); background: #eef8f5; }
.worksheet-section { padding: 6px 0 16px; border-bottom: 1px solid var(--line); }
.worksheet-section h3 { color: var(--ink); font-size: 1.1rem; }
.worksheet-section li { padding: 8px 0 14px 6px; white-space: pre-wrap; }
.worksheet-section li::marker { color: var(--teal); font-weight: 700; }
.worksheet-section.answer-space li { padding-bottom: 40px; border-bottom: 1px dashed var(--line); }
.result-body { animation: reveal .2s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (max-width: 820px) { .generator-card { position: static; } .workspace { grid-template-columns: minmax(0, 1fr); } .field-grid { grid-template-columns: 1fr 1fr; } }
@media print {
  .topbar, .intro, .tool-tabs, .generator-card, .result-actions, .deck-navigation, .flashcard, .empty-state { display: none !important; }
  .shell { width: 100%; padding: 0; } .workspace { display: block; }
  .result-card { border: 0; box-shadow: none; padding: 0; }
  .result-item, .worksheet-section { break-inside: avoid; }
  .print-deck { display: block !important; }
}
.print-deck { display: none; }
.quiz-pages { min-width: 0; }
.quiz-page { min-height: 360px; border: 0; padding: 4px 0 12px; }
.quiz-page h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); font-weight: 650; letter-spacing: -.02em; line-height: 1.5; margin: 12px 0 24px; }
.quiz-page .quiz-options { gap: 12px; }
.quiz-page .quiz-options li { padding: 14px 16px; border: 1px solid var(--line); background: #f8fafc; font-size: 1rem; border-radius: 12px; }
.quiz-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.quiz-pagination .secondary-button { min-width: 100px; width: auto; }
.quiz-pagination .deck-counter { text-align: center; color: var(--muted); }
.quiz-progress { width: 100%; height: 5px; border: 0; border-radius: 10px; overflow: hidden; appearance: none; background: #e6edf3; accent-color: var(--teal); }
.quiz-progress::-webkit-progress-bar { background: #e6edf3; }
.quiz-progress::-webkit-progress-value { background: var(--teal); transition: width .2s ease; }
.quiz-progress::-moz-progress-bar { background: var(--teal); }
@media (max-width: 540px) { .quiz-pagination { gap: 8px; } .quiz-pagination .secondary-button { min-width: 0; padding: 10px; } .quiz-pagination .deck-counter { font-size: .8rem; } }
@media print { .quiz-page[hidden] { display: block !important; } .quiz-page { min-height: 0; break-inside: avoid; } .quiz-pagination, .quiz-progress { display: none !important; } }

@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .result-card { min-height: 420px; }
  .empty-state { min-height: 370px; }
}
@media (max-width: 540px) {
  .shell { width: min(100% - 20px, 1240px); padding-top: 22px; }
  .field-grid { grid-template-columns: 1fr; }
  .generator-card, .result-card { padding: 16px; border-radius: 16px; }
  .result-heading { align-items: stretch; flex-direction: column; }
  .secondary-button { width: 100%; }
  .user-name { display: none; }
  .auth-card { padding: 22px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { gap: 7px; font-size: .85rem; }
  .brand-logo { width: 32px; height: 32px; }
  .auth-mark { width: 64px; height: 61px; }
  .account-actions { gap: 6px; }
  .close-button { padding: 8px; }
  .result-item { padding: 16px; }
  .result-actions .secondary-button { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
