/* Refinements inside the existing cartoon interface. Loaded last.
   Uses the original palette and component shapes from design-system.css;
   only new components (generation flow, inline speech, feedback charts),
   buttons and scrollbars are styled here. Existing pages keep their look. */
:root.atelier-theme {
  --hb-accent: var(--design-accent, #384c86);
  --hb-accent-hover: var(--design-accent-hover, #2e3f70);
  --hb-soft: var(--design-soft, #f1f4fa);
  --hb-line: var(--design-line, #e4e7ed);
  --hb-ink: var(--design-ink, #242935);
  --hb-muted: var(--design-muted, #697384);
  --hb-warm: var(--design-warm, #b08653);
  --hb-ok: var(--design-success, #30735d);
  --hb-bad: var(--design-danger, #b74255);
  --hb-card-shadow: var(--design-shadow, 0 8px 28px rgb(31 45 75 / 5%));
  --hb-card-shadow-hover: 0 14px 34px rgb(31 45 75 / 9%);
  --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 12px; --r-xl: 16px; --r-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --fs-page: 24px; --fs-section: 16px; --fs-body: 14px; --fs-small: 12.5px; --fs-caption: 11.5px;
  --fw-strong: 600; --fw-medium: 500;
}

/* ---------- scrollbars ---------- */
html.atelier-theme { scrollbar-width: thin; scrollbar-color: #c9d1e1 transparent; }
html.atelier-theme * { scrollbar-width: thin; scrollbar-color: #cfd6e4 transparent; }
html.atelier-theme ::-webkit-scrollbar { width: 11px; height: 11px; }
html.atelier-theme ::-webkit-scrollbar-track { background: transparent; }
html.atelier-theme ::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background: #cdd4e2 padding-box; }
html.atelier-theme ::-webkit-scrollbar-thumb:hover { background: #9fadc9 padding-box; }
html.atelier-theme ::-webkit-scrollbar-thumb:active { background: var(--hb-accent) padding-box; }
html.atelier-theme ::-webkit-scrollbar-corner { background: transparent; }
html.atelier-theme :is(.tabs, .admin-navigation, .table-scroll, .admin-table-wrap, .lesson-tools)::-webkit-scrollbar { width: 6px; height: 6px; }
html.atelier-theme :is(.tabs, .admin-navigation, .table-scroll, .admin-table-wrap, .lesson-tools)::-webkit-scrollbar-thumb { border-width: 1px; background: #d8deea padding-box; }

/* ==========================================================
   BUTTON SYSTEM — one set of sizes and states in the original palette.
   Anchored on #app / #modal-root so page-specific legacy sizes cannot drift.
   ========================================================== */
:root.atelier-theme {
  --btn-h: 40px; --btn-h-sm: 34px; --btn-r: var(--r-lg); --btn-r-sm: var(--r-md);
  --btn-ring: 0 0 0 3px rgb(56 76 134 / 22%);
  --btn-ease: cubic-bezier(.2,.8,.2,1);
}
@media (pointer: coarse) { :root.atelier-theme { --btn-h: 44px; --btn-h-sm: 44px; } }

html.atelier-theme body :is(#app, #modal-root) :is(.btn, .login-button, .generation-send, .auth-submit) {
  display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 7px !important;
  min-height: var(--btn-h) !important; height: auto !important; padding: 0 16px !important; border-radius: var(--btn-r) !important;
  font-size: var(--fs-body) !important; font-weight: var(--fw-strong) !important; line-height: 1.2 !important; letter-spacing: 0; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; text-decoration: none !important;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .18s ease, transform .16s var(--btn-ease) !important;
}
html.atelier-theme body :is(#app, #modal-root) :is(.btn.small, .login-button) { min-height: var(--btn-h-sm) !important; padding: 0 var(--sp-3) !important; border-radius: var(--btn-r-sm) !important; font-size: var(--fs-small) !important; }
html.atelier-theme body :is(#app, #modal-root) :is(.btn, .login-button, .generation-send, .auth-submit) .icon { width: 16px; height: 16px; flex: none; transition: transform .18s var(--btn-ease); }
html.atelier-theme body :is(#app, #modal-root) :is(.btn.small, .login-button) .icon { width: 14px; height: 14px; }

/* Primary */
html.atelier-theme body :is(#app, #modal-root) :is(.btn:not(.ghost):not(.secondary):not(.soft):not(.danger):not([data-danger="true"]), .login-button, .generation-send, .auth-submit) {
  color: #fff !important; background: var(--hb-accent) !important; border: 1px solid var(--hb-accent) !important;
  box-shadow: 0 1px 2px rgb(31 45 75 / 10%), inset 0 1px 0 rgb(255 255 255 / 12%) !important;
}
html.atelier-theme body :is(#app, #modal-root) :is(.btn:not(.ghost):not(.secondary):not(.soft):not(.danger):not([data-danger="true"]), .login-button, .generation-send, .auth-submit):is(:hover, :focus-visible):not(:disabled):not([aria-disabled="true"]) {
  background: var(--hb-accent-hover) !important; border-color: var(--hb-accent-hover) !important; box-shadow: 0 6px 16px rgb(56 76 134 / 24%) !important;
}
html.atelier-theme body :is(#app, #modal-root) :is(.btn:not(.ghost):not(.secondary):not(.soft):not(.danger):not([data-danger="true"]), .login-button, .generation-send, .auth-submit):is(:hover, :focus-visible):not(:disabled):not([aria-disabled="true"]):not(.st-magnetic) { transform: translateY(-1px); }
/* Secondary */
html.atelier-theme body :is(#app, #modal-root) .btn.secondary {
  color: #3c4a64 !important; background: #fff !important; border: 1px solid #d9dfe8 !important; box-shadow: 0 1px 2px rgb(31 45 75 / 4%) !important;
}
html.atelier-theme body :is(#app, #modal-root) .btn.secondary:is(:hover, :focus-visible):not(:disabled) { color: var(--hb-accent) !important; background: #f7f9fd !important; border-color: #aebdd8 !important; box-shadow: 0 4px 12px rgb(31 45 75 / 8%) !important; }
html.atelier-theme body :is(#app, #modal-root) .btn.secondary:is(:hover, :focus-visible):not(:disabled):not(.st-magnetic) { transform: translateY(-1px); }
/* Soft (tonal) */
html.atelier-theme body :is(#app, #modal-root) .btn.soft { color: var(--hb-accent) !important; background: #eef2fa !important; border: 1px solid transparent !important; box-shadow: none !important; }
html.atelier-theme body :is(#app, #modal-root) .btn.soft:is(:hover, :focus-visible):not(:disabled) { background: #e3e9f6 !important; }
html.atelier-theme body :is(#app, #modal-root) .btn.soft:is(:hover, :focus-visible):not(:disabled):not(.st-magnetic) { transform: translateY(-1px); }
/* Danger */
html.atelier-theme body :is(#app, #modal-root) :is(.btn.danger, .btn[data-danger="true"], .account-signout) { color: var(--hb-bad) !important; background: #fff5f6 !important; border: 1px solid #edcbd2 !important; box-shadow: none !important; }
html.atelier-theme body :is(#app, #modal-root) :is(.btn.danger, .btn[data-danger="true"], .account-signout):is(:hover, :focus-visible):not(:disabled) { background: #ffeaee !important; border-color: #e3aab6 !important; }
/* Press, focus, disabled */
html.atelier-theme body :is(#app, #modal-root) :is(.btn, .login-button, .generation-send, .auth-submit):active:not(:disabled) { box-shadow: 0 1px 2px rgb(31 45 75 / 10%) !important; transition-duration: .06s !important; }
html.atelier-theme body :is(#app, #modal-root) :is(.btn, .login-button, .generation-send, .auth-submit):active:not(:disabled):not(.st-magnetic) { transform: translateY(0) scale(.97) !important; }
html.atelier-theme body :is(#app, #modal-root) :is(.btn, .login-button, .generation-send, .auth-submit):focus-visible { outline: none !important; box-shadow: var(--btn-ring) !important; }
html.atelier-theme body :is(#app, #modal-root) :is(.btn, .login-button, .generation-send, .auth-submit):is(:disabled, [aria-disabled="true"]) {
  color: #8a93a3 !important; background: #eef0f4 !important; border-color: #e3e7ee !important; box-shadow: none !important; transform: none !important; cursor: not-allowed !important; opacity: 1 !important;
}
/* Trailing arrows nudge forward; leading icons stay put. */
html.atelier-theme body :is(#app, #modal-root) :is(.btn, .generation-send, .link-btn, .reference-preview):hover:not(:disabled) > .icon:last-child:not(:first-child) { transform: translateX(3px); }
/* Busy: a calm dim instead of a spinner (data-busy from the app, aria-busy elsewhere). */
html.atelier-theme body :is(#app, #modal-root) :is(.btn, .generation-send, .admin-button, .vocab-actions button):is([data-busy], [aria-busy="true"]) { opacity: .72 !important; cursor: progress !important; }

/* Text links read as actions without looking like buttons. */
html.atelier-theme body :is(#app, #modal-root) :is(.link-btn, .reference-preview) {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; border: 0; background: none; color: var(--hb-accent) !important;
  font-size: 13px !important; font-weight: 600 !important; text-decoration: none !important; cursor: pointer;
  background-image: linear-gradient(currentColor, currentColor); background-size: 0 1.5px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size .22s var(--btn-ease), color .16s ease;
}
html.atelier-theme body :is(#app, #modal-root) :is(.link-btn, .reference-preview):is(:hover, :focus-visible) { color: var(--hb-accent-hover) !important; background-size: 100% 1.5px; }
html.atelier-theme body :is(#app, #modal-root) :is(.link-btn, .reference-preview) .icon { width: 14px; height: 14px; transition: transform .18s var(--btn-ease); }

/* Chips and pills that act as buttons. */
html.atelier-theme body :is(#app, #modal-root) button.pill { cursor: pointer; transition: border-color .16s ease, color .16s ease, background-color .16s ease, transform .16s var(--btn-ease); }
html.atelier-theme body :is(#app, #modal-root) button.pill:hover { color: var(--hb-accent); border-color: #c7d3e8; background-color: #f7f9fd; }
html.atelier-theme body :is(#app, #modal-root) button.pill:active { transform: scale(.96); }
/* Icon-only buttons share one shape. */
html.atelier-theme body :is(#app, #modal-root) :is(.st-icon-btn, .history-refresh, .close-history) { width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 10px; transition: background-color .16s ease, border-color .16s ease, transform .16s var(--btn-ease); }
html.atelier-theme body :is(#app, #modal-root) :is(.st-icon-btn, .history-refresh, .close-history):active { transform: scale(.92); }
/* Compact card actions (listen / save) share one chip shape. */
html.atelier-theme body :is(#app, #modal-root) .vocab-actions { display: flex; gap: 6px; }
html.atelier-theme body :is(#app, #modal-root) .vocab-actions button {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 10px; border: 1px solid #e1e6ef; border-radius: 9px; background: #fff;
  color: #4d5a72; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background-color .16s ease, transform .16s var(--btn-ease);
}
html.atelier-theme body :is(#app, #modal-root) .vocab-actions button:hover { color: var(--hb-accent); border-color: #c7d3e8; background: #f7f9fd; }
html.atelier-theme body :is(#app, #modal-root) .vocab-actions button:active { transform: scale(.95); }
html.atelier-theme body :is(#app, #modal-root) .vocab-actions button .icon { width: 14px; height: 14px; }
/* Admin keeps its look; only sizing and states align. */
html.atelier-theme body :is(#app, #modal-root) .admin-button { min-height: 36px; border-radius: 10px; transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s var(--btn-ease), box-shadow .18s ease; }
html.atelier-theme body :is(#app, #modal-root) .admin-button:not(:disabled):hover { transform: translateY(-1px); }
html.atelier-theme body :is(#app, #modal-root) .admin-button:not(:disabled):active { transform: scale(.97); }
html.atelier-theme body :is(#app, #modal-root) .admin-button:focus-visible { outline: none; box-shadow: var(--btn-ring); }
/* Every interactive control: pointer, no tap flash, clear disabled cursor. */
html.atelier-theme body :is(button, [role="button"], summary) { -webkit-tap-highlight-color: transparent; }
html.atelier-theme body :is(button, [role="button"]):not(:disabled) { cursor: pointer; }
html.atelier-theme body button:disabled { cursor: not-allowed; }
/* Confirmation after "save word" and similar one-shot actions. */
html.atelier-theme body .st-done { color: var(--hb-ok) !important; border-color: #cfe6da !important; background-color: #f1f8f4 !important; }
/* No spinning or rotating feedback inside buttons (sign-in, admin loading, done states). */
html.atelier-theme body :is(button, .btn, .admin-loading) .icon { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  html.atelier-theme body :is(#app, #modal-root) :is(.btn, .login-button, .generation-send, .auth-submit, .admin-button, button.pill) { transform: none !important; }
}

/* ---------- chapter tabs: one segmented control ---------- */
html.atelier-theme body :is(#app) .main.page-lesson .tabs {
  display: grid !important; grid-template-columns: repeat(6, minmax(0, 1fr)) !important; gap: 4px !important; align-items: stretch;
  padding: 5px !important; margin: 0 0 22px !important; border: 1px solid var(--hb-line) !important; border-radius: 16px !important; background: #fff !important;
  box-shadow: var(--hb-card-shadow) !important; overflow: visible;
}
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab {
  position: relative; z-index: 1; display: inline-flex !important; flex-direction: row !important; align-items: center !important; justify-content: center !important; gap: 7px !important;
  min-height: 44px !important; height: auto !important; padding: 0 10px !important; border: 0 !important; border-radius: 12px !important; background: transparent !important;
  color: #6a7487 !important; font-size: 13.5px !important; font-weight: 600 !important; line-height: 1.2 !important; white-space: nowrap; box-shadow: none !important; cursor: pointer;
  transition: color .2s ease, background-color .2s ease !important;
}
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab::after { display: none !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab > .icon { width: 16px !important; height: 16px !important; opacity: 1 !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab:not(.active):hover { color: var(--hb-ink) !important; background: #f4f6fa !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab.active { color: #fff !important; background: transparent !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs:not(.st-has-ink) .tab.active { background: var(--hb-accent) !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab:focus-visible { outline: none !important; box-shadow: var(--btn-ring) !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab:active { transform: scale(.97); }
/* The sliding indicator is the active pill itself. */
html.atelier-theme body :is(#app) .main.page-lesson .tabs .st-ink {
  top: 5px !important; bottom: 5px !important; border-radius: 12px !important; background: var(--hb-accent) !important; box-shadow: 0 4px 12px rgb(56 76 134 / 22%) !important;
  transition: transform .35s cubic-bezier(.3,.7,.2,1), width .35s cubic-bezier(.3,.7,.2,1) !important;
}
html.atelier-theme body :is(#app) .main.page-lesson .tabs .st-ink::after { display: none !important; }
/* Completed chapters: a small check badge, never a second highlight. */
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab-complete {
  display: inline-grid !important; place-items: center; width: 16px !important; height: 16px !important; border-radius: 50% !important; color: #fff !important; background: var(--hb-ok) !important;
}
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab-complete .icon { width: 10px !important; height: 10px !important; stroke-width: 3 !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab.active .tab-complete { color: var(--hb-accent) !important; background: #fff !important; }
html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab.completed:not(.active) { color: #3f4a5f !important; }
@media (max-width: 760px) {
  html.atelier-theme body :is(#app) .main.page-lesson .tabs { display: flex !important; overflow-x: auto !important; scrollbar-width: none; }
  html.atelier-theme body :is(#app) .main.page-lesson .tabs::-webkit-scrollbar { display: none; }
  html.atelier-theme body :is(#app) .main.page-lesson .tabs .tab { flex: 0 0 auto; padding: 0 14px !important; min-height: 40px !important; font-size: 13px !important; }
}

/* ---------- lesson progress merged into the title and tab bar ---------- */
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .lesson-overview.st-merged { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip-path: inset(50%); border: 0; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .tabs .st-tab-progress { position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; overflow: hidden; border-radius: 3px; background: transparent; pointer-events: none; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .tabs .st-tab-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #9fb0d6, var(--hb-accent)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .st-progress-pill { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 5px 12px; border: 1px solid var(--hb-line); border-radius: 999px; background: #fff; color: var(--hb-muted); font-size: 12px; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .st-progress-pill b { color: var(--hb-accent); font-weight: 650; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .st-progress-mini { width: 64px; height: 5px; overflow: hidden; border-radius: 5px; background: var(--hb-soft); }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .st-progress-mini i { display: block; height: 100%; border-radius: inherit; background: var(--hb-accent); }

/* ---------- inline speech ---------- */
html.atelier-theme body .st-speaking { position: relative; color: var(--hb-accent) !important; }
html.atelier-theme body .st-speaking[data-st-state="loading"] { cursor: progress; }
html.atelier-theme body .st-speaking[data-st-state="loading"] { opacity: .72; animation: none; }
html.atelier-theme body .st-speaking[data-st-state="playing"] { background-color: var(--hb-soft) !important; box-shadow: 0 0 0 3px rgb(56 76 134 / 12%); animation: none; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson #lesson-content .article-paragraph.st-reading { background: linear-gradient(90deg, rgb(241 244 250 / 95%), rgb(241 244 250 / 0%)); box-shadow: -18px 0 0 0 rgb(241 244 250 / 95%); }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson #lesson-content .article-paragraph.st-reading::before { transform: scaleY(1); }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson #lesson-content .article-paragraph.st-reading .st-para-tools { opacity: 1; transform: none; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson #lesson-content .st-inline-listen { display: inline-grid; vertical-align: middle; margin-left: 8px; }
/* The fallback player must expose Play/Download when mobile autoplay is blocked. */
html.atelier-theme body .speech-player-host[hidden] { display: none !important; }
html.atelier-theme body .speech-player-host:not([hidden]) { display: block; }
html.atelier-theme body .st-speech-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; line-height: 1.6; }
html.atelier-theme body .st-speech-actions [role="status"] { flex: 1 1 220px; color: var(--hb-muted); }
html.atelier-theme body .st-speaking[data-st-state="ready"] { background-color: var(--hb-soft) !important; }

/* ---------- AI feedback: radar + correction links ---------- */
html.atelier-theme body .panel.st-reported .score-ring { display: inline-grid; vertical-align: middle; }
html.atelier-theme body .st-radar { position: relative; display: inline-block; width: min(260px, 70%); margin: 4px 0 10px 64px; vertical-align: middle; aspect-ratio: 1; }
html.atelier-theme body .st-radar svg { width: 100%; height: 100%; overflow: visible; }
html.atelier-theme body .st-radar .grid { fill: none; stroke: #e6eaf2; stroke-width: 1; }
html.atelier-theme body .st-radar .axis { stroke: #e6eaf2; stroke-width: 1; }
html.atelier-theme body .st-radar .area { fill: rgb(56 76 134 / 16%); stroke: var(--hb-accent); stroke-width: 2; stroke-linejoin: round; transform-origin: 110px 110px; transform: scale(.2); opacity: 0; transition: transform .9s cubic-bezier(.34,1.56,.64,1), opacity .4s ease; }
html.atelier-theme body .st-radar .dot { fill: #fff; stroke: var(--hb-accent); stroke-width: 2; opacity: 0; transition: opacity .3s ease calc(var(--i) * 80ms + .6s); }
html.atelier-theme body .panel.st-go .st-radar .area { transform: none; opacity: 1; }
html.atelier-theme body .panel.st-go .st-radar .dot { opacity: 1; }
html.atelier-theme body .st-radar-label { position: absolute; transform: translate(-50%, -50%); color: #5a6478; font-size: 11px; white-space: nowrap; text-align: center; line-height: 1.3; }
html.atelier-theme body .st-radar-label b { display: block; color: var(--hb-accent); font-size: 12px; }
html.atelier-theme body .st-hidden-fix { display: none !important; }
html.atelier-theme body .st-fixes { display: grid; gap: 8px; margin: 14px 0; }
html.atelier-theme body .st-fixes h4 { margin: 0 0 2px; color: var(--hb-ink); font-size: 13px; font-weight: 650; }
html.atelier-theme body .st-fix { display: grid; grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr); align-items: center; gap: 6px 4px; padding: 10px 12px; border: 1px solid #e8ecf3; border-radius: 13px; background: #fafbfd; animation: st-chapter-in .35s ease both; animation-delay: calc(var(--i) * 90ms); }
html.atelier-theme body .st-fix-from { justify-self: end; padding: 4px 9px; border-radius: 8px; color: #8a4a57; background: #fff3f5; text-decoration: line-through; text-decoration-color: rgb(183 66 85 / 55%); font-size: 14px; }
html.atelier-theme body .st-fix-to { justify-self: start; padding: 4px 9px; border-radius: 8px; color: var(--hb-ok); background: #eef7f2; font-size: 14px; font-weight: 600; }
html.atelier-theme body .st-fix :is(.st-fix-from, .st-fix-to) em { font-style: normal; text-decoration: none; opacity: .75; }
html.atelier-theme body .st-fix-link { width: 76px; height: 24px; overflow: visible; }
html.atelier-theme body .st-fix-link path { fill: none; stroke: #9fb0d6; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
html.atelier-theme body .st-fix-link path:first-child { stroke-dasharray: 1; stroke-dashoffset: 1; animation: st-draw .6s cubic-bezier(.2,.8,.2,1) forwards; animation-delay: calc(var(--i) * 90ms + .25s); }
html.atelier-theme body .st-fix p { grid-column: 1 / -1; margin: 0; color: var(--hb-muted); font-size: 12px; line-height: 1.6; text-align: center; }
@media (max-width: 560px) { html.atelier-theme body .st-fix { grid-template-columns: minmax(0, 1fr) 46px minmax(0, 1fr); } html.atelier-theme body .st-fix-link { width: 46px; } }
@media (prefers-reduced-motion: reduce) { html.atelier-theme body .st-fix-link path:first-child { stroke-dashoffset: 0; } html.atelier-theme body .st-radar :is(.area, .dot) { transform: none; opacity: 1; transition: none; } }
html.atelier-theme body.reduce-motion .st-fix-link path:first-child { stroke-dashoffset: 0; }
html.atelier-theme body.reduce-motion .st-radar :is(.area, .dot) { transform: none; opacity: 1; transition: none; }

/* ---------- teacher: class level spread ---------- */
html.atelier-theme body .st-level-spread { margin: 12px 0 14px; }
html.atelier-theme body .st-level-bar { display: flex; height: 30px; overflow: hidden; border-radius: 10px; background: var(--hb-soft); }
html.atelier-theme body .st-level-bar i { display: grid; place-items: center; min-width: 26px; animation: st-bar-grow .7s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 90ms); transform-origin: 0 50%; }
html.atelier-theme body .st-level-bar b { color: #fff; font-size: 12px; font-weight: 650; }
html.atelier-theme body .st-level-bar em { align-self: center; padding: 0 12px; color: var(--hb-muted); font-size: 12px; font-style: normal; }
@keyframes st-bar-grow { from { transform: scaleX(0); } }
html.atelier-theme body :is(.st-level-bar, .st-level-legend) .lv0 { background: #9fb0d6; }
html.atelier-theme body :is(.st-level-bar, .st-level-legend) .lv1 { background: #7b90c4; }
html.atelier-theme body :is(.st-level-bar, .st-level-legend) .lv2 { background: #5a70ad; }
html.atelier-theme body :is(.st-level-bar, .st-level-legend) .lv3 { background: #43589a; }
html.atelier-theme body :is(.st-level-bar, .st-level-legend) .lv4 { background: #2e3f70; }
html.atelier-theme body .st-level-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; color: var(--hb-muted); font-size: 12px; }
html.atelier-theme body .st-level-legend span { display: inline-flex; align-items: center; gap: 6px; }
html.atelier-theme body .st-level-legend i { width: 10px; height: 10px; border-radius: 3px; }
html.atelier-theme body .st-level-legend b { color: var(--hb-ink); font-weight: 650; }

/* ==========================================================
   HOME: title, the course input and example topics only.
   The original centered single-screen layout is kept.
   ========================================================== */
html.atelier-theme body.home-mode .st-hero-sub { margin: 10px auto 0; max-width: 32em; color: var(--hb-muted); font-size: 15px; line-height: 1.8; text-align: center; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home:not(.has-generation) .suggestion-row .topic-suggestion:nth-child(n) {
  display: grid !important; grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: auto auto !important; justify-items: center !important; align-content: center; gap: 6px; text-align: center;
}
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home:not(.has-generation) .suggestion-row .topic-suggestion > * { grid-column: 1 !important; grid-row: auto !important; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home:not(.has-generation) .suggestion-row .topic-suggestion .suggestion-copy { display: block; width: auto; text-align: center; }
/* Composer: one rounded card with a quiet toolbar (layout idea from ZaoWuAi, HanBridge palette). */
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .generation-composer {
  padding: 16px 16px 12px !important; border: 1px solid #d9dfea !important; border-radius: 22px !important; background: #fff !important;
  box-shadow: 0 13px 36px rgb(31 45 75 / 8%), 0 2px 6px rgb(31 45 75 / 4%) !important; transition: border-color .2s ease, box-shadow .2s ease;
}
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .generation-composer::before { display: none !important; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .generation-composer:focus-within { border-color: #9fb0d6 !important; box-shadow: 0 13px 36px rgb(31 45 75 / 10%), 0 0 0 3px rgb(56 76 134 / 10%) !important; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home #generation-prompt { font-size: 15.5px !important; line-height: 1.7 !important; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .composer-bottom { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .composer-settings { display: flex; align-items: center; gap: 8px; min-width: 0; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .composer-level { min-height: 30px; padding: 0 4px 0 11px !important; border: 1px solid #e3e8f0 !important; border-radius: 999px !important; background: #f6f8fb !important; font-size: 12px; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .composer-level .hb-select-trigger { min-height: 28px; border: 0 !important; background: transparent !important; box-shadow: none !important; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .composer-cost { color: #98a1b3; font-size: 11.5px; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .st-composer-hint { margin-left: auto; color: #a3abba; font-size: 11.5px; white-space: nowrap; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .composer-submit { margin-left: 0; }
html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .generation-send { min-height: 36px !important; padding: 0 16px !important; border-radius: 999px !important; }
@media (max-width: 640px) { html.atelier-theme body.home-mode .main.page-home .generation-home.st-home .st-composer-hint { display: none; } }
html.atelier-theme body.home-mode .generation-home.st-home .topic-suggestion .suggestion-image { transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
html.atelier-theme body.home-mode .generation-home.st-home .topic-suggestion:hover .suggestion-image { transform: scale(1.08); }

/* ==========================================================
   GENERATION: one clean progress panel
   ========================================================== */
/* The flow graph and status line replace the older progress pieces. */
html.atelier-theme body.home-mode .course-progress.st-flowing :is(.progress-pipeline, .progress-track, .progress-overview, .progress-orbit, .progress-artwork, .progress-footer, .progress-current-detail, .progress-context) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
html.atelier-theme body.home-mode .main.page-home .generation-home.has-generation .course-progress.st-flowing { margin-top: 14px; padding-top: 16px; }
html.atelier-theme body.home-mode .main.page-home .generation-home.has-generation .course-progress.st-flowing .course-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
html.atelier-theme body.home-mode .main.page-home .generation-home.has-generation .course-progress.st-flowing .progress-heading h2 { margin: 2px 0 0; font-size: 18px; font-weight: 650; }
html.atelier-theme body.home-mode .main.page-home .generation-home.has-generation .course-progress.st-flowing .progress-badge { margin-left: auto; }

html.atelier-theme body.home-mode .st-flow { position: relative; width: 100%; margin: 14px 0 0; border: 1px solid #e8ecf3; border-radius: 16px; background: #fafbfd; }
html.atelier-theme body.home-mode .st-flow > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
html.atelier-theme body.home-mode .st-edge { fill: none; stroke-width: 2; stroke-linecap: round; vector-effect: non-scaling-stroke; transition: stroke .4s ease; }
html.atelier-theme body.home-mode .st-edge.is-waiting { stroke: #dfe4ec; stroke-dasharray: .01 .016; }
html.atelier-theme body.home-mode .st-edge.is-done { stroke: var(--hb-accent); }
html.atelier-theme body.home-mode .st-edge.is-done.is-fresh { stroke-dasharray: 1; stroke-dashoffset: 1; animation: st-draw .8s cubic-bezier(.4,0,.2,1) forwards; }
html.atelier-theme body.home-mode .st-edge.is-flow { stroke: #c3cee5; }
html.atelier-theme body.home-mode .st-edge.is-failed { stroke: #e6bcc5; stroke-dasharray: .02 .02; }
html.atelier-theme body.home-mode .st-packet { fill: var(--hb-accent); }

html.atelier-theme body.home-mode .st-agent { position: absolute; display: grid; justify-items: center; gap: 2px; width: 112px; transform: translate(-50%, -24px); text-align: center; }
html.atelier-theme body.home-mode .st-agent-orb {
  position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: #9aa3b5; background: #fff;
  border: 1.5px solid #e1e6ef; transition: background-color .35s ease, border-color .35s ease, color .35s ease, box-shadow .35s ease;
}
html.atelier-theme body.home-mode .st-agent-orb .icon { width: 20px; height: 20px; }
html.atelier-theme body.home-mode .st-agent strong { margin-top: 6px; color: #4a5468; font-size: 12.5px; font-weight: 600; }
html.atelier-theme body.home-mode .st-agent small { color: #a0a8b8; font-size: 11px; }
html.atelier-theme body.home-mode .st-agent.is-done .st-agent-orb { color: #fff; background: var(--hb-accent); border-color: var(--hb-accent); }
html.atelier-theme body.home-mode .st-agent.is-done strong { color: var(--hb-ink); }
/* Active: a steady accent ring. */
html.atelier-theme body.home-mode .st-agent.is-active .st-agent-orb { color: var(--hb-accent); border-color: var(--hb-accent); box-shadow: 0 0 0 4px rgb(56 76 134 / 12%); }
html.atelier-theme body.home-mode .st-agent.is-active strong { color: var(--hb-accent); }
html.atelier-theme body.home-mode .st-agent.is-failed .st-agent-orb { color: #fff; background: var(--hb-bad); border-color: var(--hb-bad); }

html.atelier-theme body.home-mode .st-branch {
  position: absolute; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; transform: translate(-50%, -50%); white-space: nowrap;
  border: 1px solid #e3e8f0; border-radius: 10px; background: #fff; color: #9aa3b5; font-size: 12px; font-weight: 600;
  transition: color .35s ease, border-color .35s ease, background-color .35s ease;
}
html.atelier-theme body.home-mode .st-branch .icon { width: 14px; height: 14px; }
html.atelier-theme body.home-mode .st-branch.is-core { padding: 7px 12px; border-radius: 12px; }
html.atelier-theme body.home-mode .st-branch.is-active { color: var(--hb-accent); border-color: #c7d3e8; background: #f4f6fb; }
html.atelier-theme body.home-mode .st-branch.is-done { color: var(--hb-ok); border-color: #d2e6dc; background: #f3f9f6; }
html.atelier-theme body.home-mode .st-branch.is-failed { color: var(--hb-bad); border-color: #efd2d8; background: #fff6f8; }

/* Status line under the graph. */
html.atelier-theme body.home-mode .st-flow-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 12px 2px 4px; color: var(--hb-muted); font-size: 12.5px; }
html.atelier-theme body.home-mode .st-flow-status strong { flex: 1 1 260px; min-width: 0; color: var(--hb-ink); font-size: 13.5px; font-weight: 600; }
html.atelier-theme body.home-mode .st-flow-detail { flex: 1 0 100%; padding-left: 20px; font-size: 12px; line-height: 1.5; }
html.atelier-theme body.home-mode .st-flow-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--hb-accent); }
html.atelier-theme body.home-mode .st-flow-status:is(.is-done) .st-flow-dot { background: var(--hb-ok); animation: none; }
html.atelier-theme body.home-mode .st-flow-status:is(.is-failed, .is-uncertain) .st-flow-dot { background: var(--hb-bad); animation: none; }
html.atelier-theme body.home-mode :is(.st-flow-step, .st-flow-time) { padding: 3px 9px; border: 1px solid var(--hb-line); border-radius: 999px; background: #fff; font-variant-numeric: tabular-nums; }
html.atelier-theme body.home-mode .st-flow-step { color: var(--hb-accent); font-weight: 600; }

/* Result card: a stable 16:9 illustration and a compact copy/action column. */
html.atelier-theme body .main[class] .generation-result { display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr) !important; align-items: center; gap: 18px; }
html.atelier-theme body .main[class] .generation-result .result-visual { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r-lg); background: #f6f7fb; }
html.atelier-theme body .main[class] .generation-result .result-visual > img {
  display: block !important; width: 100% !important; height: auto !important; min-height: 0 !important; aspect-ratio: 16 / 9; align-self: start !important;
  border-radius: var(--r-lg); object-fit: contain !important; background: #f6f7fb !important;
}
html.atelier-theme body .main[class] .generation-result .result-visual > img:is([data-generated-art], [src*="/media/course-art/"]) { object-fit: cover !important; }
html.atelier-theme body .shell .main[class] .generation-result .result-copy { display: block; min-width: 0; padding: 14px 16px 14px 0; }
html.atelier-theme body .main[class] .generation-result .result-saved { display: inline-block; padding: 2px 7px; border-radius: 6px; color: #30735d; background: #eef7f2; font-size: 11px; }
html.atelier-theme body .main[class] .generation-result .result-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 7px 0; }
html.atelier-theme body .main[class] .generation-result .result-title h2 { margin: 0; font-size: 19px; line-height: 1.35; }
html.atelier-theme body .main[class] .generation-result .result-review-note { display: inline-block; vertical-align: middle; margin-left: 8px; padding: 2px 6px; border: 1px solid #ecdfbd; border-radius: 6px; background: #fff8e9; color: #896321; font-size: 10px; font-weight: 500; }
html.atelier-theme body .main[class] .generation-result .result-chapters { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; }
html.atelier-theme body .main[class] .generation-result .result-chapters a { padding: 4px 7px; font-size: 11px; }
html.atelier-theme body .main[class] .generation-result .result-details { margin: 7px 0; font-size: 12px; }
html.atelier-theme body .main[class] .generation-result .result-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
html.atelier-theme body #app .main[class] .generation-result .result-actions .btn { margin: 0; min-height: 34px !important; padding: 6px 12px !important; font-size: 12px !important; }
html.atelier-theme body .main[class] .generation-result.st-art-ready img { animation: st-appear .6s ease both; }
html.atelier-theme body :is(.result-visual, .lesson-visual) { position: relative; }
html.atelier-theme body .course-art-overlay { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: flex-end; padding: 10px; pointer-events: none; border-radius: inherit; overflow: hidden; }
html.atelier-theme body .course-art-overlay [data-course-art-retry] { position: relative; pointer-events: auto; min-height: 30px; margin: 0; padding: 4px 9px; background: rgb(255 255 255 / 88%) !important; }
html.atelier-theme body #app .shell .main[class] :is(.generation-result, .article-figure) .course-art-overlay button[data-course-art-retry][hidden] { display: none !important; }
html.atelier-theme body .st-art-pending .course-art-overlay::before { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg,transparent 20%,rgb(255 255 255 / 30%) 48%,transparent 76%); background-size: 200% 100%; animation: hb-art-shimmer 2.8s ease-in-out infinite; }
html.atelier-theme body .course-art-overlay .course-art-status { margin: 0; }
html.atelier-theme body .palace-teaching-scene { position: relative; }
@media (prefers-reduced-motion: reduce) { html.atelier-theme body .st-art-pending .course-art-overlay::before { animation: none; } }
html.atelier-theme body.reduce-motion .st-art-pending .course-art-overlay::before { animation: none; }
html.atelier-theme body .modal:has(.word-dialog) { width: min(360px, calc(100vw - 24px)); padding: 16px; }
html.atelier-theme body .word-dialog .modal-head { margin: 0 0 6px; }
html.atelier-theme body .word-dialog .modal-head h2 { margin: 0; font-size: 24px; }
html.atelier-theme body .word-dialog :is(.pinyin-line, .word-translation) { margin: 4px 0; font-size: 14px; line-height: 1.45; }
html.atelier-theme body .word-dialog .explain-card { margin: 8px 0 0; padding: 9px 11px; font-size: 13px; line-height: 1.55; }
html.atelier-theme body .word-dialog .explain-card p { margin: 6px 0 0; }
html.atelier-theme body .word-dialog .modal-actions { flex-direction: row; gap: 6px; margin-top: 10px; }
html.atelier-theme body :is(#app, #modal-root) .word-dialog .modal-actions .btn { width: auto; min-height: 32px !important; padding: 5px 9px !important; font-size: 12px !important; }
/* Only completed work contracts. In-flight generation keeps its full graph. */
html.atelier-theme body.home-mode .main.page-home .generation-home.is-complete { padding-top: 16px; padding-bottom: 16px; min-height: 0; }
html.atelier-theme body.home-mode .generation-home.is-complete .generation-stage { padding: 0; min-height: 0; }
html.atelier-theme body.home-mode .generation-home.is-complete .generation-thread { padding: 18px 24px; }
html.atelier-theme body.home-mode .generation-home.is-complete .generation-project-head { padding-bottom: 10px; }
html.atelier-theme body.home-mode .generation-home.is-complete .generation-project-head h1 { margin: 4px 0 0; font-size: 22px; line-height: 1.35; }
html.atelier-theme body.home-mode .generation-home.is-complete .generation-project > [data-part="progress"],
html.atelier-theme body.home-mode .generation-home.is-complete .course-progress { min-height: 0; }
html.atelier-theme body.home-mode .main.page-home .generation-home.is-complete .course-progress.st-flowing { margin-top: 8px; padding-top: 10px; }
html.atelier-theme body.home-mode .generation-home.is-complete .course-progress-head { min-height: 0; }
html.atelier-theme body.home-mode .generation-home.is-complete .st-flow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; aspect-ratio: auto !important; margin-top: 8px; padding: 9px 14px; }
html.atelier-theme body.home-mode .generation-home.is-complete .st-flow > svg,
html.atelier-theme body.home-mode .generation-home.is-complete .st-flow :is(.st-branch, .st-agent small) { display: none; }
html.atelier-theme body.home-mode .generation-home.is-complete .st-agent { position: static; transform: none; width: auto; display: flex; align-items: center; gap: 6px; }
html.atelier-theme body.home-mode .generation-home.is-complete .st-agent strong { margin: 0; font-size: 11px; }
html.atelier-theme body.home-mode .generation-home.is-complete .st-agent-orb { width: 22px; height: 22px; border-radius: 7px; }
html.atelier-theme body.home-mode .generation-home.is-complete .st-agent-orb .icon { width: 12px; height: 12px; }
html.atelier-theme body.home-mode .generation-home.is-complete .st-flow-status { min-height: 24px; margin: 6px 2px; }
html.atelier-theme body.home-mode .generation-home.is-complete .result-usage { margin: 6px 0 0; }
html.atelier-theme body.home-mode .generation-home.is-complete .workspace-footnote { margin-top: 8px; }
@media (max-width: 600px) {
  html.atelier-theme body .main[class] .generation-result { grid-template-columns: minmax(0, 1fr) !important; }
  html.atelier-theme body .main[class] .generation-result .result-copy { padding: 12px; }
  html.atelier-theme body.home-mode .generation-home.is-complete .generation-thread { padding: 16px; }
}

/* A course still generating in the background, shown on the fresh home. */
html.atelier-theme body.home-mode .st-active-gen {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: 760px; margin: 0 auto 10px; padding: 9px 14px; border: 1px solid #dde4f0; border-radius: 14px;
  background: #fff; color: var(--hb-muted); font-size: 13px; box-shadow: var(--hb-card-shadow);
}
html.atelier-theme body.home-mode .st-active-gen b { color: var(--hb-ink); font-weight: 600; }
html.atelier-theme body.home-mode .st-active-gen .link-btn { margin-left: auto; }
html.atelier-theme body.home-mode .st-active-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--hb-accent); }

@media (max-width: 600px) {
  html.atelier-theme body.home-mode .st-agent { width: 140px; transform: translate(-50%, -28px); }
  html.atelier-theme body.home-mode .st-agent small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html.atelier-theme body.home-mode .st-edge.is-done.is-fresh { stroke-dashoffset: 0 !important; }
}
html.atelier-theme body.reduce-motion.home-mode .st-edge.is-done.is-fresh { stroke-dashoffset: 0 !important; }

/* ==========================================================
   SURFACE FINISH — the quiet surfaces of ZaoWuAi (hairline edges, layered soft
   shadows, ghost toolbar controls, visible focus) on HanBridge's own layout,
   palette and illustrations. Nothing here moves or resizes page structure.
   ========================================================== */
html.atelier-theme {
  /* Fields drop the older green-grey tokens for the indigo palette. */
  --field-border: #dce1ea; --field-text: var(--hb-ink); --field-muted: #8a93a3;
  --field-accent: var(--hb-accent); --field-active: var(--hb-soft);
  --hb-field-hover: #c3cbd9; --hb-field-ring: 0 0 0 3px rgb(56 76 134 / 14%);
  --design-shadow: 0 1px 2px rgb(31 45 75 / 4%), 0 8px 24px rgb(31 45 75 / 5.5%);
  --hb-pop-shadow: 0 2px 6px rgb(31 45 75 / 5%), 0 18px 44px rgb(31 45 75 / 13%);
  --hb-ease: cubic-bezier(.2, .8, .2, 1);
}

/* Fields: a darker edge on hover and an accent ring on focus (previously no focus cue at all). */
html.atelier-theme body :is(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=color]), textarea, select):not(.generation-composer *) {
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease !important;
}
@media (hover: hover) {
  html.atelier-theme body :is(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=color]), textarea, select):not(.generation-composer *):not(:focus, :disabled, [readonly]):hover { border-color: var(--hb-field-hover) !important; }
  html.atelier-theme body .hb-select-trigger:not([aria-disabled=true], [aria-expanded=true]):hover { border-color: var(--hb-field-hover) !important; }
}
html.atelier-theme body :is(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=color]), textarea, select):not(.generation-composer *):focus {
  border-color: var(--hb-accent) !important; box-shadow: var(--hb-field-ring) !important;
}
html.atelier-theme body :is(input, textarea, select)[aria-invalid=true]:focus { border-color: var(--hb-bad) !important; box-shadow: 0 0 0 3px rgb(183 66 85 / 14%) !important; }
html.atelier-theme body .hb-select-trigger { transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease !important; }
html.atelier-theme body .hb-select-trigger:is(:focus-visible, [aria-expanded=true]) { border-color: var(--hb-accent) !important; box-shadow: var(--hb-field-ring) !important; }
/* Borderless triggers (language switch, composer level) stay borderless. */
html.atelier-theme body :is(.language-switch, .composer-level) .hb-select-trigger { border-color: transparent !important; box-shadow: none !important; }
html.atelier-theme body .hb-select-chevron { color: #8a93a3; }

/* Menus: a floating sheet with soft depth; options highlight on a tonal wash. */
html.atelier-theme body .hb-select-menu { padding: 5px; border-color: #e1e6ee; border-radius: var(--r-lg); box-shadow: var(--hb-pop-shadow); scrollbar-color: #cfd6e4 transparent; }
html.atelier-theme body .hb-select-option { border-radius: var(--r-sm); transition: background-color .12s ease, color .12s ease; }
html.atelier-theme body .hb-select-option.is-active { background: var(--hb-soft); color: var(--hb-accent); }
html.atelier-theme body .hb-select-option[aria-selected=true] { color: var(--hb-accent); font-weight: 600; }

/* Top bar: search, language and the personal entry read as one ghost toolbar. */
html.atelier-theme body header.topbar { box-shadow: 0 1px 0 rgb(31 45 75 / 6%); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
html.atelier-theme body header.topbar :is(.st-kbd, .language-switch, .personal-entry) {
  min-height: 36px; border-radius: var(--r-md); transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
html.atelier-theme body header.topbar :is(.st-kbd, .language-switch) { border-color: transparent; background: transparent; box-shadow: none; }
html.atelier-theme body header.topbar .personal-entry { height: 36px; padding-block: 0; }
html.atelier-theme body header.topbar .personal-entry:not(.active) { background: transparent; }
@media (hover: hover) {
  html.atelier-theme body header.topbar :is(.st-kbd, .language-switch, .personal-entry):hover { border-color: transparent; background: var(--hb-soft); color: var(--hb-ink); }
}
html.atelier-theme body header.topbar .language-switch:focus-within { background: var(--hb-soft); }

/* Keyboard focus is always visible, in the accent colour, outside the control. */
html.atelier-theme body :is(a, button, summary, [role=tab], [role=button], [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid rgb(56 76 134 / 55%); outline-offset: 2px;
}
html.atelier-theme body :is(input, textarea, select, .hb-select-trigger):focus-visible { outline: 0; }

/* Cards and tiles share one hover: a firmer edge and a little more depth, no jump. */
html.atelier-theme body .shell.workspace-shell .main[class] :is(.account-tile, .flow-surface) { transition: border-color .18s var(--hb-ease), box-shadow .18s var(--hb-ease), background-color .18s ease; }

@media (prefers-reduced-motion: reduce) {
  html.atelier-theme body :is(input, textarea, select, .hb-select-trigger, .hb-select-option, header.topbar *) { transition: none !important; }
}

/* ---------- shared controls and status ---------- */
:root.atelier-theme { --hb-pop-shadow: 0 10px 32px rgb(31 45 75 / 14%); }
html.atelier-theme body :is(#app, #modal-root) .btn.ghost { color: var(--hb-accent) !important; background: transparent !important; border: 1px solid transparent !important; box-shadow: none !important; }
html.atelier-theme body :is(#app, #modal-root) .btn.ghost:is(:hover, :focus-visible):not(:disabled) { background: var(--hb-soft) !important; border-color: transparent !important; }
html.atelier-theme body :is(#app, #modal-root) .btn.ghost:is(:disabled, [aria-disabled="true"]) { color: #8a93a3 !important; background: #eef0f4 !important; border-color: #e3e7ee !important; }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-button, .vocab-actions button, .st-icon-btn, .history-refresh, [data-speak], [data-save-word], [data-copy], [data-action="read-all"], [data-action="save-api"], [data-action="test-api"]) {
  min-height: var(--btn-h-sm) !important; border-radius: 10px !important; line-height: 1.4; transition: background-color .16s, border-color .16s, color .16s;
}
html.atelier-theme body :is(#app, #modal-root) :is(.st-icon-btn, .history-refresh) { width: var(--btn-h-sm); height: var(--btn-h-sm); }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-button, .vocab-actions button, .st-icon-btn, [data-speak], [data-save-word], [data-copy]):hover:not(:disabled) { background-color: var(--hb-soft); }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-button, .vocab-actions button, .st-icon-btn, [data-speak], [data-save-word], [data-copy]):active:not(:disabled):not(.st-node) { opacity: .8; transform: none !important; }
/* Word-web nodes are centred with translate(-50%,-50%); dropping it on press moved the node
   from under the pointer, so the click landed on the stage and nothing played. */
html.atelier-theme body :is(#app, #modal-root) .st-web-stage .st-node:active { opacity: .85; transform: translate(-50%, -50%) scale(.97) !important; }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-button, .vocab-actions button, .st-icon-btn, [data-speak], [data-save-word], [data-copy]):focus-visible { outline: 2px solid var(--hb-accent); outline-offset: 2px; }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-button, .vocab-actions button, .st-icon-btn, [data-speak], [data-save-word], [data-copy]):disabled { opacity: .55; transform: none !important; }
html.atelier-theme body :is(#app, #modal-root) .icon { width: 16px; height: 16px; stroke-width: 1.8; }
html.atelier-theme body :is(#app, #modal-root) :is(.btn.small, .vocab-actions button, .admin-button, .st-icon-btn) .icon { width: 16px !important; height: 16px !important; }
html.atelier-theme body .st-status { display: inline-flex; align-items: center; padding: 3px var(--sp-2); border: 1px solid; border-radius: var(--r-sm); font-size: var(--fs-small); line-height: 1.5; }
html.atelier-theme body :is(#app, #modal-root) :is(.st-status[data-tone="success"], .history-status[data-tone="success"], .admin-status-approved, .admin-status-active, .admin-status-done, .admin-status-paid, .admin-status-resolved, .course-progress[data-state="done"] .progress-badge) { color: #30735d; background: #eef7f2; border-color: #cfe6da; }
html.atelier-theme body :is(#app, #modal-root) :is(.st-status[data-tone="warning"], .history-status[data-tone="warning"], .admin-status-pending, .admin-status-draft, .admin-status-open, .course-progress[data-state="uncertain"] .progress-badge) { color: #896321; background: #fff8e9; border-color: #ecdfbd; }
html.atelier-theme body :is(#app, #modal-root) :is(.st-status[data-tone="error"], .history-status[data-tone="error"], .admin-status-rejected, .admin-status-failed, .admin-status-inactive, .course-progress[data-state="failed"] .progress-badge) { color: var(--hb-bad); background: #fff2f4; border-color: #edcbd2; }
html.atelier-theme body :is(#app, #modal-root) :is(.st-status[data-tone="processing"], .history-status[data-tone="processing"], .admin-status-queued, .admin-status-running, .course-progress[data-state="running"] .progress-badge) { color: var(--hb-accent); background: #eef2fa; border-color: #d4ddef; }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-operation-state.is-available, .admin-operation-state.is-healthy, .admin-operation-state.is-idle) { color: #30735d; background: #eef7f2; border-color: #cfe6da; }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-operation-state.is-unknown, .admin-operation-state.is-degraded) { color: #896321; background: #fff8e9; border-color: #ecdfbd; }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-operation-state.is-unavailable, .admin-operation-state.is-error) { color: var(--hb-bad); background: #fff2f4; border-color: #edcbd2; }
html.atelier-theme body :is(#app, #modal-root) :is(.admin-operation-state.is-busy, .admin-operation-state.is-processing) { color: var(--hb-accent); background: #eef2fa; border-color: #d4ddef; }
html.atelier-theme body .shell .main[class] :is(.panel:not(.admin-panel), .course-card, .vocab-card, .generation-result) { border-color: var(--hb-line); border-radius: var(--r-xl); box-shadow: var(--design-shadow); }
html.atelier-theme body :is(input:not([type="checkbox"]):not([type="radio"]), textarea, select, .hb-select-trigger) { border-radius: var(--r-md); }
html.atelier-theme body :is(.hb-select-menu, .user-menu-popup) { border-radius: var(--r-lg); }
html.atelier-theme body .form-actions,
html.atelier-theme body .modal-actions,
html.atelier-theme body :is(.admin-model-form, .admin-review-form) { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }
html.atelier-theme body .form-actions > .btn:first-child,
html.atelier-theme body .modal-actions > .btn:last-child { order: 2; }
html.atelier-theme body .st-art-status,
html.atelier-theme body .course-art-status { margin: var(--sp-2) 0 0; color: var(--hb-muted); font-size: var(--fs-small); }
html.atelier-theme body .st-art-status.st-art-shimmer,
html.atelier-theme body .course-art-status.st-art-shimmer { position: relative; overflow: hidden; padding: var(--sp-2); border-radius: var(--r-sm); background: linear-gradient(90deg,#f1f3f8,#fff,#f1f3f8); background-size: 200% 100%; animation: hb-art-shimmer 1.8s ease-in-out infinite; }
html.atelier-theme body .course-art-retry { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); color: var(--hb-muted); font-size: var(--fs-small); }
html.atelier-theme body .article-figure.st-art-pending img { opacity: .75; }
html.atelier-theme body .article-figure.st-art-ready img { animation: st-appear .6s ease both; }
html.atelier-theme body .admin-feedback-rating .icon { width: 16px; height: 16px; color: #c6cedd; vertical-align: middle; }
html.atelier-theme body .admin-feedback-rating .icon.is-filled { color: var(--hb-warm); fill: rgb(176 134 83 / 18%); }
@keyframes hb-art-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- stable generation and natural page scrolling ---------- */
html.atelier-theme body .generation-project > [data-part] { min-width: 0; }
html.atelier-theme body .generation-project > [data-part="progress"] { overflow-anchor: auto; }
html.atelier-theme body .generation-project > :is([data-part="result"], [data-part="failure"], [data-part="notes"]) { overflow-anchor: none; }
html.atelier-theme body .generation-project > [data-part]:empty { display: none; }
html.atelier-theme body .generation-project > [data-part="progress"] { min-height: 320px; }
html.atelier-theme body.home-mode .course-progress.st-flowing { min-height: 320px; }
html.atelier-theme body.home-mode .st-flow-status { min-height: 34px; }
html.atelier-theme body.home-mode .st-flow-time { min-width: 58px; text-align: center; }
html.atelier-theme body :is(.st-flow-time, .user-menu-popup)[hidden] { display: none !important; }
html.atelier-theme body .shell.workspace-shell .main[class] :is(.lesson-tools, .generation-history-list, .generation-thread) { max-height: none !important; overflow: visible !important; }
html.atelier-theme body :is(.progress-orbit, .progress-status-indicator, .progress-artwork, .st-flow-dot, .st-active-dot, .skeleton, .admin-loading, .loading-bar)::after { animation: none !important; }
html.atelier-theme body :is(.progress-orbit, .progress-orbit *, .progress-status-indicator, .progress-artwork, .skeleton, .admin-loading, .loading-bar, .agent-node.active > span) { animation: none !important; }
html.atelier-theme body :is(button, .btn):is([data-busy], [aria-busy="true"]), html.atelier-theme body .auth-submit:disabled { opacity: .72 !important; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .st-rail-track b,
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson .st-rail-node.active .st-dot::after { animation: none !important; }
html.atelier-theme body .shell.workspace-shell .main[class].page-lesson #lesson-content .st-axis .map-building { animation: none !important; }
@media (max-width: 600px) {
  html.atelier-theme body :is(.form-actions, .modal-actions, .admin-model-form, .admin-review-form) { align-items: stretch; flex-direction: column; width: 100%; }
  html.atelier-theme body :is(.form-actions, .modal-actions, .admin-model-form, .admin-review-form) > * { width: 100%; }
  html.atelier-theme body .form-actions > .btn:first-child,
  html.atelier-theme body .modal-actions > .btn:last-child { order: -1; }
  html.atelier-theme body .generation-project > [data-part="progress"], html.atelier-theme body.home-mode .course-progress.st-flowing { min-height: 660px; }
}

/* ---------- USER MENU ---------- */
html.atelier-theme body header.topbar .user-menu { position: relative; flex: none; }
html.atelier-theme body header.topbar button.personal-entry { font: inherit; min-height: 44px; }
html.atelier-theme body header.topbar .user-menu-popup { position: absolute; z-index: 90; top: calc(100% + 8px); right: 0; width: 248px; max-width: calc(100vw - 24px); padding: 6px; border: 1px solid #e1e6ee; border-radius: 12px; background: #fff; box-shadow: var(--hb-pop-shadow); color: var(--hb-ink); }
html.atelier-theme body header.topbar .user-menu-profile { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--hb-line); }
html.atelier-theme body header.topbar .user-menu-profile > div { min-width: 0; }
html.atelier-theme body header.topbar .user-menu-profile strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
html.atelier-theme body header.topbar .user-menu-profile div > span { display: block; margin-top: 3px; color: var(--hb-muted); font-size: 12px; }
html.atelier-theme body header.topbar .user-menu-popup [role="menuitem"] { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--hb-ink); font: inherit; font-size: 13px; text-decoration: none; text-align: left; }
html.atelier-theme body header.topbar .user-menu-popup [role="menuitem"]:is(:hover, :focus-visible) { background: var(--hb-soft); }
html.atelier-theme body header.topbar .user-menu-popup [data-action="logout"] { color: var(--hb-bad); }
html.atelier-theme body header.topbar .user-menu-divider { height: 1px; margin: 5px 4px; background: var(--hb-line); }
@media (pointer: coarse), (max-width: 600px) { html.atelier-theme body header.topbar .user-menu-popup [role="menuitem"] { min-height: 44px; } }

/* Language menu: same trigger and sheet as the account menu, replacing the native OS dropdown. */
html.atelier-theme body header.topbar .lang-menu { position: relative; flex: none; }
html.atelier-theme body header.topbar #lang-menu-trigger {
  display: inline-flex; align-items: center; gap: var(--sp-1); height: 36px; padding: 0 var(--sp-2); border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--hb-muted); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; box-shadow: none;
}
html.atelier-theme body header.topbar #lang-menu-trigger .icon { width: 16px; height: 16px; flex: none; }
html.atelier-theme body header.topbar #lang-menu-trigger .hb-select-chevron { width: 12px; height: 12px; color: #8a93a3; transition: transform .18s var(--hb-ease); }
html.atelier-theme body header.topbar #lang-menu-trigger[aria-expanded="true"] { background: var(--hb-soft); color: var(--hb-ink); }
html.atelier-theme body header.topbar #lang-menu-trigger[aria-expanded="true"] .hb-select-chevron { transform: rotate(180deg); }
html.atelier-theme body header.topbar .lang-menu-popup {
  position: absolute; z-index: 90; top: calc(100% + 8px); right: 0; width: 168px; padding: 6px;
  border: 1px solid #e1e6ee; border-radius: var(--r-lg); background: #fff; box-shadow: var(--hb-pop-shadow); color: var(--hb-ink);
}
html.atelier-theme body header.topbar .lang-menu-popup[hidden] { display: none !important; }
html.atelier-theme body header.topbar .lang-menu-popup [role="menuitemradio"] {
  display: flex; align-items: center; justify-content: space-between; gap: 9px; width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--hb-ink); font: inherit; font-size: var(--fs-body); text-align: left; cursor: pointer;
}
html.atelier-theme body header.topbar .lang-menu-popup [role="menuitemradio"]:is(:hover, :focus-visible) { background: var(--hb-soft); outline: 0; }
html.atelier-theme body header.topbar .lang-menu-popup [role="menuitemradio"] .icon { width: 15px; height: 15px; visibility: hidden; color: var(--hb-accent); }
html.atelier-theme body header.topbar .lang-menu-popup [role="menuitemradio"][aria-checked="true"] { color: var(--hb-accent); font-weight: 600; }
html.atelier-theme body header.topbar .lang-menu-popup [role="menuitemradio"][aria-checked="true"] .icon { visibility: visible; }
@media (pointer: coarse), (max-width: 600px) {
  html.atelier-theme body header.topbar #lang-menu-trigger { min-height: 44px; }
  html.atelier-theme body header.topbar .lang-menu-popup [role="menuitemradio"] { min-height: 44px; }
}
@media (max-width: 430px) { html.atelier-theme body header.topbar .user-menu-popup { position: fixed; top: var(--user-menu-top, 64px); right: 12px; width: calc(100vw - 24px); } }

/* ---------- ACCOUNT ---------- */
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account { width: 100%; max-width: 1180px; min-width: 0; padding: 28px 28px 32px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account :is(.account-overview, .account-summary, .account-section) { margin: 0 0 24px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-overview { gap: 20px; padding-bottom: 20px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account :is(.account-profile, .account-person, .account-tile-copy) { min-width: 0; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-person p { overflow-wrap: anywhere; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .section-heading h2 { flex: none; margin: 0; font-size: 16px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-learning-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-tile { width: 100%; min-width: 0; min-height: 104px; padding: 14px; border: 1px solid var(--hb-line); border-radius: 16px; box-shadow: var(--design-shadow); }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-tile-copy strong { display: block; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.6; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-summary-item { min-width: 0; min-height: 88px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-summary-item strong { overflow-wrap: anywhere; font-size: 24px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-utilities { margin-top: 0; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-utility-list > :is(a, button) { min-height: 44px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .history-item strong { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
@media (max-width: 1024px) {
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .section-heading { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account { padding: 20px 16px 28px; }
  html.atelier-theme body header.topbar #user-menu-trigger { min-width: 44px; min-height: 44px; justify-content: center; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-overview { flex-direction: column; align-items: stretch; gap: 14px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-profile-actions { width: 100%; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-profile-actions > .btn { flex: 1; min-height: 44px !important; white-space: normal; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-person h1 { font-size: 22px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-summary { gap: 10px; padding-bottom: 0; border-bottom: 0; }
  /* On phones the two figures become small cards so their text never meets the screen edge. */
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-summary-item,
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-summary-item + .account-summary-item {
    min-height: 80px; padding: 12px 14px; border: 1px solid var(--hb-line); border-radius: 14px; background: #fff; box-shadow: var(--design-shadow);
  }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-summary-item strong { font-size: 20px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .section-heading { flex-direction: column; align-items: stretch; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-learning-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 6px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-learning-actions > .btn { min-width: 0; min-height: 44px !important; padding: 6px !important; white-space: normal; overflow-wrap: anywhere; font-size: 12px !important; line-height: 1.4 !important; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account :is(.account-grid, .generation-history-list) { grid-template-columns: minmax(0, 1fr); }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-tile { grid-template-columns: 54px minmax(0, 1fr) 16px; align-items: center; min-height: 88px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-tile-art { grid-column: 1; grid-row: 1; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-tile-copy { grid-column: 2; grid-row: 1; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-tile > .icon { grid-column: 3; grid-row: 1; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-utility-list { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-utility-list > :is(a, button) { width: 100%; justify-content: flex-start; padding: 8px 10px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account :is(.footer a, .footer button, .account-history-actions > *) { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ---------- ADMIN: retain existing surfaces, contain tables ---------- */
html.atelier-theme body .shell.workspace-shell .main[class].page-admin { min-width: 0; max-width: 100%; }
html.atelier-theme body .shell.workspace-shell .main[class].page-admin :is(.admin-table-wrap, .table-scroll) { min-width: 0; max-width: 100%; max-height: none; overflow-x: auto !important; overflow-y: hidden !important; }
html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-navigation { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
@media (max-width: 768px) {
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-navigation { display: flex; flex-wrap: nowrap; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-nav-item { flex: 0 0 auto; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin :is(.admin-toolbar, .admin-toolbar-simple, .inline-form, .settings-grid, .admin-provider-grid, .admin-config-grid, .admin-form-grid, .admin-model-form, .admin-knowledge-form, .admin-review-form, .admin-form) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin :is(.admin-toolbar, .inline-form, .settings-grid, .admin-model-form, .admin-knowledge-form, .admin-review-form, .admin-form) > * { grid-column: 1 !important; grid-row: auto !important; min-width: 0; width: 100%; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table { display: table; min-width: 680px; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table thead { display: table-header-group; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table tbody { display: table-row-group; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table tr { display: table-row; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table td { display: table-cell; width: auto; max-width: none; padding: 12px 16px; border-bottom: 1px solid var(--admin-line); text-align: left; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table td::before { display: none; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table-wrap { border: 1px solid var(--admin-line); border-radius: 10px; }
  html.atelier-theme body .shell.workspace-shell .main[class].page-admin .admin-table .admin-confirm-row td { display: table-cell; padding: 12px 16px; }
}

/* All three lesson slots share one image frame. Only the cover has a fallback. */
html.atelier-theme body #app .shell .main.page-lesson #lesson-content .article-figure {
  overflow: hidden; border: 1px solid var(--hb-line); border-radius: 16px;
}
html.atelier-theme body #app .shell .main.page-lesson #lesson-content .article-figure .lesson-visual.large {
  width: 100%; aspect-ratio: 16 / 9; max-height: none; min-height: 0;
}
html.atelier-theme body #app .shell .main.page-lesson #lesson-content .article-figure .topic-image {
  display: block; width: 100%; height: 100%; aspect-ratio: 16 / 9; object-fit: cover;
}

/* Desktop workspace: wide cards with an independent, centered reading column.
   Smaller viewports keep their existing page and account grids. */
@media (min-width: 1280px) {
  html.atelier-theme body #app .shell .topbar-inner,
  html.atelier-theme body #app .shell.workspace-shell .main[class]:not(.page-admin),
  html.atelier-theme body #app .shell .main[class]:not(.page-admin) {
    width: calc(100% - 2 * clamp(20px, 3vw, 48px)); max-width: 1760px;
    margin-inline: auto; padding-inline: 0; box-sizing: border-box;
  }
  html.atelier-theme body #app .shell .main[class].page-lesson #lesson-content {
    --hb-reading-width: clamp(720px, 64vw, 1200px);
    width: 100%; max-width: none; margin-inline: auto;
  }
  html.atelier-theme body #app .shell .main[class].page-lesson #lesson-content > .lesson-body { width: 100%; max-width: none; margin-inline: 0; box-sizing: border-box; }
  html.atelier-theme body #app .shell .main[class].page-lesson #lesson-content .lesson-body > :not(.article-figure) {
    width: min(100%, var(--hb-reading-width)); max-width: var(--hb-reading-width); margin-inline: auto !important;
  }
  html.atelier-theme body #app .shell .main[class].page-lesson #lesson-content .lesson-body .zh-text {
    max-width: none; font-size: clamp(18px, 1.1vw, 20px);
  }
  html.atelier-theme body #app .shell .main[class].page-lesson #lesson-content .lesson-body .translation { max-width: none; }
  html.atelier-theme body #app .shell .main[class].page-lesson #lesson-content .article-figure {
    width: 100%; max-width: 1200px; margin-inline: auto;
  }
  html.atelier-theme body.home-mode #app .main.page-home .generation-home {
    width: 100%; max-width: 1200px; margin-inline: auto;
  }
  html.atelier-theme body.home-mode #app .main.page-home .generation-home .generation-composer {
    width: 100%; max-width: 960px; margin-inline: auto; box-sizing: border-box;
  }
  html.atelier-theme body.home-mode #app .main.page-home .generation-home .suggestion-row {
    width: 100%; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px;
  }
  html.atelier-theme body.home-mode #app .main.page-home .generation-home.has-generation :is(.generation-stage, .generation-thread, .generation-project) {
    width: 100%; max-width: 1200px; margin-inline: auto; box-sizing: border-box;
  }
}
@media (min-width: 1600px) {
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-account .account-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Reading settings on the left, equal actions on the right, progress below. */
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 4px 8px;
  padding: 7px 10px 5px; overflow: visible;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools-content {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 12px; min-width: 0;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools-toggle {
  grid-column: 1; min-width: 28px; min-height: 34px; padding: 0 7px; align-self: start;
}
html.atelier-theme body #app .main.page-lesson :is(.lesson-tools-reading, .lesson-tools-operations, .lesson-tools-actions) {
  display: flex; flex-wrap: nowrap; align-items: center; min-width: 0;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools-reading { gap: 10px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-reading > :not(:first-child) { border-left: 1px solid var(--hb-line); padding-left: 10px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools .lesson-tool-field { gap: 6px; min-height: 34px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools :is(.lesson-tool-field, .st-switch) > [data-i18n] { color: #7a8496; font-size: 11px; font-weight: 500; }
html.atelier-theme body #app .main.page-lesson .lesson-tools .st-toggles { gap: 10px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools .st-switch { gap: 6px; min-height: 34px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools .st-switch + .st-switch { border-left: 1px solid var(--hb-line); padding-left: 10px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools .st-seg { min-height: 34px; box-sizing: border-box; }
html.atelier-theme body #app .main.page-lesson .lesson-tools .st-seg button { min-height: 30px; padding: 3px 5px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-operations { gap: 8px; margin-left: auto; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-actions { gap: 6px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-actions .btn {
  flex: 0 0 104px; width: 104px; min-height: 34px !important; height: 34px !important;
  padding: 0 8px !important; font-size: 12px !important; gap: 6px !important; box-sizing: border-box;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools .lesson-tools-actions .icon { width: 15px; height: 15px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-menu { position: relative; flex: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-more { min-height: 34px; padding: 0 8px; gap: 5px; white-space: nowrap; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-more[aria-expanded="true"] { background: var(--hb-soft); color: var(--hb-ink); }
html.atelier-theme body #app .main.page-lesson .lesson-tools-extra {
  top: calc(100% + 8px); right: 0; z-index: 90; width: 272px; max-width: calc(100vw - 32px);
  padding: 6px; gap: 0; border: 1px solid #e1e6ee; border-radius: var(--r-lg);
  background: #fff; box-shadow: var(--hb-pop-shadow); color: var(--hb-ink); box-sizing: border-box;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools-options { display: grid; gap: 8px; padding: 6px 8px 12px; border-bottom: 1px solid var(--hb-line); }
html.atelier-theme body #app .main.page-lesson .lesson-tools-options .lesson-tool-field { justify-content: space-between; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-links { display: grid; gap: 2px; padding-top: 6px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-links .btn {
  justify-content: flex-start !important; min-height: 36px !important; padding: 6px 10px !important;
  background: transparent !important; border-color: transparent !important; box-shadow: none !important; font-size: 12px !important;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools .lesson-tools-links .btn:is(:hover, :focus-visible) { background: var(--hb-soft) !important; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-progress { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; width: 100%; margin: 0; height: 10px; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-progress-line { flex: 1; height: 2px; overflow: hidden; border-radius: 2px; background: #edf0f6; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-progress-line i { display: block; height: 100%; background: var(--hb-accent); border-radius: inherit; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-percent { color: #8993a6; font-size: 10px; line-height: 1; font-variant-numeric: tabular-nums; }
/* Important legacy button transitions must also include independent translation. */
html.atelier-theme body #app .main.page-lesson .lesson-tools .st-magnetic.is-magnetic-enabled {
  transition: translate 300ms cubic-bezier(.2,.8,.2,1), background-color .16s, border-color .16s, color .16s, box-shadow .18s !important;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools .st-magnetic.is-magnetic-enabled.is-magnetic-pressed { transition: none !important; }
@media (max-width: 1199px) {
  html.atelier-theme body #app .main.page-lesson .lesson-tools-content { flex-direction: column; align-items: stretch; gap: 8px; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools-reading { flex-wrap: wrap; gap: 8px 10px; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools-operations { justify-content: flex-end; margin-left: 0; }
}
@media (max-width: 600px), (pointer: coarse) {
  html.atelier-theme body #app .main.page-lesson .lesson-tools-reading,
  html.atelier-theme body #app .main.page-lesson .lesson-tools .st-toggles { flex-wrap: wrap; }
  html.atelier-theme body #app .main.page-lesson :is(.lesson-tools-toggle, .lesson-tools-more),
  html.atelier-theme body #app .main.page-lesson .lesson-tools .st-switch { min-height: 44px; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools .st-seg { min-height: 46px; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools .st-seg button { min-height: 44px; min-width: 44px; padding-inline: 6px; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools-reading > :not(:first-child) { padding-left: 0; border-left: 0; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools-operations { flex-wrap: wrap; gap: 8px; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools-actions { flex-wrap: wrap; flex: 1 1 100%; gap: 6px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-actions .btn {
    flex: 1 1 90px; width: auto; min-height: 44px !important; height: 44px !important;
  }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-links .btn { min-height: 44px !important; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools .st-magnetic.is-magnetic-enabled { transition: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  html.atelier-theme body #app .main.page-lesson .lesson-tools .st-magnetic.is-magnetic-enabled { transition: none !important; }
}
html.atelier-theme body.reduce-motion #app .main.page-lesson .lesson-tools .st-magnetic.is-magnetic-enabled { transition: none !important; }

/* Lesson card, sticky chapter navigation and the floating learning dock. */
html.atelier-theme:has(.page-lesson) {
  scroll-padding-top: var(--lesson-scroll-top, 140px);
  scroll-padding-bottom: calc(var(--lesson-scroll-bottom, 104px) + env(safe-area-inset-bottom, 0px));
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson {
  --lesson-top: 72px; --lesson-tools-space: 108px;
  padding-bottom: calc(var(--lesson-tools-space) + env(safe-area-inset-bottom, 0px));
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-card {
  width: 100%; min-width: 0; background: #fff; border-radius: 20px; overflow-anchor: none;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-card > .tabs {
  position: sticky; top: var(--lesson-top); z-index: 25; width: 100%; box-sizing: border-box;
  margin: 0 !important; border-radius: 18px 18px 12px 12px !important; box-shadow: none !important;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-card > .tabs.is-stuck {
  background: rgb(255 255 255 / 90%) !important; backdrop-filter: blur(14px);
  box-shadow: 0 6px 20px rgb(56 76 134 / 10%) !important;
}
html.atelier-theme body #app .main.page-lesson .tabs .st-ink {
  transition: transform 280ms cubic-bezier(.2,.8,.2,1), width 280ms cubic-bezier(.2,.8,.2,1) !important;
}
html.atelier-theme body #app .main.page-lesson .lesson-viewport { overflow: clip; display: flow-root; touch-action: pan-y pinch-zoom; }
html.atelier-theme body #app .main.page-lesson .lesson-viewport.is-switching { overflow: hidden; }
html.atelier-theme body #app .main.page-lesson #lesson-content.is-dragging { user-select: none; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content {
  --hb-reading-width: clamp(720px, 64vw, 1200px);
  width: 100%; max-width: none; padding: 24px clamp(18px, 3vw, 40px); box-sizing: border-box;
  background: transparent; border-radius: 0 0 20px 20px; box-shadow: none;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content > .lesson-body {
  width: 100%; max-width: none; margin-inline: 0;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content .lesson-body > *,
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content[data-chapter="grammar"] > .panel {
  width: min(100%, var(--hb-reading-width)); max-width: var(--hb-reading-width); margin-inline: auto !important; box-sizing: border-box;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content :is(.zh-text, .translation, .panel > p, .english-tip, .st-grammar-explanation) {
  text-align: justify; text-justify: inter-character; text-align-last: start; line-height: 1.95;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content :is(.translation, .english-tip, [lang="en"]) {
  text-justify: inter-word; margin-left: 0; padding-left: 0; border-left: 0;
}
/* Each ruby remains an atomic character/reading pair; the paragraph distributes gaps. */
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content .st-ruby .zh-text { line-height: 2; }
html.atelier-theme body #app .main.page-lesson #lesson-content ruby { ruby-align: center; white-space: nowrap; }
html.atelier-theme body #app .main.page-lesson #lesson-content ruby rt { text-align: center; text-align-last: center; }
html.atelier-theme body #app .main.page-lesson #lesson-content .st-ruby-unit { display: inline-block; white-space: nowrap; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools {
  position: fixed; top: auto; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: max(12px, calc((100% - var(--lesson-tools-width, 1200px)) / 2)); z-index: 35;
  width: min(calc(100% - 24px), var(--lesson-tools-width, 1200px)); max-width: none;
  min-height: 60px; margin: 0; padding: 7px 10px; gap: 0 8px; box-sizing: border-box;
  grid-template-columns: 44px minmax(0, 1fr); align-items: center;
  border: 1px solid rgb(196 206 231 / 75%); border-radius: 24px;
  background: rgb(255 255 255 / 92%); backdrop-filter: blur(18px); box-shadow: 0 8px 32px rgb(45 61 108 / 18%);
  transition: width 320ms cubic-bezier(.2,.8,.2,1), left 320ms cubic-bezier(.2,.8,.2,1), border-radius 320ms;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-content {
  display: flex !important; flex-direction: row; flex-wrap: nowrap; align-items: center; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; gap: 16px; padding: 0 4px; background: transparent; min-height: 44px;
  opacity: 1; visibility: visible; transition: opacity 160ms 120ms, visibility 0s;
}
html.atelier-theme body #app .main.page-lesson :is(.tabs, .lesson-tools-content)::-webkit-scrollbar { display: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools :is(.lesson-tools-reading, .lesson-tools-operations, .lesson-tools-actions, .st-toggles) {
  flex-direction: row; flex-wrap: nowrap; flex-shrink: 0;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools .lesson-tools-actions { flex: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-content > * { animation: lesson-tool-in 320ms cubic-bezier(.2,.8,.2,1) both; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-content > :nth-child(2) { animation-delay: 60ms; }
@keyframes lesson-tool-in { from { opacity: 0; translate: -8px 0; } to { opacity: 1; translate: 0 0; } }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools-toggle {
  position: relative; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; align-self: center;
  color: var(--hb-accent); background: var(--hb-soft);
}
html.atelier-theme body #app .main.page-lesson .lesson-tools-toggle > .icon { display: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-toggle > .lesson-tools-collapse { transform: none; font-size: 24px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools[data-open="false"] {
  left: 12px; width: 60px; height: 60px; padding: 7px; border-radius: 50%; gap: 0;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools[data-open="false"] .lesson-tools-content {
  height: 44px; max-height: 44px; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 120ms, visibility 0s 120ms;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="false"] .lesson-tools-content > * { animation: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="false"] .lesson-tools-toggle > .icon { display: block; }
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="false"] .lesson-tools-collapse { display: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="false"] .lesson-tools-toggle::before {
  content: ""; position: absolute; inset: -5px; padding: 3px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--hb-accent) var(--lesson-progress, 0%), #e4e9f5 0);
  mask: linear-gradient(#fff 0 0) content-box exclude, linear-gradient(#fff 0 0);
}
html.atelier-theme body #app .main.page-lesson .lesson-tools-progress { position: absolute; bottom: 3px; left: 22px; width: calc(100% - 44px); height: 3px; pointer-events: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools-percent { display: none; }
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="false"] .lesson-tools-progress { visibility: hidden; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools-extra {
  position: absolute; top: auto; bottom: calc(100% + 12px); right: 0;
  max-width: calc(100vw - 24px); max-height: calc(100dvh - var(--lesson-top) - 112px - env(safe-area-inset-bottom, 0px)); overflow-y: auto;
}
@media (pointer: coarse), (max-width: 767px) {
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-card > .tabs { display: flex !important; touch-action: pan-x pan-y; }
  html.atelier-theme body #app .main.page-lesson .tabs .tab { flex: 1 0 88px !important; min-height: 44px !important; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools { left: 12px; width: calc(100% - 24px); }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools[data-open="false"] { width: 60px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools :is(button, .lesson-tools-actions .btn, .st-switch) { min-width: 44px; min-height: 44px !important; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-actions .btn { flex: 0 0 104px; }
}
@media (prefers-reduced-motion: reduce) {
  html.atelier-theme body #app .main.page-lesson :is(.tabs, .tabs .st-ink, .lesson-tools, .lesson-tools-content, .lesson-tools-content > *) { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
html.atelier-theme body.reduce-motion #app .main.page-lesson :is(.tabs, .tabs .st-ink, .lesson-tools, .lesson-tools-content, .lesson-tools-content > *) { animation: none !important; transition: none !important; scroll-behavior: auto; }

/* ==========================================================
   LESSON COLUMN — tabs, floating toolbar and every chapter block share the
   reading width, so the bars line up with the text and the vocabulary cards.
   ========================================================== */
html.atelier-theme body #app .main.page-lesson {
  --hb-reading-width: clamp(720px, 64vw, 1200px);
  --hb-lesson-pad: clamp(18px, 3vw, 40px); /* #lesson-content's side padding */
  --hb-tools-width: min(calc(100% - 24px), var(--hb-reading-width));
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-card > .tabs {
  width: min(calc(100% - 2 * var(--hb-lesson-pad)), var(--hb-reading-width)) !important;
  max-width: none !important; margin-inline: auto !important; box-sizing: border-box;
}
/* Chapters without a .lesson-body wrapper (words, practice, …) align their blocks the same way. */
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content > :not(.lesson-body) {
  width: min(100%, var(--hb-reading-width)); max-width: var(--hb-reading-width); margin-inline: auto !important; box-sizing: border-box;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson #lesson-content .vocab-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

/* Floating toolbar: anchored to the column's left edge in both states. Collapsing
   narrows it to a 60px button in place and expanding unfolds it left to right
   with a single width transition — the bar never slides sideways. */
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools,
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools[data-open="false"] {
  left: calc((100% - var(--hb-tools-width)) / 2); right: auto;
  min-height: 60px; height: 60px; padding: 7px 10px 7px 7px;
  transition: width 420ms cubic-bezier(.22, 1, .36, 1), border-radius 420ms cubic-bezier(.22, 1, .36, 1), box-shadow 300ms ease;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools { width: var(--hb-tools-width); border-radius: 30px; }
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools[data-open="false"] {
  width: 60px; border-radius: 30px; gap: 0; padding: 7px;
}
/* The content stays laid out (inert while collapsed) and is clipped by the bar's
   width, so it is revealed progressively as the bar widens. */
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-content {
  min-width: 0; overflow-x: auto; overflow-y: hidden; opacity: 1; visibility: visible;
  transition: opacity 220ms ease 110ms, visibility 0s 0s;
}
html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools[data-open="false"] .lesson-tools-content {
  opacity: 0; visibility: hidden; transition: opacity 120ms ease, visibility 0s 420ms;
}
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="true"] .lesson-tools-content > * { animation: lesson-tool-unfold 420ms cubic-bezier(.22, 1, .36, 1) both; }
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="true"] .lesson-tools-content > :nth-child(2) { animation-delay: 70ms; }
html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open="true"] .lesson-tools-content > :nth-child(3) { animation-delay: 120ms; }
@keyframes lesson-tool-unfold { from { opacity: 0; translate: -18px 0; } to { opacity: 1; translate: 0 0; } }
/* The chevron turns instead of swapping glyphs abruptly. */
html.atelier-theme body #app .main.page-lesson .lesson-tools-toggle > .lesson-tools-collapse { display: inline-block; transition: rotate 420ms cubic-bezier(.22, 1, .36, 1); }
@media (pointer: coarse), (max-width: 767px) {
  html.atelier-theme body #app .main.page-lesson { --hb-tools-width: calc(100% - 24px); }
}
/* When the column is too narrow for every label, the three actions and "more" become
   icon buttons; their labels stay in the DOM (visually hidden) for screen readers. */
html.atelier-theme body #app .main.page-lesson .lesson-layout > .lesson-tools { container: lesson-tools / inline-size; }
@container lesson-tools (max-width: 1000px) {
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-content { gap: 10px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-actions .btn,
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-tools .lesson-tools-more {
    flex: 0 0 38px !important; width: 38px !important; min-width: 38px !important; height: 38px; min-height: 38px !important;
    padding: 0 !important; justify-content: center; border-radius: 50% !important; gap: 0 !important;
  }
  html.atelier-theme body #app .main.page-lesson .lesson-tools :is(.lesson-tools-actions .btn, .lesson-tools-more) > :is([data-i18n], span[aria-hidden]) {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  html.atelier-theme body #app .main.page-lesson .lesson-tools .lesson-tools-more::before { content: "⋯"; font-size: 18px; line-height: 1; letter-spacing: 0; }
  html.atelier-theme body #app .main.page-lesson .lesson-tools .lesson-tools-actions .icon { width: 17px; height: 17px; }
}@media (prefers-reduced-motion: reduce) {
  html.atelier-theme body #app .main.page-lesson .lesson-tools[data-open] { transition: none !important; }
}

/* Phone headings use the page gutter; a wide level selector scrolls from its first item. */
@media (max-width: 767px) {
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson { padding-inline: 16px; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-title { align-items: stretch; width: 100%; margin-inline: 0; padding-inline: 0; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-heading { width: 100%; max-width: none; margin-inline: 0; padding-inline: 0; text-align: left; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-heading > .en { display: block; overflow-wrap: anywhere; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-levels { display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; text-align: center; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-level-note { width: 100%; text-align: center; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .level-switch { align-self: center; margin-inline: auto; width: max-content; max-width: 100%; box-sizing: border-box; justify-content: flex-start; overflow-x: auto; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .level-switch button { flex-shrink: 0; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-card > .tabs { border-radius: 10px !important; }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .tabs :is(.tab, .st-ink, .st-ink::after) { border-radius: 8px !important; }
}
@media (max-width: 767px), (pointer: coarse) {
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools {
    left: 0; right: 0; bottom: 0; width: 100%; height: calc(60px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0; padding: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px)) calc(19px + env(safe-area-inset-left, 0px));
  }
  html.atelier-theme body #app .shell.workspace-shell .main[class].page-lesson .lesson-layout > .lesson-tools[data-open="false"] {
    left: calc(12px + env(safe-area-inset-left, 0px)); right: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: 60px; height: 60px; padding: 7px; border-radius: 30px;
  }
  html.atelier-theme body #app .main.page-lesson .lesson-tools-progress { bottom: calc(3px + env(safe-area-inset-bottom, 0px)); }
}

/* Keep the same flow nodes mounted. Only the phone geometry and terminal visibility change. */
@media (max-width: 767px) {
  html.atelier-theme body.home-mode #app .main.page-home .generation-home.has-generation { min-height: 0; flex: none; gap: 10px; padding: 12px 0; }
  html.atelier-theme body.home-mode #app .generation-home.has-generation .generation-stage { margin: 0; padding: 0; min-height: 0; flex: none; }
  html.atelier-theme body.home-mode #app .generation-home.has-generation .generation-thread { height: auto; padding: 0; }
  html.atelier-theme body.home-mode #app .generation-home.has-generation .generation-project { padding: 14px; min-height: 0; }
  html.atelier-theme body.home-mode #app .generation-project-head { padding-bottom: 10px; gap: 8px; }
  html.atelier-theme body.home-mode #app .generation-project-head h1 { margin-top: 4px; font-size: 20px; line-height: 1.4; }
  html.atelier-theme body.home-mode #app .generation-project > [data-part="progress"],
  html.atelier-theme body.home-mode #app .main.page-home .generation-home.has-generation .course-progress { min-height: 0; margin-top: 10px; padding-top: 10px; }
  html.atelier-theme body.home-mode #app .course-progress-head { min-height: 0; gap: 8px; }
  html.atelier-theme body.home-mode #app .main.page-home .generation-home.has-generation .progress-heading h2 { font-size: 17px; line-height: 1.4; }
  html.atelier-theme body.home-mode #app .progress-badge { flex-shrink: 0; font-size: 11px; }
  html.atelier-theme body.home-mode #app .st-flow { height: 144px; aspect-ratio: auto !important; margin-top: 12px; border-radius: 10px; }
  html.atelier-theme body.home-mode #app .st-flow > svg { overflow: hidden; }
  html.atelier-theme body.home-mode #app .st-agent { width: 20%; transform: translate(-50%, -14px); gap: 3px; }
  html.atelier-theme body.home-mode #app .st-agent-orb { width: 28px; height: 28px; border-radius: 50%; }
  html.atelier-theme body.home-mode #app .st-agent-orb .icon { width: 14px; height: 14px; }
  html.atelier-theme body.home-mode #app .st-agent strong { max-width: 100%; margin-top: 4px; font-size: 11px; line-height: 1.4; font-weight: 500; }
  html.atelier-theme body.home-mode #app .st-flow :is(.st-agent small, .st-branch.is-core, .st-packet) { display: none; }
  html.atelier-theme body.home-mode #app .st-edge { stroke-width: 1; }
  html.atelier-theme body.home-mode #app .st-branch { gap: 3px; padding: 4px; border-radius: 7px; font-size: 11px; }
  html.atelier-theme body.home-mode #app .st-branch .icon { width: 11px; height: 11px; }
  html.atelier-theme body.home-mode #app .st-flow-status { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 6px 8px; margin: 10px 0 0; }
  html.atelier-theme body.home-mode #app .st-flow-status strong { grid-column: 2 / -1; font-size: 12px; line-height: 1.5; }
  html.atelier-theme body.home-mode #app .st-flow-step { grid-column: 2; justify-self: start; font-size: 11px; }
  html.atelier-theme body.home-mode #app .st-flow-time { grid-column: 3; font-size: 11px; }
  html.atelier-theme body.home-mode #app .st-flow-detail { grid-column: 2 / -1; padding: 0; font-size: 11px; }
  html.atelier-theme body.home-mode #app .course-progress[data-state="done"] :is(.st-flow, .progress-pipeline, .st-flow-step, .st-flow-time) { display: none !important; }
  html.atelier-theme body.home-mode #app .generation-project[data-state="done"] > :is([data-part="head"], [data-part="notes"]),
  html.atelier-theme body.home-mode #app .generation-home.is-complete .workspace-footnote { display: none; }
  html.atelier-theme body.home-mode #app .main.page-home .generation-home.has-generation .course-progress[data-state="done"] { margin-top: 0; padding-top: 0; border-top: 0; }
  html.atelier-theme body.home-mode #app .main[class] .generation-result { margin-top: 12px; gap: 0; }
  html.atelier-theme body.home-mode #app .main[class] .generation-result .result-visual { max-height: 150px; aspect-ratio: auto; height: 150px; }
  html.atelier-theme body.home-mode #app .main[class] .generation-result .result-copy { padding: 10px 12px; }
  html.atelier-theme body.home-mode #app .main[class] .generation-result .result-title h2 { font-size: 18px; }
  html.atelier-theme body.home-mode #app .main[class] .generation-result .result-actions { margin-top: 8px; gap: 6px; }
  html.atelier-theme body.home-mode #app .generation-background-note { margin: 10px 0 0; font-size: 11px; }
}
