/* ── LESSON PLAN LAYOUTS (src/planning/plan-layouts.js) ── */
.plan-shell { max-width: 1320px; margin: 0 auto; }
.plan-shell > .card:first-child { position: sticky; top: 64px; z-index: 30; }
.plan-shell > .card:first-child h1 { font-family: var(--font-display); font-size: 18px !important; }
.plan-body { display: grid; gap: 20px; align-items: start; }
.plan-body.view-swap { animation: rise var(--dur-3) var(--ease-out); }
.plan-main { min-width: 0; }
.plan-sec-title { font-family: var(--font-display); font-size: 17px !important; letter-spacing: -.01em; margin-bottom: 12px !important; }
.plan-rail, .plan-aside, .plan-stepnav { display: none; }

/* Step by step */
.plan-shell[data-view="steps"] .plan-body { grid-template-columns: 250px minmax(0, 1fr); }
.plan-shell[data-view="steps"] .plan-rail { display: block; }
.plan-shell[data-view="steps"] .plan-stepnav { display: flex; }
.plan-shell[data-view="steps"] .plan-footer { display: none !important; }
.plan-shell[data-view="steps"] .plan-sec { min-height: 360px; padding: 20px !important; }
.plan-rail { position: sticky; top: 140px; padding: 14px; }
.plan-rail-top { display: flex; justify-content: space-between; font-size: 12px; }
.plan-prog { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin: 8px 0 12px; }
.plan-prog span { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width var(--dur-4) var(--ease-out); }
.plan-step { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 8px; border: none; background: none; border-radius: 9px; font-size: 13px; color: var(--ink-2); text-align: left; cursor: pointer; transition: background-color var(--dur-1); }
.plan-step:hover { background: var(--surface-2); }
.plan-step.cur { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.plan-step-n { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.plan-step-n .ico { width: 13px; height: 13px; }
.plan-step.done .plan-step-n { background: var(--sage); border-color: var(--sage-line); color: var(--sage-ink); }
.plan-step.part .plan-step-n { border-color: var(--butter-line); background: var(--butter); color: var(--butter-ink); }
.plan-step.cur .plan-step-n { border-color: var(--accent); }
.plan-step-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-step-fill { font-size: 11px; color: var(--muted); }
.plan-stepnav { position: sticky; bottom: 0; align-items: center; gap: 10px; padding: 12px 16px; margin-top: 4px; border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); backdrop-filter: blur(6px); z-index: 5; }
.plan-step-of { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }

/* Printed page: the whole plan as one document, edited in place */
.plan-shell[data-view="doc"] .plan-body { grid-template-columns: 220px minmax(0, 1fr); }
.plan-shell[data-view="doc"] .plan-rail { display: block; position: sticky; top: 140px; }
.plan-shell[data-view="doc"] .plan-rail .plan-step-n { display: none; }
.plan-shell[data-view="doc"] .plan-main { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-soft); padding: 40px 44px; }
.plan-shell[data-view="doc"] .plan-main > p { display: none; }
.plan-shell[data-view="doc"] .plan-sec { border: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 0 22px !important; background: none; border-radius: 0; }
.plan-shell[data-view="doc"] .plan-sec .card { border: none !important; box-shadow: none !important; padding: 0 !important; background: none; }
.plan-shell[data-view="doc"] .plan-sec-title { text-align: center; text-transform: uppercase; letter-spacing: .04em; font-size: 14px !important; padding: 8px; background: var(--surface-2); border: 1px solid var(--line-strong); margin: 0 !important; }
.plan-shell[data-view="doc"] .form-row, .plan-shell[data-view="doc"] .form-row-3 { display: block; }
.plan-shell[data-view="doc"] .form-group { display: grid; grid-template-columns: 30% minmax(0, 1fr); margin: 0; border: 1px solid var(--line-strong); border-top: none; }
.plan-shell[data-view="doc"] .form-group > .form-label { margin: 0; padding: 8px 10px; background: var(--surface-2); border-right: 1px solid var(--line-strong); font-size: 11.5px; font-weight: 600; color: var(--ink); }
.plan-shell[data-view="doc"] .form-group > .form-control, .plan-shell[data-view="doc"] .form-group > textarea, .plan-shell[data-view="doc"] .form-group > input, .plan-shell[data-view="doc"] .form-group > select {
  border: none; border-radius: 0; min-height: 34px; padding: 8px 10px; font-family: 'Cambria', 'Georgia', serif; font-size: 13.5px; line-height: 1.5; resize: none; overflow: hidden; background: transparent; }
.plan-shell[data-view="doc"] .form-group > .form-control:hover { background: var(--surface-2); }
.plan-shell[data-view="doc"] .form-group > .form-control:focus { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.plan-shell[data-view="doc"] #ilaw-day-tabs { display: none !important; }
.plan-shell[data-view="doc"] .ilaw-day-panel { display: block !important; margin-top: 14px; }
.plan-shell[data-view="doc"] .ilaw-day-panel::before { content: attr(data-label); display: block; padding: 6px 10px; font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--on-accent); background: var(--accent); }
.plan-shell[data-view="doc"] .ilaw-day-panel .card > div[style*="font-weight:700"] { padding: 6px 10px; background: var(--surface-3); border: 1px solid var(--line-strong); border-top: none; font-size: 12px !important; margin: 0 !important; }
.plan-shell[data-view="doc"] .plan-footer { margin-top: 24px; }

/* Live preview */
.plan-shell[data-view="split"] .plan-body { grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); }
.plan-shell[data-view="split"] .plan-aside { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 140px; max-height: calc(100vh - 160px); }
.plan-preview { overflow: hidden; display: flex; flex-direction: column; min-height: 0; flex: 1.4; }
.plan-checks { overflow: hidden; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.plan-preview-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; flex-wrap: wrap; }
#plan-preview, #plan-checks { overflow: auto; min-height: 0; }
.plan-paper { margin: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-soft); border-radius: 4px; font-family: 'Cambria', 'Georgia', serif; font-size: 12px; }
.plan-paper-title { text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.plan-paper table { width: 100%; border-collapse: collapse; }
.plan-paper th, .plan-paper td { border: 1px solid var(--line-strong); padding: 5px 7px; vertical-align: top; text-align: left; }
.plan-paper th { width: 34%; background: var(--surface-2); font-family: var(--font-ui); font-size: 10.5px; font-weight: 600; }
.plan-issue { width: 100%; display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border: none; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 12.5px; color: var(--ink-2); cursor: pointer; transition: background-color var(--dur-1); }
.plan-issue:hover { background: var(--surface-2); }
.plan-issue .chip { flex-shrink: 0; }

@media (max-width: 1000px) {
  .plan-shell[data-view] .plan-body { grid-template-columns: minmax(0, 1fr); }
  .plan-rail, .plan-aside { position: static !important; max-height: none !important; }
  .plan-shell[data-view="doc"] .plan-main { padding: 18px 14px; }
  .plan-shell[data-view="doc"] .form-group { grid-template-columns: minmax(0, 1fr); }
  .plan-shell[data-view="doc"] .form-group > .form-label { border-right: none; border-bottom: 1px solid var(--line-strong); }
  .plan-shell > .card:first-child { position: static; }
}

/* ── The plans list: one row per plan, Edit up front, the rest in the row's menu (lesson-plans.js) ── */
.plan-rows { overflow: hidden; }
.plan-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) 90px 110px auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; transition: background-color var(--dur-1); }
.plan-row:hover { background: var(--surface-2); }
.plan-row-head { border-top: 0; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: default; }
.plan-title { min-width: 0; }
.plan-title b { display: block; font-weight: 600; font-size: 14px; }
.plan-title .muted { display: block; font-size: 12px; }
.plan-comp { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-for .muted { display: block; font-size: 12px; }
.plan-actions { display: flex; gap: 4px; justify-content: flex-end; }
@media (max-width: 760px) {
  .plan-row { grid-template-columns: minmax(0, 1fr) auto; }
  .plan-row-head, .plan-term, .plan-saved { display: none; }
  .plan-for { grid-column: 1; grid-row: 2; }
  .plan-actions { grid-column: 2; grid-row: 1 / span 2; }
}

/* The plan's header stays in view with where the plan stands and its Save button. */
.plan-head { position: sticky; top: 64px; z-index: 50; }
.save-state { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.save-state .ico { width: 16px; height: 16px; }
.save-state.saved { color: var(--sage-ink); }
.save-state.unsaved { color: var(--butter-ink); font-weight: 600; }
@media (max-width: 700px) { .plan-head { top: 56px; } }
.plan-head .save-group { order: 10; margin-left: auto; display: inline-flex; align-items: center; gap: 12px; }

/* ── The outline: each part's state, sessions opened into each sesyon (plan-layouts.js _planRail) ── */
.plan-step { align-items: flex-start; }
.plan-step-name { white-space: normal; }
.plan-step-name small { display: block; font-size: 12px; font-weight: 400; color: var(--ink-2); }
.plan-step.fix .plan-step-n { background: var(--rose); border-color: var(--rose-line); color: var(--rose-ink); font-weight: 700; }
.plan-step.fix small { color: var(--rose-ink); }
.plan-step.ai .plan-step-n { background: var(--lilac); border-color: var(--lilac-line); color: var(--lilac-ink); }
.plan-step.ai small { color: var(--lilac-ink); }
.plan-substeps { display: grid; gap: 2px; margin: 0 0 4px 24px; }
.plan-substep { padding: 8px; }
.plan-substep .plan-step-n { width: 18px; height: 18px; font-size: 10px; }
.plan-substep.on { background: var(--surface-2); }
.plan-rail-more { font-size: 12px; color: var(--rose-ink); margin: -4px 0 8px; }
.plan-shell[data-view="doc"] .plan-rail .plan-substeps { margin-left: 8px; }
.plan-parts-btn { display: none; }
.plan-rail-sheet { display: block !important; position: static !important; padding: 0; border: 0; box-shadow: none; }
@media (max-width: 700px) {
  .plan-shell .plan-rail { display: none !important; }
  .plan-rail-sheet { display: block !important; }
  .plan-parts-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 16px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
  .plan-parts-btn > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .plan-parts-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .plan-shell[data-view="steps"] .plan-stepnav { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
}

/* AI text not reviewed yet: a lilac edge and a tag with Keep, until the teacher edits or keeps it (ai-service.js). */
[data-ai] { border-color: var(--lilac-line) !important; border-left: 4px solid var(--lilac-ink) !important; background: color-mix(in srgb, var(--lilac) 45%, var(--surface)) !important; }
.ai-tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; margin-left: 8px; padding: 0 4px 0 8px; border-radius: var(--r-pill); background: var(--lilac); color: var(--lilac-ink); font-size: 11px; font-weight: 600; vertical-align: middle; }
.ai-tag .ico { width: 12px; height: 12px; }
.ai-tag.mine { padding: 0 8px; background: var(--surface-2); color: var(--ink-2); }
.ai-keep { height: 18px; padding: 0 8px; border: 0; border-radius: var(--r-pill); background: var(--surface); color: var(--lilac-ink); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; }
.ai-keep:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ai-review { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 12px; border-radius: var(--r-lg); background: var(--lilac); color: var(--lilac-ink); }
.ai-review > .ico { width: 20px; height: 20px; flex-shrink: 0; }
.ai-review p { margin: 0; flex: 1 1 320px; font-size: 13px; color: var(--ink); }
.ai-review b { color: var(--lilac-ink); }

/* A draft as it comes (ai-service.js _aiRunStart): a field the AI is about to
   write shows lines of words in its own box (nothing moves when they come), a
   soft light passing over them; its words fade in when its part arrives. A
   part that didn't come through: a dashed edge, to type in or try again.
   Reduced motion: motion.css stills the light. */
.form-control.ai-pending { --ai-lines: 12px 11px; color: transparent !important; caret-color: transparent; pointer-events: none; user-select: none;
  background-color: var(--surface) !important; background-repeat: no-repeat !important;
  background-image: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface) 75%, transparent) 50%, transparent 70%),
    repeating-linear-gradient(to bottom, var(--surface-3) 0 9px, transparent 9px 21px) !important;
  background-size: 220% 100%, calc(100% - 24px) calc(100% - 20px) !important; background-position: 120% 0, var(--ai-lines);
  animation: ai-shimmer 1.6s var(--ease-in-out) infinite; }
input.form-control.ai-pending { --ai-lines: 12px 50%; background-size: 220% 100%, min(60%, 260px) 9px !important; }
.form-control.ai-pending::placeholder { color: transparent; }
@keyframes ai-shimmer { from { background-position: 120% 0, var(--ai-lines); } to { background-position: -100% 0, var(--ai-lines); } }
.form-control.ai-arrived { animation: ai-arrive var(--dur-4) var(--ease-out); }
@keyframes ai-arrive { from { color: transparent; background-color: var(--surface-2); } }
.form-control.ai-failed { border-style: dashed !important; border-color: var(--rose-line) !important; }
.ai-progress { position: sticky; top: 8px; z-index: 6; display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 12px; border-radius: var(--r-lg); background: var(--lilac); color: var(--lilac-ink); box-shadow: var(--shadow-soft); }
.ai-progress > .ico { width: 20px; height: 20px; flex-shrink: 0; }
.ai-progress p { margin: 0; flex: 1 1 300px; font-size: 13px; color: var(--ink); }
.ai-progress b { color: var(--lilac-ink); }
.ai-parts { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.ai-part { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 500; }
.ai-part .ico { width: 13px; height: 13px; }
.ai-part[data-state="writing"] { color: var(--lilac-ink); }
.ai-part[data-state="done"] { background: var(--sage); color: var(--sage-ink); }
.ai-part[data-state="failed"] { background: var(--rose); color: var(--rose-ink); }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: ai-dot 1.2s var(--ease-in-out) infinite; }
@keyframes ai-dot { 50% { opacity: .3; } }
/* The session tabs say the same: being written, done, or not come through. */
.ai-tab-writing::after, .ai-tab-done::after, .ai-tab-failed::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; vertical-align: middle; }
.ai-tab-writing::after { background: var(--lilac-ink); animation: ai-dot 1.2s var(--ease-in-out) infinite; }
.ai-tab-done::after { background: var(--green); }
.ai-tab-failed::after { background: var(--red); }
.plan-saved small { display: block; margin-top: 4px; font-size: 12px; }
.plan-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) 90px minmax(0, 1.3fr) auto; }
.plan-status { white-space: nowrap; }
@media (max-width: 760px) { .plan-row { grid-template-columns: minmax(0, 1fr) auto; } .plan-saved { display: block; grid-column: 1; } }

/* Unsaved changes kept on this device, offered back when the plan opens (lesson-plan-core.js). */
.plan-draft-banner { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 16px; margin-bottom: 12px; border-radius: var(--r-lg); background: var(--butter); border: 1px solid var(--butter-line); }
.plan-draft-banner > .ico { width: 20px; height: 20px; color: var(--butter-ink); flex-shrink: 0; margin-top: 2px; }
.plan-draft-banner > div:first-of-type { flex: 1 1 320px; font-size: 13px; color: var(--ink); }
.plan-draft-banner b { display: block; font-size: 14px; margin-bottom: 2px; }
.plan-draft-acts { display: flex; gap: 8px; }

/* CMS Interactive in the plan list: each plan's slides and games, one bar segment a session. */
.plan-rows.ix-on .plan-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr) 80px minmax(0, 1.2fr) minmax(0, 1.3fr) auto; }
.ix-sum { display: grid; gap: 6px; font-size: 13px; }
.ix-bar { display: flex; gap: 3px; max-width: 140px; }
.ix-bar i { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); }
.ix-bar i.on { background: var(--sage-ink); }
@media (max-width: 760px) {
  .plan-rows.ix-on .plan-row { grid-template-columns: minmax(0, 1fr) auto; }
  .plan-ix { grid-column: 1; }
  .plan-rows.ix-on .plan-actions { grid-row: 1 / span 4; flex-direction: column; align-items: stretch; }
}

/* "Present and play" on the plan page: one row a session. */
.ix-pp-note { margin: 0 0 12px; font-size: 13px; }
.ix-sess { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--line); }
.ix-sess-text { flex: 1 1 220px; min-width: 0; display: grid; gap: 2px; }
.ix-sess-text b { font-weight: 600; }
.ix-sess-text span { overflow-wrap: break-word; }
.ix-sess-text small { font-size: 12px; }
.ix-sess-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.ix-sess-acts .btn { min-height: 44px; }

/* Import a lesson plan (src/planning/plan-import.js) */
.imp-how { margin: 0 0 14px; padding-left: 18px; font-size: 12px; color: var(--text-muted); }
.imp-how li { margin: 4px 0; }
.imp-how b { color: var(--text); font-weight: 600; }
.imp-status { min-height: 18px; margin: 0; font-size: 12px; color: var(--text-muted); }
