:root {
  --navy: #0e3560;
  --navy-2: #174a7e;
  --blue: #1f66a8;
  --blue-2: #1a5189;
  --ink: #14263b;
  --muted: #4a5d73;
  --bg: #e4ecf5;
  --bg-2: #d3e0ee;
  --panel: #ffffff;
  --panel-2: #f3f8fd;
  --line: #c3d3e5;
  --card-blue: #d6e9f9;
  --card-lav: #e2defa;
  --card-cream: #fdf0c9;
  --tan: #fbebd2;
  --tan-line: #e6c58a;
  --over: #fde3df;
  --over-line: #b4382b;
  --ok: #17603a;
  --focus: #ffb000;
  --radius: 12px;
  --shadow: 0 6px 18px rgba(20, 50, 90, .13);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) fixed;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--navy); }
p { margin: 0 0 .75em; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 8px; }

.shell { width: 100%; max-width: 1840px; margin: 0 auto; padding: 14px clamp(12px, 2.2vw, 40px) 28px; }

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff; border-radius: var(--radius); padding: 10px 18px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand-icon { width: 30px; height: 30px; color: #fff; flex: none; }
.brand-title { color: #fff; font-size: 1.4rem; font-weight: 700; }
.brand-sub { border-left: 1px solid rgba(255,255,255,.45); padding-left: 12px; font-size: .95rem; color: #e1ecf8; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.badge { background: #fff; color: var(--navy); font-weight: 600; font-size: .85rem; padding: 4px 12px; border-radius: 999px; }

/* Stepper */
.stepper-wrap { margin: 12px 0 14px; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: step; }
.stepper li {
  counter-increment: step; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.7); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 4px 14px 4px 6px; font-size: .92rem;
}
.stepper li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line); font-weight: 700; font-size: .85rem;
}
.stepper li[aria-current="step"] { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.stepper li[aria-current="step"]::before { background: #fff; color: var(--navy); border-color: #fff; }
.stepper li.done { color: var(--ok); }
.stepper li.done::before { content: "\2713"; background: #e3f4ea; border-color: #8cc7a2; color: var(--ok); }

.app { outline: none; }

/* Panels & shared */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-body { padding: 16px 18px; }
.titlebar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(90deg, var(--blue-2), var(--blue)); color: #fff; padding: 9px 16px;
}
.titlebar h2, .titlebar h3 { color: #fff; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.titlebar .meta { font-size: .92rem; color: #e6f0fa; }
.titlebar .meta strong { color: #fff; font-size: 1.05rem; }
.icon { width: 20px; height: 20px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; padding: 9px 18px; font-weight: 600; min-height: 42px;
}
.btn-primary { background: linear-gradient(180deg, var(--navy-2), var(--navy)); color: #fff; box-shadow: 0 3px 8px rgba(14,53,96,.3); }
.btn-primary:hover:not(:disabled) { background: var(--navy); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--blue); }
.btn-secondary:hover:not(:disabled) { background: var(--panel-2); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.55); min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn-ghost:hover { background: rgba(255,255,255,.15); }
.btn-small { min-height: 36px; padding: 5px 12px; font-size: .92rem; }
.btn-large { min-height: 56px; font-size: 1.2rem; padding: 12px 24px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label, .field .label { font-weight: 600; color: var(--navy); }
.hint { font-size: .9rem; color: var(--muted); }
input[type="text"], select, textarea {
  width: 100%; border: 1px solid #9db5cf; border-radius: 8px; padding: 8px 10px; background: #fff; min-height: 40px;
}
textarea { resize: vertical; min-height: 84px; }
select:disabled, input:disabled { background: #eef2f7; color: #6c7c8f; cursor: not-allowed; }
.error { color: var(--over-line); font-weight: 600; margin-top: 6px; }

/* Plain screens */
.narrow { max-width: 980px; margin: 0 auto; }
.screen-title { font-size: 1.8rem; margin-bottom: 10px; outline: none; }
.lead { font-size: 1.1rem; }
.task-line { background: var(--panel-2); border-left: 5px solid var(--blue); padding: 10px 14px; border-radius: 8px; font-weight: 600; margin: 10px 0 14px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }

.briefing { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 22px; align-items: start; }
.maya-fig { margin: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--bg-2); border: 1px solid var(--line); }
.maya-fig img { display: block; width: 100%; height: auto; }
.maya-fig figcaption { padding: 8px 12px; font-size: .9rem; color: var(--muted); background: #fff; }
.speech { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 0 0 12px; position: relative; }
.speech .who { font-weight: 700; color: var(--navy); display: block; margin-bottom: 4px; }
.brief dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0; }
.brief dt { font-weight: 700; color: var(--navy); }
.brief dd { margin: 0; }
.note { background: #eef5fc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: .95rem; color: var(--muted); }

/* Action card look (shared) */
.acard { border: 1px solid #98b6d6; border-radius: 12px; padding: 10px 12px; background: var(--card-blue); color: var(--ink); text-align: left; }
.acard.c1 { background: var(--card-lav); border-color: #b2a8e3; }
.acard.c2 { background: var(--card-cream); border-color: #e3c466; }
.acard .verb-obj { font-weight: 700; display: block; overflow-wrap: anywhere; }
.acard .out { display: block; font-size: .92rem; overflow-wrap: anywhere; margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid #7ea3c9; border-radius: 999px; padding: 1px 10px; font-size: .88rem; font-weight: 700; color: var(--navy); margin-top: 6px; }
.state-tag { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; padding: 1px 8px; border-radius: 6px; background: #fff; border: 1px solid #7ea3c9; color: var(--navy); margin-right: 6px; margin-top: 6px; }
.state-tag.warn { border-color: var(--over-line); color: var(--over-line); }
.example-card { max-width: 420px; }
.example-card dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; }
.example-card dt { font-weight: 700; }
.example-card dd { margin: 0; }
.notes-list { padding-left: 20px; }
.parts { padding-left: 20px; }

/* Mission banner */
.banner { display: grid; grid-template-columns: auto 1fr minmax(260px, 36%); gap: 18px; align-items: center; padding: 14px 18px; }
.avatar { width: 76px; height: 76px; border-radius: 18px; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(20,50,90,.25); object-fit: cover; background: var(--bg-2); }
.banner h2 { font-size: 1.7rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #dcebfa; border-radius: 999px; padding: 4px 14px; margin-top: 6px; font-size: .95rem; }
.goalbox { border-left: 1px solid var(--line); padding-left: 18px; display: grid; gap: 8px; }
.goalbox .row { display: flex; gap: 10px; align-items: flex-start; }
.goalbox .row .icon { color: var(--blue); margin-top: 3px; width: 22px; height: 22px; }
.goalbox b { display: block; color: var(--navy); }

.briefstrip { margin-top: 12px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 0; }
.briefstrip > div { padding: 12px 18px; }
.briefstrip > div + div { border-left: 1px solid var(--line); }
.briefstrip h3 { font-size: 1rem; margin-bottom: 4px; }
.briefstrip ul { margin: 4px 0; padding-left: 20px; }
.linklist { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
a.link { color: var(--blue-2); font-weight: 600; }
details.ynotes { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 6px 10px; width: 100%; }
details.ynotes summary { cursor: pointer; font-weight: 600; color: var(--navy); }
details.ynotes ol { padding-left: 20px; margin: 6px 0; }

/* Workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 68fr) minmax(0, 32fr); gap: 18px; margin-top: 14px; align-items: start; }
.stack { display: grid; gap: 14px; min-width: 0; }

.timeline { padding: 14px 16px 6px; }
.track { display: flex; gap: 0; align-items: stretch; min-height: 128px; width: 100%; }
.track .acard { min-width: 0; display: flex; flex-direction: column; cursor: pointer; width: 100%; }
.slot { min-width: 0; display: flex; padding: 0 3px; }
.slot > .acard { flex: 1; }
.slot.unused {
  border: 2px dashed #a9bbd0; border-radius: 12px; background: #eef2f7; color: var(--muted);
  flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 6px; font-size: .92rem;
}
.slot.unused strong { color: var(--navy); }
.ticks { position: relative; height: 34px; margin: 6px 0 0; border-top: 2px solid #5f7fa3; }
.ticks span { white-space: nowrap; position: absolute; top: 0; transform: translateX(-50%); font-size: .82rem; color: var(--muted); padding-top: 4px; }
.ticks span::before { content: ""; position: absolute; left: 50%; top: -9px; width: 2px; height: 8px; background: #5f7fa3; }
.ticks span:first-child { transform: none; }
.ticks span:last-child { transform: translateX(-100%); }
.ticks span:first-child::before { left: 0; }
.ticks span:last-child::before { left: 100%; }
.overflow {
  margin: 4px 0 10px; border: 2px solid var(--over-line); border-radius: 12px; padding: 8px 10px;
  background: repeating-linear-gradient(-45deg, var(--over), var(--over) 10px, #fff4f2 10px, #fff4f2 20px);
}
.overflow h4 { color: var(--over-line); font-size: .95rem; margin-bottom: 6px; }
.overflow .row { display: flex; gap: 8px; flex-wrap: wrap; }
.overflow .acard { min-width: 150px; max-width: 260px; cursor: pointer; }
.nodur { margin: 4px 0 10px; border: 2px dashed #8aa6c4; border-radius: 12px; padding: 8px 10px; background: #f7fafd; }
.nodur h4 { font-size: .95rem; margin-bottom: 6px; }
.nodur .row { display: flex; gap: 8px; flex-wrap: wrap; }
.nodur .acard { min-width: 150px; max-width: 260px; cursor: pointer; }
.empty { color: var(--muted); padding: 18px 8px; text-align: center; width: 100%; border: 2px dashed #a9bbd0; border-radius: 12px; background: #f3f7fb; }

.acard.selected { outline: 4px solid var(--navy); outline-offset: 1px; box-shadow: 0 0 0 2px #fff inset; }
.acard .sel-mark { display: none; font-weight: 700; font-size: .8rem; color: var(--navy); }
.acard.selected .sel-mark { display: inline; }
.acard.incomplete { border-style: dashed; }
button.acard { font: inherit; width: auto; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px 14px; border-top: 1px solid var(--line); background: var(--panel-2); }
.controls .sel-label { flex: 1 1 220px; font-size: .95rem; }
.controls .sel-label b { color: var(--navy); }

.backlog-list { display: grid; gap: 10px; padding: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.parent { background: var(--tan); border: 1px solid var(--tan-line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; grid-column: 1 / -1; }
.parent .icon { width: 36px; height: 36px; color: #8a6a2a; }
.parent .ptag { display: inline-block; background: #f4d7a0; border-radius: 6px; padding: 0 8px; font-size: .82rem; font-weight: 700; color: #6a4d14; }
.parent h4 { margin: 4px 0 2px; }
.backlog-list .acard { cursor: pointer; opacity: .96; background: #e9eef4; border-color: #aebccc; }
.hint-line { padding: 0 16px 12px; font-size: .92rem; color: var(--muted); }

/* Editor & check */
.editor { padding: 14px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip-btn { background: #fff; border: 1px solid #8aa6c4; border-radius: 999px; padding: 2px 12px; cursor: pointer; font-size: .9rem; min-height: 30px; }
.chip-btn:hover { background: var(--panel-2); }
.editor-actions { display: flex; gap: 10px; margin-top: 6px; }
.editor-actions .btn { flex: 1; }
.check { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel-2); }
.check h3 { font-size: 1rem; margin-bottom: 4px; }
.check ul { margin: 4px 0; padding-left: 18px; }
.check li { margin: 2px 0; }
.status-line { font-weight: 700; }
.status-line.over { color: var(--over-line); }
.status-line.good { color: var(--ok); }
.commit-wrap { padding: 12px 16px 16px; }
.commit-wrap .btn { width: 100%; }
.commit-note { font-size: .92rem; color: var(--muted); margin-top: 6px; }

/* Review */
.review-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; margin-top: 14px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 14px 16px 6px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 1.4rem; color: var(--navy); line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--muted); }
.plan-list { list-style: none; margin: 0; padding: 8px 16px 14px; display: grid; gap: 8px; counter-reset: p; }
.plan-list li { counter-increment: p; display: grid; grid-template-columns: 34px 1fr; gap: 8px; }
.plan-list li::before { content: counter(p); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; margin-top: 8px; }
.plan-list .acard small { display: block; margin-top: 4px; color: #5b3d00; }
.plan-list .tag-select { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-list .tag-select select { width: auto; min-height: 34px; padding: 3px 8px; }
.section-sub { padding: 8px 16px 0; font-weight: 700; color: var(--navy); }
.msg-list { list-style: none; padding: 12px 16px; margin: 0; display: grid; gap: 8px; }
.msg-list li { background: #eef5fc; border-left: 5px solid var(--blue); border-radius: 6px; padding: 8px 12px; }
.msg-list li.watch { background: #fff8e5; border-left-color: #d79a00; }
.msg-list li.narr { background: #eaf6ef; border-left-color: var(--ok); font-weight: 600; }
.cov { width: 100%; border-collapse: collapse; font-size: .95rem; }
.cov th, .cov td { text-align: left; padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.cov th { color: var(--navy); width: 42%; font-weight: 600; }
.prompts { padding: 4px 16px 14px 36px; }
div.prompts { padding-left: 16px; }
.prompts li { margin: 4px 0; }
.debrief-grid { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 20px; align-items: start; }
.takeaways { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; padding: 0; list-style: none; }
.takeaways li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.takeaways b { display: block; color: var(--navy); }
.downloads { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.confirm-box { background: #fff8e5; border: 1px solid #e0b64a; border-radius: 10px; padding: 10px 14px; margin-top: 10px; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 460px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 30, 55, .5); }
.dialog-body { padding: 18px 20px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.footer { margin-top: 22px; font-size: .86rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.footer a { color: var(--blue-2); }
.footer p { margin: 0 0 4px; }

/* Responsive */
@media (max-width: 1000px) {
  .workspace, .review-grid { grid-template-columns: 1fr; }
  .banner { grid-template-columns: auto 1fr; }
  .goalbox { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 10px; }
  .briefstrip { grid-template-columns: 1fr; }
  .briefstrip > div + div { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .briefing, .debrief-grid { grid-template-columns: 1fr; }
  .maya-fig { max-width: 300px; }
  .takeaways { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .track { flex-direction: column; min-height: 0; }
  .track .slot { width: 100% !important; flex: none !important; }
  .ticks { display: none; }
  .brand-sub { border-left: 0; padding-left: 0; }
  .brief dl { grid-template-columns: 1fr; }
  .screen-title { font-size: 1.5rem; }
  .banner h2 { font-size: 1.35rem; }
  .avatar { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Compact editor: label beside input, as in the UI reference */
.mission-title { font-size: 1.7rem; margin: 0; }
.editor { padding: 12px 16px; }
.editor .field { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 2px 10px; align-items: start; margin-bottom: 8px; }
.editor .field > label { padding-top: 8px; line-height: 1.25; font-size: .95rem; }
.editor .field > :not(label) { grid-column: 2; }
.editor .field > label + * { grid-row: 1; }
.editor textarea { min-height: 56px; }
.editor .ed-intro { margin-bottom: 8px; }
@media (max-width: 560px) {
  .editor .field { grid-template-columns: 1fr; }
  .editor .field > :not(label) { grid-column: 1; }
  .editor .field > label + * { grid-row: auto; }
}

/* Final responsive pass */
html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
.app, .workspace, .stack, .panel, .review-grid { min-width: 0; }
.speech, .acard, .msg-list li, .brief dd, .hint, .note { overflow-wrap: anywhere; }
@media (min-width: 1400px) {
  :root { font-size: 17px; }
}
@media (min-width: 1001px) and (max-width: 1240px) {
  /* narrow right column: stack labels above inputs so nothing is squeezed */
  .editor .field { grid-template-columns: 1fr; }
  .editor .field > :not(label) { grid-column: 1; }
  .editor .field > label + * { grid-row: auto; }
  .editor .field > label { padding-top: 0; }
}
@media (pointer: coarse), (max-width: 1024px) {
  .plan-list .tag-select select { min-height: 44px; }
  .btn, .btn-small, .btn-ghost, .chip-btn, select, input[type="text"] { min-height: 44px; }
  .btn-ghost { padding: 6px 14px; }
  .chip-btn { padding: 4px 14px; }
  .stepper li { padding-top: 6px; padding-bottom: 6px; }
}
@media (max-width: 720px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .topbar { padding: 10px 12px; }
  .brand-title { font-size: 1.2rem; }
  .stepper { gap: 6px; }
  .stepper li { font-size: .85rem; padding-right: 10px; }
  .banner { padding: 12px; gap: 12px; }
  .controls { padding: 10px 12px 14px; }
  .controls .btn { flex: 1 1 calc(50% - 8px); }
  .timeline { padding: 12px 12px 6px; }
  .backlog-list { padding: 12px; grid-template-columns: 1fr; }
  .editor-actions .btn { min-height: 48px; }
  .commit-wrap .btn { min-height: 56px; }
  .briefstrip > div { padding: 12px; }
  .dialog-actions .btn { flex: 1 1 100%; }
  .downloads .btn, .actions .btn { flex: 1 1 100%; }
  .cov th { width: 38%; }
  .plan-list li { grid-template-columns: 26px 1fr; gap: 6px; }
  .plan-list li::before { width: 26px; height: 26px; font-size: .85rem; }
}

a.link { display: inline-block; padding: 6px 0; }

/* Labels never break mid-word; timeline cards stay compact at narrow track widths */
.state-tag, .pill, .sel-mark { overflow-wrap: normal; white-space: nowrap; }
.track .acard { padding: 8px 9px; }
.track .state-tag { font-size: .68rem; letter-spacing: 0; padding: 0 5px; margin-right: 4px; }
.track .pill { padding: 1px 8px; }
