/* Teacher builder styles. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #1b1f24;
  --muted: #56606d;
  --line: #d3d9e0;
  --accent: #1f5fbf;
  --accent-soft: #e8f0fc;
  --accent-ink: #ffffff;
  --ok: #17663a;
  --ok-bg: #e6f4ea;
  --bad: #a3261b;
  --bad-bg: #fdecea;
  --warn: #7a4b00;
  --warn-bg: #fff4dc;
  --focus: #ffbf47;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
h1, h2, h3 { line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* File pickers are hidden inputs styled through their label: show focus on the label. */
label.btn:has(+ input[type="file"]:focus-visible),
input[type="file"]:focus-visible + label.btn,
label.btn:has(~ input[type="file"]:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading, .noscript { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none;
}
.btn:hover:not([disabled]) { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover:not([disabled]) { background: var(--accent-soft); }
.btn-danger { color: var(--bad); }
.btn-small { min-height: 32px; padding: 4px 10px; font-size: .875rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- start screen ---------- */
.start { max-width: 1040px; margin: 0 auto; padding: 32px 16px 48px; }
.start h1 { font-size: 2rem; margin: 0 0 4px; }
.start .lede { color: var(--muted); margin: 0 0 24px; max-width: 60ch; }
.start h2 { font-size: 1.15rem; margin: 28px 0 12px; }
.tile-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tile h3 { margin: 0; font-size: 1.05rem; }
.tile p { margin: 0; color: var(--muted); font-size: .925rem; }
.tile .btn { margin-top: auto; align-self: flex-start; }
.tile.is-featured { border-color: var(--accent); }
.tile.is-blank { border-style: dashed; background: var(--surface-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.resume {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent);
}
.resume p { margin: 0; }

/* ---------- AI drafting ---------- */
.ai-card {
  padding: 20px; margin: 0 0 24px; border-radius: var(--radius); background: var(--surface);
  border: 2px solid var(--accent); box-shadow: var(--shadow);
}
.ai-card h2 { margin: 0 0 4px; font-size: 1.25rem; }
.ai-card .row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.ai-status { margin: 10px 0 0; font-weight: 600; color: var(--accent); }
.ai-status:empty { display: none; }
.ai-status.is-error { color: var(--bad); }
.ai-more { border-color: var(--accent); }
.ai-progress { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.ai-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.ai-progress-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.ai-bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.ai-bar-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.ai-progress.is-warning .ai-bar-fill { background: var(--warn); }
.ai-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 4px; padding: 0; font-size: .9rem; color: var(--muted); }
.ai-steps li { display: flex; align-items: center; gap: 6px; }
.ai-steps li.is-done { color: var(--ok); }
.ai-steps li.is-current { color: var(--ink); font-weight: 600; }
.ai-step-icon { width: 1em; text-align: center; }
.ai-progress-msg { margin: 6px 0; font-weight: 600; }
.ai-progress.is-warning .ai-progress-msg { color: var(--warn); }
@media (prefers-reduced-motion: reduce) { .ai-bar-fill { transition: none; } }
.custom-card, .create-card { border-color: #7a3fb0; }
.custom-card h2::before, .create-card h2::before { content: "\2726  "; color: #7a3fb0; }
.std-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.std-strand { margin: 10px 0 2px; font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.std-strand:first-child { margin-top: 0; }
.create-card input[type="search"] { margin-bottom: 6px; }
.create-card .cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.pic-preview { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.pic-preview img { max-width: 220px; max-height: 140px; border-radius: 8px; border: 1px solid var(--line); }
.custom-frame { min-height: 640px; }
[hidden] { display: none !important; }

/* ---------- wizard shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px;
}
.brand { font-weight: 700; margin-right: 8px; }
.summary { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1 1 360px; font-size: .9rem; color: var(--muted); }
.summary strong { color: var(--ink); font-weight: 600; }
.save-state { font-size: .82rem; color: var(--muted); }

.stepper { background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.stepper ol { display: flex; gap: 4px; list-style: none; margin: 0; padding: 8px 16px; min-width: max-content; }
.stepper button {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  border: 1px solid transparent; background: none; cursor: pointer; font-weight: 600; color: var(--muted);
}
.stepper button[disabled] { cursor: not-allowed; opacity: .55; }
.stepper .num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); font-size: .85rem;
}
.stepper button[aria-current="step"] { color: var(--accent); background: var(--accent-soft); }
.stepper button[aria-current="step"] .num { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.stepper .is-visited .num { border-color: var(--accent); }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; font-size: .75rem;
  background: var(--bad-bg); color: var(--bad); text-align: center; font-weight: 700;
}
.badge:empty { display: none; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; max-width: 1600px; margin: 0 auto; }
@media (min-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(380px, 44%); align-items: start; }
  .preview-pane { position: sticky; top: 112px; height: calc(100vh - 128px); }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel > h2 { margin: 0 0 4px; font-size: 1.35rem; }
.panel > h2:focus { outline: none; }
.panel .step-lede { margin: 0 0 20px; color: var(--muted); }
.step-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- form controls ---------- */
.section { margin: 0 0 24px; }
.section > h3 { font-size: 1.05rem; margin: 0 0 4px; }
.section > .help { margin-top: 0; }
fieldset.section { border: 0; padding: 0; }
fieldset.section > legend { font-size: 1.05rem; font-weight: 700; padding: 0; margin-bottom: 4px; }
.field { margin: 0 0 14px; }
.label { display: block; font-weight: 600; margin-bottom: 4px; }
.help { color: var(--muted); font-size: .875rem; margin: 2px 0 6px; }
.input, .select, .textarea {
  width: 100%; padding: 8px 10px; min-height: 40px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
}
.textarea { min-height: 72px; resize: vertical; }
.input.narrow { max-width: 140px; }
.input.is-invalid { border-color: var(--bad); }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; }
.check .check-body { display: flex; flex-direction: column; }
.check .check-title { font-weight: 600; }
.check .help { margin: 0; }
.check.is-disabled { opacity: .55; cursor: not-allowed; }
.soon { font-size: .72rem; font-weight: 700; padding: 1px 6px; margin-left: 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); vertical-align: middle; }
.inline-checks { display: flex; flex-wrap: wrap; gap: 4px 20px; }

.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card-option {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 12px 40px;
  border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--surface);
}
.card-option input { position: absolute; left: 14px; top: 15px; width: 18px; height: 18px; }
.card-option.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.card-title { font-weight: 700; }
.card-desc { font-size: .875rem; color: var(--muted); }

details.more { border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; margin: 16px 0; }
details.more > summary { cursor: pointer; font-weight: 600; padding: 12px 0; color: var(--accent); }
details.more[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }

/* standards */
.std-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px; }
.std-list .check { border-bottom: 1px solid var(--line); padding: 8px 0; }
.std-list .check:last-child { border-bottom: 0; }
.std-code { font-weight: 700; }
.placeholder-tag { font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); margin-left: 6px; }
.empty { color: var(--muted); font-style: italic; padding: 8px 0; }

/* question editors */
.item-editor { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 12px; background: var(--surface); }
.item-editor > summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none;
}
.item-editor > summary::-webkit-details-marker { display: none; }
.item-editor > summary::before { content: "\25B8"; color: var(--muted); transition: transform .15s; }
.item-editor[open] > summary::before { transform: rotate(90deg); }
.item-editor[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.item-num { font-weight: 700; white-space: nowrap; }
.item-type { font-size: .8rem; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.item-snippet { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.item-body { padding: 14px; }
.item-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.sub-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.sub-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--surface-2); }
.sub-row-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.sub-row-head .grow { flex: 1 1 200px; }
.pair-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.rubric-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: center; }
.add-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.add-bar .select { width: auto; min-width: 200px; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: .9rem; margin: 0 0 12px; }
.info { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font-size: .9rem; margin: 0 0 16px; }

/* diagram labeling */
.diagram-edit { position: relative; display: inline-block; max-width: 100%; cursor: crosshair; }
.diagram-edit img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; }
.diagram-spot {
  position: absolute; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem; pointer-events: none;
  background: var(--accent); color: var(--accent-ink); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* download step */
.status-box { padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.status-box.ok { background: var(--ok-bg); color: var(--ok); }
.status-box.bad { background: var(--bad-bg); color: var(--bad); }
.status-box h3 { margin: 0 0 6px; font-size: 1.05rem; }
.status-box ul { margin: 6px 0 0; padding-left: 20px; }
.status-box li { margin: 4px 0; }
.status-box li .btn { margin-left: 6px; }
.file-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.file-facts dt { font-weight: 600; }
.file-facts dd { margin: 0; overflow-wrap: anywhere; }
.lms-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.lms-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.lms-card h4 { margin: 0 0 6px; }
.lms-card ol { margin: 0; padding-left: 20px; }
.lms-card li { margin: 4px 0; }

/* preview */
.preview-pane {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); min-height: 520px;
}
.preview-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.preview-bar .title { font-weight: 700; }
.preview-status { font-size: .85rem; color: var(--muted); flex: 1; }
.preview-frame { flex: 1; width: 100%; border: 0; min-height: 480px; background: #fff; }
.preview-blocked { padding: 24px; color: var(--muted); }
.preview-blocked ul { padding-left: 20px; }
