body:not(.light) {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #fff;
  --input: #f6f7fa;
  --text: #191c23;
  --muted: #535d6d;
  --line: #dfe4ed;
  --soft: #edf2fa;
  --accent: #0a56bf;
  --gold: #8a4f1a;
  --studio-blue: #0b5bd1;
  --studio-on-blue: #fff;
  --studio-blue-tint: #e7f0fd;
  --studio-blue-line: #bad6fe;
  --studio-surface: #fff;
  --studio-float: rgb(255 255 255 / 92%);
  --studio-shadow: 0 14px 46px rgb(21 36 63 / 7%);
  --fw-glass: #fff;
  --fw-glass-border: #dfe4ed;
}

body.light {
  color-scheme: dark;
  --bg: #15171c;
  --panel: #202329;
  --input: #191c22;
  --text: #f5f7fb;
  --muted: #b8c3d2;
  --line: #3b4350;
  --soft: #262e39;
  --accent: #9bc6ff;
  --gold: #f3bf84;
  --studio-blue: #a1caff;
  --studio-on-blue: #102445;
  --studio-blue-tint: #2a3b53;
  --studio-blue-line: #426189;
  --studio-surface: #202329;
  --studio-float: rgb(32 35 41 / 94%);
  --studio-shadow: 0 14px 46px rgb(0 0 0 / 24%);
  --fw-glass: #202329;
  --fw-glass-border: #3b4350;
}

body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  accent-color: var(--studio-blue);
}

body [hidden] { display: none !important; }
body :is(button, input, select, textarea, summary, a):focus-visible {
  outline: 2px solid var(--studio-blue);
  outline-offset: 3px;
}

body > header {
  min-height: 63px;
  background: var(--studio-float);
  border: 1px solid var(--line);
  box-shadow: var(--studio-shadow);
  padding-block: 8px;
}
body > header .brand { align-items: center; gap: 10px; }
body > header .brand strong { font-size: 18px; letter-spacing: -.04em; color: var(--text); }
body > header .logo { width: 37px; height: 37px; }
.header-actions button { padding-inline: 12px; min-height: 40px; }
#accountBtn { border-color: var(--line); background: var(--input); }

.panel, .utility, aside#fwCurriculum, .fw-rail {
  border-color: var(--line);
  box-shadow: var(--studio-shadow);
}
.panel { border-radius: 24px; }
.panel :is(h1, h2), .atlas-modal h2 {
  color: var(--text);
  letter-spacing: -.042em;
  text-wrap: balance;
}
.panel h1 { font-size: clamp(1.85rem, 4vw, 2.9rem); }
.panel h2 { font-size: clamp(1.35rem, 2.7vw, 1.9rem); }
.panel .muted { color: var(--muted); }
.shell main { width: min(100%, 1100px); }
#content, .studio-flow, #studioLessonProgress { scroll-margin-top: 94px; }
.studio-onboarding main > :is(#overview, .utility) { display: none; }

body :is(button.primary, .header-actions #today),
body.light :is(button.primary, .header-actions #today) {
  color: var(--studio-on-blue);
  background: var(--studio-blue);
  border-color: var(--studio-blue);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--studio-blue) 17%, transparent);
}
body button.primary:hover { filter: brightness(.94); }
button:not(:disabled):active { transform: translateY(1px); }
button[aria-disabled="true"] { opacity: .58; cursor: default; }

.fw-rail { background: var(--studio-float); }
body .fw-rail button.active,
body .fw-rail #fwRoadmap[aria-expanded="true"] {
  color: var(--accent);
  background: var(--studio-blue-tint);
  box-shadow: none;
}
body .fw-rail .studio-more { display: none; }
.studio-more-icon { font-size: 25px; line-height: 19px; font-weight: 750; }

body:not(.light) .fw-overview, body.light .fw-overview {
  color: var(--text);
  background: linear-gradient(140deg, var(--studio-surface), var(--studio-blue-tint));
  border-color: var(--studio-blue-line);
  box-shadow: var(--studio-shadow);
}
body .fw-overview :is(h2, small, b, p) { color: var(--text); }
body .fw-overview :is(.eyebrow, h2 em) { color: var(--accent); }
.fw-overview h2 { font-size: clamp(1.45rem, 3vw, 2.15rem); letter-spacing: -.043em; }
.fw-overview .fw-over-actions { row-gap: 6px; }
.fw-overview .fw-overstats > div { background: var(--studio-float); border-color: var(--line); }
.fw-overbar i { background: var(--studio-blue); }

.studio-flow { position: relative; min-width: 0; }
.studio-primary > h1 { margin: 0 0 .65em; }
.studio-flow-top { margin: 1.15rem 0 1.6rem; }
.studio-step-count {
  margin: 0 0 .55rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}
.studio-step-list {
  position: relative;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 5px;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--input);
}
.studio-step-list li { flex: 0 0 auto; min-width: 0; }
body .studio-step-list button,
body.light .studio-step-list button:not(.primary) {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 5px 12px 5px 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: .8rem;
  white-space: nowrap;
}
.studio-step-list button span {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  font-variant-numeric: tabular-nums;
}
body .studio-step-list button[aria-current="step"] {
  border-color: var(--studio-blue-line);
  background: var(--studio-blue-tint);
  color: var(--accent);
}
.studio-step-list button[aria-current="step"] span {
  color: var(--studio-on-blue);
  background: var(--studio-blue);
}
.studio-step { min-width: 0; animation: studio-enter 230ms ease-out both; }
.studio-step > h2 { margin: 0 0 .7rem; }
.studio-step > h2:focus { outline: none; }
.studio-step > p:first-of-type { max-width: 65ch; }
.studio-group > .studio-flow .studio-step > h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.studio-original-panel { min-width: 0; }
.studio-original-panel > :is(h1,h2):first-child { margin-top: 0; }
.studio-flow-error { margin: .55rem 0 0; color: var(--gold); font-weight: 650; }
.studio-flow-error:empty, #fwProfileError:empty { display: none; }
.studio-flow-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 1.5rem;
  padding-top: .95rem;
  border-top: 1px solid var(--line);
}
.studio-flow-actions:has(> :only-child[hidden]) { display: none; }
.studio-flow-actions button { min-height: 44px; font-size: .875rem; }
.studio-flow-actions button[data-studio-move="-1"], #studioLessonActions button:first-child { margin-inline-end: auto; }

.fw-profile-grid {
  display: grid;
  margin: 1rem 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.studio-step :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea),
#atlasLogin input {
  min-height: 46px;
  border-radius: 12px;
  color: var(--text);
  background-color: var(--input);
  border-color: var(--line);
  font-size: 1rem;
}
.studio-step input[type="file"] { width: 100%; overflow: hidden; }
.studio-step fieldset { border: 0; padding: 0; margin: 0 0 .65rem; min-inline-size: 0; }
.studio-step legend { font-weight: 700; }
.studio-step .fw-chip {
  min-height: 44px;
  border-color: var(--line);
  background: var(--input);
}
.studio-step .fw-chip:has(input:checked) {
  border-color: var(--studio-blue-line);
  background: var(--studio-blue-tint);
}

.studio-lesson-progress { display: flex; align-items: center; gap: 10px; }
.studio-lesson-progress p { margin: 0; white-space: nowrap; }
.studio-lesson-progress progress { width: min(170px, 42%); height: 7px; }
.fw-study .fw-lesson-tabs {
  position: relative;
  margin: .85rem 0 1.4rem;
  background: var(--input);
  border-color: var(--line);
  border-radius: 16px;
}
.fw-study .fw-lesson-tabs button { min-height: 43px; border-radius: 12px; }
.fw-study .fw-lesson-tabs button[aria-selected="true"] {
  color: var(--accent) !important;
  background: var(--studio-blue-tint) !important;
  border-color: var(--studio-blue-line) !important;
}
.fw-study [data-fw-lesson-panel] { animation: studio-enter 230ms ease-out both; }
.fw-study [data-fw-lesson-panel] > .fw-next { display: none; }

.studio-project-list { display: grid; margin: 1.2rem 0; gap: 8px; }
.studio-project, .studio-notebook-settings {
  min-width: 0;
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--input);
}
.studio-project summary, .studio-notebook-settings summary {
  min-height: 48px;
  padding-block: .72rem;
  font-weight: 710;
  cursor: pointer;
}
.studio-project[open] { background: var(--panel); border-color: var(--studio-blue-line); }
.studio-project[open] > .studio-flow, .studio-notebook-settings[open] { padding-bottom: .85rem; }
.studio-project .studio-flow-top { margin-top: .6rem; }
.studio-project .atlas-project-links { padding: 0; background: transparent; border: 0; }
.studio-file-list > p { overflow-wrap: anywhere; }
.studio-file-list button { margin: 0 3px 7px; }

.atlas-modal { background: rgb(13 25 45 / 48%); }
.atlas-modal > section {
  width: min(540px, 100%);
  padding: clamp(20px, 6vw, 34px);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 25px 90px rgb(0 0 0 / 22%);
}
.atlas-modal .studio-step {
  width: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.atlas-modal p { font-size: .925rem; }
.atlas-modal :is(button, input) { min-height: 44px; }
.studio-identity { overflow-wrap: anywhere; }
#atlasLogin label { margin-block: 14px; }
#atlasLogin button { width: 100%; margin-top: .4rem; }

.studio-sheet {
  width: min(calc(100vw - 24px), 510px);
  max-height: calc(100dvh - 65px);
  margin: auto auto max(11px, env(safe-area-inset-bottom));
  padding: 16px;
  color: var(--text);
  background: var(--studio-surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 25px 85px rgb(0 0 0 / 32%);
  animation: studio-enter 210ms ease-out both;
}
.studio-sheet::backdrop { background: rgb(10 20 40 / 47%); backdrop-filter: blur(5px); }
.studio-sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.studio-sheet-head h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.03em; }
.studio-sheet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.studio-sheet-grid button, .studio-sheet-actions button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 9px;
  border-radius: 12px;
  text-align: start;
  font-size: .84rem;
}
.studio-sheet-grid svg { flex: 0 0 20px; }
.studio-sheet-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }

.fw-sec-dialog {
  width: min(calc(100vw - 24px), 500px);
  max-height: calc(100dvh - 35px);
  background: var(--studio-surface);
  border-radius: 24px;
}
.fw-sec-dialog :is(input, button) { min-height: 44px; font-size: 1rem; }
.studio-backup-modes { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.studio-backup-modes button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--studio-blue-tint);
  border-color: var(--studio-blue-line);
}

@keyframes studio-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 700px) {
  body { font-size: 15px; }
  body > header {
    flex-wrap: nowrap;
    margin: 7px 8px 0;
    padding-inline: 12px;
    gap: 4px;
    top: max(5px, env(safe-area-inset-top));
    border-radius: 19px;
  }
  body > header .brand strong { font-size: 17px; }
  body > header :is(#fwSecure, #backup, #restore, #menu, #today) { display: none; }
  .header-actions { flex-wrap: nowrap; gap: 5px; }
  .header-actions button { min-height: 44px; }
  .header-actions #theme { min-width: 44px; }
  .shell, .focus-mode .shell { padding-bottom: calc(94px + env(safe-area-inset-bottom)); }
  .panel { padding: 15px; border-radius: 20px; }
  .fw-study .fw-study-head { align-items: flex-start; gap: 6px; }
  .fw-study .fw-study-head h1 { font-size: clamp(1.55rem, 6.5vw, 2.1rem); }
  .fw-overview { border-radius: 20px; }
  .fw-rail {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    justify-items: stretch;
    inset-inline: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    height: 62px;
    border-radius: 20px;
    padding: 4px;
    gap: 3px;
    overflow: hidden;
  }
  .fw-rail [data-fw-tab]:not([data-studio-essential]), .fw-rail .fw-rail-sep {
    display: none !important;
  }
  body .fw-rail .studio-more { display: flex; }
  .fw-rail button, body.fw-compact .fw-rail button, .fw-rail #fwRoadmap {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    border-radius: 14px;
    padding: 4px 2px;
  }
  .fw-rail button span, body.fw-compact .fw-rail button span { font-size: .65rem; }
  .fw-rail button .studio-more-icon { font-size: 25px; }
  .studio-step-list { border-radius: 14px; }
  .studio-flow-top { margin-bottom: 1rem; }
  .studio-flow-actions { gap: 7px; margin-top: 1rem; }
  .fw-profile-grid { grid-template-columns: 1fr; gap: 10px; }
  .studio-project, .studio-notebook-settings { padding-inline: 10px; }
  .studio-project .studio-flow-actions button { min-width: 75px; }
  .studio-step textarea { resize: vertical; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .studio-step, .studio-sheet, .fw-study [data-fw-lesson-panel], .fw-mark * { animation: none !important; }
  .shell, .fw-rail, button { transition: none !important; }
}

@media print {
  .studio-flow-top, .studio-flow-actions, .studio-lesson-progress { display: none !important; }
  .fw-study [data-fw-lesson-panel][hidden] { display: block !important; }
}
