@layer base, layout, components, print;

@layer base {
  :root { color-scheme: light; --ink: #233c34; --muted: #5e6b60; --paper: #f6f4ed; --white: #fffefa; --green: #234f42; --line: #d7ddd2; --sage: #e8ede1; --accent: #c6d59c; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--paper); }
  * { box-sizing: border-box; }
  body { margin: 0; }
  h1, h2, h3, p { margin-top: 0; }
  h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; line-height: 1.12; }
  h1 { font-size: clamp(2.6rem, 6vw, 4.7rem); letter-spacing: -.05em; margin-bottom: 24px; }
  h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); letter-spacing: -.025em; }
  h3 { font-size: 1.07rem; line-height: 1.4; }
  a { color: var(--green); text-underline-offset: 4px; }
  button, .button { border: 1px solid var(--green); background: var(--green); color: white; padding: 12px 20px; border-radius: 7px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; line-height: 1.4; }
  button:hover, .button:hover { background: #173c31; }
  button:disabled { opacity: .5; cursor: default; }
  .secondary { color: var(--green); background: transparent; border-color: #b9c4b7; }
  .secondary:hover { background: var(--sage); }
  .text-button { padding: 6px 0; color: var(--green); background: transparent; border: none; text-decoration: underline; text-underline-offset: 4px; text-align: left; }
  .text-button:hover { background: transparent; color: #12271f; }
  button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #7b9547; outline-offset: 4px; }
  textarea, input[type=text], input:not([type]) { width: 100%; font: inherit; color: var(--ink); border: 1px solid #a7b5a2; border-radius: 7px; background: var(--white); padding: 16px; }
  textarea { resize: vertical; display: block; min-height: 100px; line-height: 1.75; }
  textarea:focus, input:focus { outline: 2px solid #708954; outline-offset: 2px; }
  input[type=checkbox], input[type=radio] { accent-color: var(--green); width: 18px; height: 18px; flex-shrink: 0; }
  fieldset { min-width: 0; }
  summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
  details p { margin-top: 10px; }
  small { color: var(--muted); line-height: 1.6; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .skip-link { position: absolute; top: -100px; z-index: 10; background: white; padding: 12px; }
  .skip-link:focus { top: 10px; }
}

@layer layout {
  .masthead, main, .site-footer { max-width: 1180px; margin: auto; padding-left: 40px; padding-right: 40px; }
  .masthead { display: flex; align-items: center; justify-content: space-between; min-height: 100px; border-bottom: 1px solid var(--line); }
  .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-size: .95rem; font-weight: 650; }
  .brand-mark { border-radius: 50%; width: 40px; height: 40px; line-height: 37px; text-align: center; background: var(--green); color: var(--paper); font: italic 28px/37px Georgia, serif; }
  .edition { color: var(--muted); font-size: .8rem; }
  .hero { padding: 60px 0 40px; }
  .hero h1 em { color: #577647; font-weight: 400; }
  .hero p { font-size: 1.15rem; color: var(--muted); margin-bottom: 24px; }
  .hero-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: .8rem; color: var(--muted); }
  .workspace { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 55px; padding: 54px 0; }
  .sidebar { align-self: start; position: sticky; top: 24px; }
  #lesson:focus { outline: none; }
  lesson-panel, lesson-nav, session-panel, results-panel { display: block; }
  .site-footer { padding-top: 35px; padding-bottom: 35px; text-align: center; font-family: Georgia, serif; color: var(--muted); }
  .loading { padding: 50px 0; }
  @media (max-width: 800px) {
    .masthead, main, .site-footer { padding-left: 22px; padding-right: 22px; }
    .masthead { min-height: 80px; }
    .hero { padding-top: 36px; }
    .workspace { grid-template-columns: minmax(0, 1fr); gap: 30px; padding: 30px 0; }
    .sidebar { position: static; }
    .lesson-note { display: none; }
    .edition { display: none; }
  }
}

@layer components {
  .eyebrow { text-transform: uppercase; letter-spacing: .13em; font-size: .68rem; font-weight: 750; display: block; margin-bottom: 16px; color: #58704e; }
  .hero .eyebrow { display: flex; align-items: center; gap: 18px; }
  .level-pill { border: 1px solid #bac6af; padding: 4px 10px; border-radius: 30px; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .75rem; }
  .session-bar { background: #ecefe5; border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; }
  .session-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .87rem; }
  .status { margin-left: auto; font-size: .77rem; color: var(--muted); }
  .status-dot { width: 8px; height: 8px; background: #7c8378; border-radius: 50%; }
  .status-dot.online { background: #2b7547; box-shadow: 0 0 0 4px #d6e7d2; }
  .session-body { display: flex; align-items: center; gap: 25px; margin-top: 12px; }
  .session-body p { flex: 1; margin: 0; font-size: .84rem; }
  .session-body button { flex-shrink: 0; }
  .subtle { color: var(--muted); font-size: .78rem; }
  .session-body .subtle { display: block; margin-top: 4px; }
  .invite { margin-top: 12px; font-size: .84rem; }
  .link-row { display: flex; gap: 10px; margin-top: 10px; }
  .link-row input { min-width: 0; font-size: .8rem; }
  .notice { border-radius: 6px; padding: 12px 16px; margin: 16px 0 0; font-size: .9rem; }
  .error { color: #792d23; background: #f8e8df; }
  .lesson-nav ol { padding: 0; list-style: none; margin: 0; }
  .lesson-nav li { margin: 4px 0; }
  .lesson-nav button { display: flex; align-items: center; gap: 13px; width: 100%; background: transparent; color: var(--muted); border: 1px solid transparent; text-align: left; padding: 11px 12px; font-size: .86rem; font-weight: 500; }
  .lesson-nav button:hover { background: #e9ece1; }
  .lesson-nav button[aria-current=step] { background: var(--green); color: white; }
  .step-number { font-size: .68rem; font-variant-numeric: tabular-nums; }
  .done { margin-left: auto; }
  .progress { margin-top: 26px; padding: 0 12px; }
  progress { width: 100%; height: 5px; appearance: none; border: none; border-radius: 5px; display: block; background: #dee3d5; }
  progress::-webkit-progress-bar { background: #dee3d5; border-radius: 5px; }
  progress::-webkit-progress-value { background: #708954; border-radius: 5px; }
  progress::-moz-progress-bar { background: #708954; }
  .progress p { margin: 10px 0 4px; font-size: .75rem; }
  .progress span { font-size: .7rem; color: var(--muted); line-height: 1.5; display: block; }
  .lesson-note { border-top: 1px solid var(--line); padding: 25px 12px 0; margin-top: 30px; }
  .lesson-note .eyebrow { margin-bottom: 10px; }
  .lesson-note p { font: 1.2rem/1.4 Georgia, serif; margin-bottom: 10px; }
  .lesson-note small { font-size: .76rem; }
  .section-heading { position: relative; margin-bottom: 25px; }
  .section-heading .eyebrow { padding-right: 135px; }
  .duration { position: absolute; right: 0; top: -2px; font-size: .75rem; color: var(--muted); }
  .intro { font-size: .97rem; line-height: 1.8; }
  .theory { border-left: 3px solid #9bae78; background: #e9eddf; padding: 22px 25px; margin: 20px 0; border-radius: 0 7px 7px 0; }
  .theory .eyebrow { margin-bottom: 8px; }
  .theory h3 { margin-bottom: 8px; }
  .theory p, .theory li { font-size: .88rem; line-height: 1.75; }
  .theory p:last-child, .theory ul { margin-bottom: 0; }
  .theory ul { padding-left: 20px; }
  .theory li + li { margin-top: 7px; }
  .writing-task { padding: 30px 0; border-bottom: 1px solid var(--line); }
  .task-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .task-heading h3 { margin-bottom: 12px; }
  .task-kind { color: var(--muted); font-size: .69rem; white-space: nowrap; }
  .writing-task > p { font-size: .92rem; }
  .text-meta { display: flex; justify-content: space-between; gap: 10px; font-size: .69rem; color: var(--muted); margin-top: 8px; }
  .checklist { border: none; padding: 0; margin: 20px 0 8px; }
  .checklist legend { font-size: .8rem; font-weight: 600; margin-bottom: 8px; }
  .checklist label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: .82rem; }
  .help-row { display: flex; flex-wrap: wrap; align-items: start; gap: 8px 24px; margin-top: 18px; font-size: .8rem; }
  .help-row details { flex: 1; }
  .help-row .text-button { font-size: .8rem; }
  .model { padding: 20px; background: #eeeee7; margin-top: 16px; border-radius: 7px; font-size: .87rem; }
  .model p { margin: 10px 0 0; }
  .answer-text { white-space: pre-wrap; overflow-wrap: anywhere; }
  .choice-task { border: none; border-bottom: 1px solid var(--line); padding: 12px 0 24px; margin: 22px 0; }
  .choice-task legend { font-weight: 600; font-size: .96rem; padding: 0; }
  .choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
  .choice { display: flex; gap: 10px; align-items: center; padding: 10px 20px 10px 12px; background: var(--white); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
  .choice:has(:checked) { border-color: var(--green); background: #e5eddc; }
  .feedback { padding: 12px 15px; font-size: .87rem; margin: 10px 0 0; border-radius: 5px; }
  .correct { background: #e0ebd9; }
  .retry { background: #f3e6d0; color: #684b1a; }
  .live-answer { background: var(--white); border: 1px solid var(--line); padding: 20px; min-height: 120px; border-radius: 7px; }
  .tutor-note { border-left: 3px solid #c8a465; padding: 12px 0 12px 16px; margin: 20px 0 0; }
  .tutor-note label { font-size: .82rem; font-weight: 650; display: block; margin-bottom: 8px; }
  .tutor-note small { font-size: .7rem; }
  .role-card { background: var(--green); color: var(--white); border-radius: 9px; padding: 25px 28px; margin-top: 25px; }
  .role-card .eyebrow { color: #d5e0b7; }
  .role-card h3 { font: 1.7rem/1.3 Georgia, serif; }
  .role-card p { font-size: .94rem; line-height: 1.8; margin-bottom: 0; }
  .rounds { padding-left: 22px; font-size: .88rem; }
  .rounds li { padding: 5px 0; }
  .step-actions { display: flex; justify-content: space-between; gap: 15px; margin-top: 30px; }
  .results { display: grid; grid-template-columns: 1fr auto; gap: 40px; padding: 35px; border: 1px solid var(--line); border-radius: 10px; background: #ebeede; }
  .results h2 { font-size: 1.8rem; }
  .results p { font-size: .87rem; margin-bottom: 12px; }
  .results .eyebrow { margin-bottom: 10px; }
  .export-actions { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
  .sources { margin-top: 25px; font-size: .8rem; color: var(--muted); }
  #print-report { display: none; }
  @media (max-width: 800px) {
    .lesson-nav ol { display: flex; flex-wrap: wrap; gap: 4px; }
    .lesson-nav button { padding: 8px 10px; font-size: .75rem; gap: 6px; }
    .lesson-nav .eyebrow { margin-bottom: 8px; }
    .progress { margin-top: 14px; padding: 0; }
    .progress span { display: none; }
    .results { grid-template-columns: 1fr; gap: 15px; padding: 25px; }
    .session-body { align-items: start; flex-direction: column; gap: 15px; }
    .session-heading .status { width: 100%; margin-left: 18px; }
    .session-bar { padding: 18px; }
  }
  @media (max-width: 450px) {
    .section-heading .eyebrow { padding: 0; }
    .duration { position: static; display: block; margin: -6px 0 12px; }
    .step-actions button, .step-actions .button { padding: 10px 12px; font-size: .78rem; }
    .text-meta { flex-direction: column; gap: 0; }
    .task-kind { display: none; }
    .theory { padding: 18px; }
    .link-row { flex-direction: column; }
  }
}

@layer print {
  @media print {
    @page { margin: 18mm; }
    body { background: white; color: black; font-size: 10pt; }
    .masthead, #app, .site-footer, .skip-link, noscript { display: none !important; }
    #print-report { display: block; }
    #print-report h1 { font-size: 24pt; }
    #print-report h2 { font-size: 18pt; margin-top: 22pt; }
    #print-report h3 { font-size: 11pt; }
    #print-report article { border-bottom: 1px solid #bbb; padding: 10pt 0; }
    #print-report h1, #print-report h2, #print-report h3 { break-after: avoid; }
    #print-report .answer-text { border-left: 2px solid #888; padding-left: 10pt; }
  }
}
