:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --soft: #f4f7fb;
  --paper: #ffffff;
  --blue: #5b5ce2;
  --blue-dark: #4742b8;
  --teal: #17b8b3;
  --teal-dark: #0f8f91;
  --green: #138a63;
  --red: #c2412f;
  --amber: #b7791f;
  --violet: #6f4cc3;
  --violet-soft: #f1efff;
  --teal-soft: #e7fbfa;
  --shadow: 0 16px 40px rgba(44, 35, 91, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #eef4f7;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.classroom-active {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background:
    linear-gradient(180deg, rgba(23, 184, 179, 0.12), transparent 34%),
    #15142a;
  color: #f8fafc;
}

.brand {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  isolation: isolate;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  color: white;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
  overflow: hidden;
}

.brand-mark::before {
  content: attr(data-kaizen);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -49%) rotate(-10deg);
  z-index: -1;
  color: rgba(255, 255, 255, 0.24);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.16em;
  white-space: nowrap;
}

.brand strong {
  display: block;
  font-size: 1rem;
}

.brand small {
  display: block;
  color: #c9c7df;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-list a {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #dedcf0;
  text-decoration: none;
  font-weight: 650;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-list a.nav-primary {
  color: #ffffff;
  font-weight: 780;
}

.nav-list a.nav-child {
  margin-left: 18px;
  min-height: 34px;
  color: #cbc8e5;
  font-size: 0.94rem;
  position: relative;
}

.nav-list a.nav-child::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.25);
}

.nav-list a.nav-child .nav-icon {
  width: 20px;
  height: 20px;
  flex-basis: 20px;
  font-size: 0.76rem;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #9ff4eb;
  font-size: 0.86rem;
  font-weight: 850;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.nav-list a:hover,
.nav-list a.active {
  background: linear-gradient(90deg, rgba(23,184,179,0.18), rgba(111,76,195,0.18));
  color: white;
  transform: translateX(3px);
}

.nav-list a:hover .nav-icon,
.nav-list a.active .nav-icon {
  background: linear-gradient(135deg, rgba(23,184,179,0.95), rgba(111,76,195,0.92));
  color: white;
  box-shadow: 0 8px 18px rgba(23,184,179,0.18);
}

.sidebar-panel {
  margin-top: auto;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.075);
  color: #dedcf0;
  border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-panel p {
  margin: 8px 0 0;
  line-height: 1.45;
  font-size: 0.9rem;
}

.eyebrow {
  color: #2dd4bf;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.main-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  background: rgba(255,255,255,0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-search {
  max-width: 620px;
  display: grid;
  gap: 5px;
}

.topbar-search label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.topbar-search input,
.filter-row input,
.filter-row select,
.tool-control select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

.topbar-search input:focus,
.filter-row input:focus,
.filter-row select:focus,
.tool-control select:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(23, 184, 179, 0.13);
}

.account-pill {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.account-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.account-pill strong {
  display: block;
  font-size: 0.88rem;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

.menu-button {
  display: none;
  place-items: center;
  gap: 4px;
}

.menu-button span {
  width: 18px;
  height: 2px;
  background: var(--ink);
}

#app {
  min-width: 0;
  padding: 28px;
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0;
  font-size: 2rem;
}

.page-header p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  cursor: pointer;
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--violet), var(--teal-dark));
  color: white;
}

.button.primary:hover {
  background: linear-gradient(135deg, #5e41ad, #0d7f82);
}

.home-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  margin-bottom: 22px;
  padding: 26px;
  min-height: 260px;
  border: 1px solid rgba(111, 76, 195, 0.18);
  border-radius: 8px;
  background:
    radial-gradient(circle at 88% 18%, rgba(23, 184, 179, 0.18), transparent 24%),
    radial-gradient(circle at 78% 78%, rgba(111, 76, 195, 0.12), transparent 28%),
    linear-gradient(135deg, rgba(111, 76, 195, 0.09), rgba(23, 184, 179, 0.08)),
    linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
  overflow: hidden;
}

.home-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--violet), var(--teal));
  z-index: 2;
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: 18px 22px 18px auto;
  width: min(430px, 45%);
  background-image:
    linear-gradient(rgba(111, 76, 195, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 184, 179, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  opacity: 0.72;
  z-index: 0;
}

.hero-copy,
.home-hero-actions {
  position: relative;
  z-index: 1;
}

.home-hero h1 {
  max-width: 840px;
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.03;
  letter-spacing: 0;
}

.home-hero p {
  max-width: 820px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.58;
}

.hero-diagram {
  position: absolute;
  top: 34px;
  right: 34px;
  width: min(410px, 44%);
  height: calc(100% - 64px);
  pointer-events: none;
  z-index: 0;
}

.diagram-card,
.diagram-node,
.diagram-line {
  position: absolute;
  display: block;
}

.diagram-card {
  min-width: 82px;
  padding: 10px 12px;
  border: 1px solid rgba(111, 76, 195, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 34px rgba(44, 35, 91, 0.08);
  color: rgba(44, 35, 91, 0.62);
  font-weight: 850;
  text-align: center;
  backdrop-filter: blur(8px);
}

.diagram-card-a {
  top: 14px;
  right: 56px;
}

.diagram-card-b {
  top: 92px;
  right: 204px;
  min-width: 58px;
  color: rgba(13, 127, 130, 0.66);
  font-size: 1.5rem;
}

.diagram-card-c {
  right: 28px;
  bottom: 22px;
  min-width: 64px;
  color: rgba(111, 76, 195, 0.68);
  font-size: 1.35rem;
}

.diagram-node {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(111, 76, 195, 0.74), rgba(23, 184, 179, 0.74));
  box-shadow: 0 0 0 8px rgba(23, 184, 179, 0.09);
}

.node-a {
  top: 58px;
  right: 194px;
}

.node-b {
  top: 152px;
  right: 112px;
}

.node-c {
  right: 254px;
  bottom: 38px;
}

.diagram-line {
  height: 2px;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(111, 76, 195, 0.36), rgba(23, 184, 179, 0.36));
}

.line-a {
  top: 65px;
  right: 126px;
  width: 138px;
  transform: rotate(32deg);
}

.line-b {
  right: 94px;
  bottom: 76px;
  width: 184px;
  transform: rotate(-19deg);
}

.home-hero-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 360px;
}

.guide-callout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 390px);
  gap: 18px;
  align-items: center;
  margin: -6px 0 22px;
  padding: 18px;
  border: 1px solid rgba(111, 76, 195, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(111, 76, 195, 0.1), rgba(23, 184, 179, 0.08)),
    #ffffff;
  box-shadow: 0 10px 28px rgba(44, 35, 91, 0.08);
}

.guide-callout h2 {
  margin: 4px 0 6px;
  color: var(--ink);
  font-size: 1.18rem;
}

.guide-callout p {
  max-width: 760px;
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.55;
}

.guide-callout img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 6px 18px rgba(23, 32, 51, 0.1);
}

.worksheet-callout {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: -6px 0 22px;
  padding: 18px;
  border: 1px solid rgba(23, 184, 179, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(23, 184, 179, 0.11), rgba(111, 76, 195, 0.08)),
    #ffffff;
  box-shadow: 0 10px 28px rgba(44, 35, 91, 0.08);
}

.worksheet-callout-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  color: #fff;
  font-size: 1.3rem;
  font-weight: 900;
}

.worksheet-callout h2 {
  margin: 0;
  font-size: 1.12rem;
}

.worksheet-callout p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.metric,
.panel,
.tool-card,
.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
}

.metric {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, rgba(111, 76, 195, 0.75), rgba(23, 184, 179, 0.75));
}

.metric span {
  color: var(--muted);
  font-weight: 750;
  font-size: 0.8rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
  color: #282450;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.split-grid > .panel:first-child {
  border-color: rgba(23, 184, 179, 0.45);
  background:
    linear-gradient(135deg, rgba(23, 184, 179, 0.18), rgba(111, 76, 195, 0.13)),
    #ffffff;
  box-shadow: 0 12px 32px rgba(23, 184, 179, 0.12);
}

.split-grid > .panel:first-child h2 {
  color: #19346b;
}

.panel {
  padding: 18px;
}

.panel h2 {
  color: #282450;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
}

.panel p {
  color: var(--muted);
  line-height: 1.55;
}

.migration-list {
  display: grid;
  gap: 10px;
}

.migration-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid #dde3ee;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(241,239,255,0.75), rgba(231,251,250,0.55));
}

.migration-item span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--violet), var(--teal-dark));
  color: white;
  font-weight: 800;
}

.migration-item h3 {
  margin: 0 0 3px;
  font-size: 0.95rem;
}

.migration-item p {
  margin: 0;
  font-size: 0.88rem;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 170px 170px 150px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-reset {
  min-width: 86px;
  height: 100%;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tool-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, rgba(111, 76, 195, 0.78), rgba(23, 184, 179, 0.78));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tool-card:hover {
  border-color: rgba(23, 184, 179, 0.55);
  box-shadow: var(--shadow);
}

.tool-card:hover::before {
  opacity: 1;
}

.tool-card-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.tool-card h2 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.18;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--violet-soft);
  color: #4c3a8a;
  font-size: 0.7rem;
  font-weight: 800;
}

.badge.free {
  background: #dcfce7;
  color: #166534;
}

.badge.pro {
  background: #fff7ed;
  color: #9a3412;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.legacy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.legacy-stage {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
}

.legacy-stage.classroom {
  --classroom-frame-scale: 1;
  position: fixed;
  inset: 0;
  z-index: 1000;
  border: 0;
  border-radius: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  box-shadow: none;
}

.legacy-toolbar {
  min-height: 48px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(241, 239, 255, 0.75), rgba(231, 251, 250, 0.75)),
    #f8fbff;
}

.legacy-stage.classroom .legacy-toolbar {
  min-height: 42px;
  padding: 7px 10px;
  align-items: center;
  flex-direction: row;
  background: #111827;
  color: white;
}

.legacy-stage.classroom .badge-row {
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.legacy-toolbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-path {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.legacy-stage.classroom .tool-path {
  color: #cbd5e1;
}

.classroom-exit {
  display: none;
  min-height: 30px;
  padding: 5px 10px;
}

.legacy-stage.classroom .classroom-exit {
  display: inline-flex;
}

@media (max-width: 820px) {
  .legacy-stage.classroom .tool-path {
    display: none;
  }
}

.legacy-frame {
  display: block;
  width: 100%;
  height: min(74vh, 820px);
  border: 0;
  background: white;
}

.site-guide-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: calc(100vh - 128px);
}

.site-guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.site-guide-frame {
  display: block;
  width: 100%;
  min-height: calc(100vh - 182px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
}

.worksheet-builder {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.worksheet-controls {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
}

.worksheet-control {
  display: grid;
  gap: 6px;
}

.worksheet-control label,
.worksheet-options label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.worksheet-control select,
.worksheet-control input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: white;
  color: var(--ink);
}

.worksheet-control select:focus,
.worksheet-control input:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(23, 184, 179, 0.13);
}

.worksheet-count-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.worksheet-count-preset {
  min-height: 30px;
  border: 1px solid rgba(23, 184, 179, 0.32);
  border-radius: 6px;
  background: #eefbfb;
  color: #106a6e;
  cursor: pointer;
  font-weight: 850;
}

.worksheet-count-preset:hover {
  border-color: var(--teal);
  background: #dff7f6;
}

.worksheet-options {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(111, 76, 195, 0.16);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(241,239,255,0.8), rgba(231,251,250,0.7));
}

.worksheet-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #282450;
}

.worksheet-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.worksheet-status[data-tone="success"] {
  color: var(--green);
  font-weight: 750;
}

.worksheet-status[data-tone="error"] {
  color: var(--red);
  font-weight: 750;
}

.worksheet-section-list {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.worksheet-section-list h3 {
  margin: 0;
  color: #282450;
  font-size: 0.95rem;
}

.worksheet-section-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.worksheet-section-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(23, 184, 179, 0.22);
  border-radius: 8px;
  background: #ffffff;
}

.worksheet-section-item strong,
.worksheet-section-item span {
  display: block;
}

.worksheet-section-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.worksheet-section-remove {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 0.78rem;
}

.worksheet-preview {
  min-height: 640px;
  overflow: auto;
  background:
    linear-gradient(135deg, rgba(111,76,195,0.05), rgba(23,184,179,0.05)),
    #f8fbff;
}

.worksheet-loader {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
}

.worksheet-sheet {
  max-width: 900px;
  margin: 0 auto;
  padding: 34px;
  border: 1px solid #dfe6ef;
  border-radius: 8px;
  background: white;
  color: #111827;
  box-shadow: 0 16px 34px rgba(23, 32, 51, 0.08);
}

.worksheet-sheet-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 2px solid #111827;
}

.worksheet-sheet-header h2 {
  margin: 6px 0;
  font-size: 1.65rem;
}

.worksheet-sheet-header p {
  margin: 0;
  color: #4b5563;
}

.worksheet-student-fields {
  display: grid;
  gap: 12px;
  font-weight: 750;
}

.worksheet-student-fields span {
  min-height: 28px;
  border-bottom: 1px solid #9ca3af;
}

.worksheet-question-list {
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 18px;
  list-style: none;
}

.worksheet-section {
  margin-top: 24px;
}

.worksheet-section h3 {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid #d1d5db;
  font-size: 1.2rem;
}

.worksheet-section > p {
  margin: 4px 0 0;
  color: #4b5563;
}

.worksheet-question {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  break-inside: avoid;
}

.worksheet-question-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #111827;
  color: white;
  font-weight: 850;
}

.worksheet-question-text {
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.5;
}

.worksheet-question-text sup,
.worksheet-answer sup,
.worksheet-steps sup,
.worksheet-key-item sup {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: super;
}

.worksheet-question-text .superscript,
.worksheet-answer .superscript,
.worksheet-steps .superscript,
.worksheet-key-item .superscript {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: super;
}

.worksheet-steps .step-indicator,
.worksheet-steps .step-arrow {
  display: inline-block;
  margin-right: 0.35em;
}

.worksheet-fraction {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  margin: 0 0.18em;
  vertical-align: middle;
  text-align: center;
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  line-height: 1.05;
}

.worksheet-fraction span:first-child {
  border-bottom: 1px solid currentColor;
  padding: 0 0.18em 0.08em;
}

.worksheet-fraction span:last-child {
  padding: 0.08em 0.18em 0;
}

sup .worksheet-fraction {
  margin: 0 0.03em;
  font-size: 0.72em;
  line-height: 0.88;
  transform: translateY(-0.18em);
}

sup .worksheet-fraction span:first-child {
  padding: 0 0.12em 0.03em;
}

sup .worksheet-fraction span:last-child {
  padding: 0.03em 0.12em 0;
}

.worksheet-integral {
  display: inline-flex;
  align-items: center;
  gap: 0.03em;
  margin-right: 0.1em;
  vertical-align: middle;
}

.worksheet-integral-limits {
  display: inline-grid;
  grid-template-rows: auto auto;
  line-height: 0.92;
  font-size: 0.64em;
  transform: translateY(-0.03em);
}

.worksheet-limited-operator {
  display: inline-grid;
  grid-template-rows: auto auto auto;
  align-items: center;
  justify-items: center;
  margin: 0 0.18em;
  vertical-align: middle;
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  line-height: 0.9;
}

.worksheet-limited-symbol {
  font-size: 1.35em;
  line-height: 0.78;
}

.worksheet-limited-upper,
.worksheet-limited-lower {
  font-size: 0.58em;
  line-height: 0.95;
  white-space: nowrap;
}

.worksheet-question-text .system-equations,
.worksheet-question-text .prob-table {
  margin-top: 8px;
}

.worksheet-math-table {
  border-collapse: collapse;
  margin: 8px 0;
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
}

.worksheet-math-table td {
  min-width: 34px;
  padding: 4px 8px;
  border-bottom: 1px solid #d1d5db;
  text-align: center;
}

.worksheet-math-table td:first-child {
  border-right: 2px solid #6b7280;
  color: #4c1d95;
  font-weight: 700;
}

.worksheet-question-text .system-line {
  margin: 4px 0;
}

.worksheet-question-text table {
  max-width: 100%;
  border-collapse: collapse;
}

.worksheet-question-text td,
.worksheet-question-text th {
  border: 1px solid #9ca3af;
  padding: 4px 7px;
}

.worksheet-working-lines {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.worksheet-working-lines span {
  height: 1px;
  background: #d1d5db;
}

.worksheet-answer,
.worksheet-steps {
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
  background: #f0fdfa;
  color: #134e4a;
  line-height: 1.45;
}

.worksheet-steps {
  background: #f5f3ff;
  color: #3b236d;
}

.worksheet-answer-key {
  break-before: page;
  page-break-before: always;
  margin-top: 42px;
  padding-top: 22px;
  border-top: 2px solid #111827;
}

.worksheet-answer-key-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.worksheet-answer-key-header h2 {
  margin: 4px 0 0;
  font-size: 1.55rem;
}

.worksheet-key-section {
  margin-top: 18px;
  break-inside: avoid;
}

.worksheet-key-section h3 {
  margin: 0;
  font-size: 1.05rem;
}

.worksheet-key-section p {
  margin: 4px 0 10px;
  color: #4b5563;
}

.worksheet-key-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.worksheet-key-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  line-height: 1.45;
}

.worksheet-key-item > span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
}

.legacy-stage.classroom .legacy-frame {
  width: calc(100% / var(--classroom-frame-scale));
  height: calc(100% / var(--classroom-frame-scale));
  min-height: 0;
  transform: scale(var(--classroom-frame-scale));
  transform-origin: top left;
}

@media (min-width: 1400px) {
  .legacy-stage.classroom {
    --classroom-frame-scale: 1;
  }
}

@media (max-width: 820px) {
  .legacy-stage.classroom {
    --classroom-frame-scale: 1;
  }
}

.missing-tool {
  min-height: 520px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(19, 138, 99, 0.06)),
    white;
}

.missing-tool h2 {
  margin: 0;
}

.missing-tool p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.missing-tool code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #e9eef6;
  color: var(--ink);
}

.related-list {
  display: grid;
  gap: 8px;
}

.related-list a {
  min-height: 38px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 750;
}

.related-list span {
  color: var(--muted);
  font-size: 0.78rem;
}

.topic-map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 18px;
}

.topic-map-card {
  padding: 10px;
  border: 1px solid rgba(111, 76, 195, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(241, 239, 255, 0.65), rgba(231, 251, 250, 0.32));
}

.topic-map-card h4 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 0.86rem;
}

.topic-map-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.standards-list {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.standards-list {
  display: grid;
  gap: 7px;
  margin: 10px 0 16px;
}

.tool-stage {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.tool-stage-head {
  padding: 18px;
  display: grid;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.level-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-weight: 750;
}

.level-tabs button.active {
  border-color: var(--blue);
  background: #dbeafe;
  color: #1e40af;
}

.tool-controls {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.tool-control {
  display: grid;
  gap: 5px;
}

.tool-control label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.question-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.question-card {
  padding: 14px;
}

.question-card header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.question-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--red);
  font-weight: 850;
  flex: 0 0 auto;
}

.question-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.question-card p {
  margin: 0;
  color: var(--muted);
}

.answer-line,
.steps-box {
  display: none;
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
}

.answer-line.visible {
  display: block;
  background: #ecfdf5;
  color: #065f46;
  font-weight: 800;
}

.steps-box.visible {
  display: block;
  background: #fff7ed;
  color: #7c2d12;
}

.teacher-panel {
  position: sticky;
  top: 92px;
  align-self: start;
}

.teacher-panel ul {
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.teacher-panel h3 {
  margin: 18px 0 8px;
  font-size: 1rem;
}

.empty-state {
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.mobile-nav {
  display: none;
}

@media (max-width: 1120px) {
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-row {
    grid-template-columns: minmax(200px, 1fr) 1fr;
  }

  .tool-layout,
  .legacy-layout,
  .split-grid,
  .worksheet-builder {
    grid-template-columns: 1fr;
  }

  .teacher-panel,
  .worksheet-controls {
    position: static;
  }

  .legacy-frame {
    height: 70vh;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 12px;
  }

  .menu-button {
    display: grid;
  }

  .account-pill {
    display: none;
  }

  #app {
    padding: 18px 12px;
  }

  .page-header {
    grid-template-columns: 1fr;
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .home-hero::after,
  .hero-diagram {
    opacity: 0.22;
    width: 58%;
    right: 4%;
  }

  .home-hero-actions {
    justify-content: flex-start;
    max-width: none;
  }

  .guide-callout,
  .worksheet-callout {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .topic-map-grid {
    grid-template-columns: 1fr;
  }

  .guide-callout .button,
  .worksheet-callout .button {
    justify-self: start;
  }

  .filter-row,
  .tool-controls,
  .level-tabs,
  .metric-grid,
  .tool-grid,
  .legacy-layout,
  .worksheet-sheet-header {
    grid-template-columns: 1fr;
  }

  .legacy-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tool-path {
    white-space: normal;
  }

  .mobile-nav {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .mobile-nav.open {
    pointer-events: auto;
    opacity: 1;
  }

  .mobile-nav-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.55);
  }

  .mobile-nav-panel {
    position: relative;
    width: min(320px, 86vw);
    min-height: 100vh;
    padding: 18px;
    background: #111827;
    color: white;
    box-shadow: var(--shadow);
  }
}

@media (min-width: 620px) and (max-width: 820px) {
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .topbar,
  .page-header,
  .worksheet-controls,
  .mobile-nav {
    display: none !important;
  }

  .app-shell,
  .main-wrap,
  #app,
  .worksheet-builder,
  .worksheet-preview {
    display: block;
    padding: 0;
    margin: 0;
    min-height: auto;
    border: 0;
    box-shadow: none;
    background: white;
  }

  .worksheet-sheet {
    max-width: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
