:root {
  --canvas: #f7f7f4;
  --surface: #fff;
  --soft: #f2f1ef;
  --ink: #24222a;
  --muted: #57535f;
  --line: #dedbe1;
  --control-line: #a29aa8;
  --accent: #513d84;
  --accent-hover: #3c2b67;
  --accent-soft: #eeeaf7;
  --green: #236447;
  --green-soft: #e9f5ee;
  --red: #a12c25;
  --radius: 10px;
  --panel-space: 22px;
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.55;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
#app { display: flex; flex-direction: column; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); }
::selection { background: #e4dbf7; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.visually-hidden, .skip-link:not(:focus), .budget-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus {
  position: fixed;
  z-index: 20;
  top: 10px;
  left: 10px;
  padding: 10px 15px;
  border-radius: 6px;
  background: var(--surface);
}
.page-width { width: min(1180px, calc(100% - 64px)); margin-inline: auto; }
.site-header {
  position: sticky;
  z-index: 5;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  min-height: 67px;
  padding-block: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -.045em;
  text-decoration: none;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  letter-spacing: 0;
}
.header-actions { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.project-switch { width: clamp(140px, 22vw, 240px); max-width: 100%; }
.settings-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
  text-decoration: none;
}
.settings-link:hover, .settings-link[aria-current] { color: var(--accent); text-decoration: underline; }
.settings-nav { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-block: 12px 24px; font-size: .9rem; }
.settings-nav a { display: inline-flex; align-items: center; min-height: 44px; }
[data-account-settings] + .panel { margin-top: 16px; }
.account-panel, #settings-preferences, #project-storage { scroll-margin-top: 16px; }
.account-panel [hidden] { display: none !important; }
.account-group { border-top: 1px solid var(--line); }
.account-group summary { min-height: 44px; padding-block: 12px; cursor: pointer; font-weight: 700; }
.account-group-body { display: grid; gap: 12px; padding-block: 4px 14px; }
.account-group-body h3 { margin: 0; }
.account-form { display: grid; justify-items: start; gap: 10px; }
.account-form[hidden] { display: none; }
.account-form .field { width: min(100%, 28rem); }
.account-form + .account-form { padding-top: 12px; border-top: 1px solid var(--line); }
.account-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.account-row div { min-width: 0; overflow-wrap: anywhere; }
.account-row .tag { margin-inline-start: 6px; }
.account-identity { padding-bottom: 12px; }
.account-identity p, .account-row p, .account-message { margin: 0; }
.account-sessions { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.account-sessions li { padding-block: 10px; border-bottom: 1px solid var(--line); }
.account-message:empty { display: none; }
.account-error { color: var(--red); }

.workspace-nav { display: flex; gap: 3px 20px; }
.workspace-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 48px;
  padding: 5px 11px 3px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: .9rem;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.workspace-nav a:hover { color: var(--accent); }
.workspace-nav a[aria-current] { border-bottom-color: var(--accent); color: var(--accent); }
.workspace-nav a:focus-visible { outline-offset: -2px; }
.workspace-nav.stitch-nav { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.stage-link { gap: 5px; }
.step-number { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: .8em; }
.mobile-stages { display: none; }

.main { flex: 1; min-width: 0; padding-block: 24px 44px; }
.context-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; min-height: 44px; margin-bottom: 16px; }
.section-nav { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.section-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 13px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 700;
}
.section-link:hover { color: var(--accent); }
.section-link[aria-current] { background: var(--accent-soft); color: var(--accent-hover); }
.save-status { margin-inline-start: auto; color: var(--muted); font-size: .83rem; }
.page-heading { margin-block: 0 22px; }
.button.mobile-portfolio { display: none; }
#portfolio { scroll-margin-top: 12px; }
h1, h2, h3 { margin: 0; line-height: 1.22; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.8rem, 3.35vw, 2.8rem); font-weight: 800; letter-spacing: -.045em; }
h2 { font-size: 1.13rem; font-weight: 800; letter-spacing: -.018em; }
h3 { font-size: 1rem; font-weight: 800; }
p { margin: 0; }
.lead { max-width: 68ch; margin-top: 6px; color: var(--muted); }
.welcome {
  max-width: 560px;
  margin: clamp(28px, 9vh, 90px) auto 16px;
  padding: clamp(20px, 5vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.welcome .lead { margin-top: 10px; }
.create-form { display: grid; gap: 15px; max-width: 530px; }
.welcome .create-form { margin-top: 24px; }
.project-list { display: grid; gap: 8px; padding: 0; margin: 18px 0; list-style: none; }
.project-list li { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.project-list strong { min-width: 0; overflow-wrap: anywhere; }
.headed-actions, .studio-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.standalone-notice, .grant-filters { margin-bottom: 16px; }
.revision-panel, .snapshot-panel { margin-top: 18px; }
.profile-confirm { margin-top: 16px; }
.create-panel { margin-bottom: 24px; }

.workspace { display: grid; gap: 20px; align-items: start; }
.studio-workspace { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.proposal-workspace { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.panel, .program-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel + .panel { margin-top: 16px; }
.workspace > .panel { margin-top: 0; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-height: 61px;
  padding: 11px var(--panel-space);
  border-bottom: 1px solid var(--line);
}
.panel > :not(.panel-head) { margin-inline: var(--panel-space); }
.panel > :not(.panel-head) + :not(.panel-head) { margin-top: 16px; }
.panel > :not(.panel-head):first-child, .panel > .panel-head + * { margin-top: 18px; }
.panel > :not(.panel-head):last-child { margin-bottom: var(--panel-space); }
.content-section h2 { margin-bottom: 12px; }
.program-card { padding: var(--panel-space); }
.program-card > * + * { margin-top: 14px; }
.voice-section { padding-top: 17px; border-top: 1px solid var(--line); }
.voice-section audio { display: block; width: 100%; min-width: 0; }
.recording { padding: 9px 13px; border-inline-start: 3px solid var(--red); background: #fbefee; color: var(--red); font-size: .88rem; }

.button-row, .row, .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: grid; gap: 15px; }
.stack > *, .field > * { min-width: 0; }
.field { display: grid; min-width: 0; gap: 6px; }
.field-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.field-group legend { margin-bottom: 7px; }
.check-label { display: flex; min-height: 44px; align-items: center; gap: 10px; cursor: pointer; }
.check-label input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.label, .budget-label { color: var(--ink); font-size: .9rem; font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 + p { margin-top: 14px; }
input:not([type='checkbox'], [type='file']), textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}
textarea { min-height: 110px; display: block; resize: vertical; line-height: 1.55; }
input[type='date'] { max-width: 100%; }
input[readonly] { background: var(--soft); }
.subtle, .micro { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.notice { padding: 12px 14px; border-radius: 6px; color: var(--muted); background: var(--soft); }
.notice.info { background: var(--accent-soft); color: var(--accent-hover); }
.notice.bad { background: #faeeec; color: var(--red); }
.notice.good { background: var(--green-soft); color: var(--green); }
.tag, .check-status {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--soft);
  color: var(--muted);
  font-size: .83rem;
  font-weight: 700;
}
.tag.good, .check-status.good { background: var(--green-soft); color: var(--green); }
.tag.info { background: var(--accent-soft); color: var(--accent-hover); }
.fit-fit { background: var(--green-soft); color: var(--green); }
.fit-need { background: #e9f1ff; color: #244981; }
.fit-mismatch { background: #faeeec; color: var(--red); }
.fit-closed { background: var(--soft); color: var(--muted); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  padding: 7px 13px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--soft); color: var(--ink); }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.button.quiet { border-color: transparent; background: transparent; color: var(--accent); }
.button.quiet:hover { background: var(--accent-soft); }
.button.danger { color: var(--red); }
.button.danger:hover { background: #fbefee; }
.button[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.button:disabled { opacity: .55; cursor: default; }
.upload-button { position: relative; }
.upload-button:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.empty { padding: 18px; border-radius: 6px; color: var(--muted); background: var(--soft); font-size: .9rem; }

.file-list, .checklist { list-style: none; margin: 0; padding: 0; }
.file-list { display: grid; gap: 8px; }
.portfolio-file, .audio-file {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.portfolio-file { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; }
.portfolio-item { display: flex; align-items: center; gap: 10px; min-width: 0; overflow-wrap: anywhere; }
.audio-file { display: grid; gap: 6px; font-size: .9rem; overflow-wrap: anywhere; }
.attachment-preview {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 68px;
  height: 53px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--soft);
  object-fit: contain;
  font-size: .76rem;
  font-weight: 800;
}
.check { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 9px; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check > :first-child { min-width: 0; overflow-wrap: anywhere; }
.check-status { flex: 0 1 auto; }
.sources { display: grid; gap: 9px; }
.read-only { min-width: 0; margin-block: 8px; padding: 11px 13px; background: var(--soft); overflow-wrap: anywhere; white-space: pre-wrap; }
.read-only > * + * { margin-top: 4px; }
.agent-field { min-width: 0; padding: 11px 13px; background: var(--soft); border-radius: 6px; }
.agent-field > p { margin-top: 5px; overflow-wrap: anywhere; white-space: pre-wrap; }
[data-agent-progress]:empty { display: none; }
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.copy-row textarea { min-height: 44px; }

.budget { width: 100%; border-collapse: collapse; table-layout: fixed; }
.budget th, .budget td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.budget th { color: var(--muted); font-size: .8rem; font-weight: 750; overflow-wrap: anywhere; }
.budget thead th:nth-child(1) { width: 14%; }
.budget thead th:nth-child(2) { width: 25%; }
.budget thead th:nth-child(3) { width: 18%; }
.budget thead th:nth-child(4) { width: 27%; }
.budget thead th:nth-child(5) { width: 16%; }
.budget td:last-child { text-align: right; }
.budget input { padding-inline: 8px; }
.budget .button { padding-inline: 7px; }
.total { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 5px 14px; padding-block: 12px; border-top: 1px solid var(--line); }
.total b { font-variant-numeric: tabular-nums; }
.stage-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin-top: 24px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: .87rem; }
.stage-footer nav { margin-inline-start: auto; }
.site-footer { padding-block: 16px 75px; border-top: 1px solid var(--line); color: var(--muted); font-size: .83rem; }
.agent-dock { position: fixed; z-index: 7; right: 16px; bottom: 16px; }
.agent-dock summary { display: flex; align-items: center; min-height: 44px; padding: 8px 15px; border-radius: 6px; background: var(--accent); color: white; font-size: .9rem; font-weight: 750; cursor: pointer; }
.agent-dock-body { position: absolute; bottom: 52px; right: 0; width: min(340px, calc(100vw - 32px)); padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 5px 20px #24222a1a; }
.agent-dock-body > * + * { margin-top: 8px; }
.toast {
  position: fixed;
  z-index: 8;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100% - 32px));
  padding: 11px 15px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
}
.toast.visible { opacity: 1; }

@media (max-width: 1050px) {
  .proposal-workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace-nav.stitch-nav { display: none; }
  .mobile-stages { display: block; padding-bottom: 8px; }
  .mobile-stages summary { width: fit-content; padding: 7px 8px; cursor: pointer; color: var(--accent); }
  .mobile-stages nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; }
  .mobile-stages .stage-link { display: flex; align-items: center; min-height: 44px; padding: 4px 7px; overflow-wrap: anywhere; text-decoration: none; }
  .mobile-stages .stage-link[aria-current] { background: var(--accent-soft); border-radius: 6px; }
}
@media (max-width: 760px) {
  :root { --panel-space: 16px; }
  .page-width { width: calc(100% - 32px); }
  .site-header { position: static; }
  .header-inner { flex-wrap: wrap; }
  .workspace-nav { gap: 2px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .workspace-nav a { padding-inline: 3px; font-size: .83rem; }
  .studio-workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 580px) {
  .header-actions:has(.project-switch) { width: 100%; gap: 6px 8px; }
  .header-actions .project-switch { flex: 1 1 90px; }
  .header-actions .button { max-width: 34%; padding-inline: 6px; font-size: .8rem; }
  .header-actions .settings-link { font-size: .8rem; }
  .section-link { padding-inline: 8px; }
  .save-status { margin-inline-start: 0; }
  .main { padding-block: 16px 30px; }
  .context-bar { margin-bottom: 12px; }
  .page-heading { margin-bottom: 15px; }
  .studio-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
  .studio-heading h1 { min-width: 0; }
  .button.mobile-portfolio { display: inline-flex; flex-shrink: 0; }
  .grid2 { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .portfolio-item { font-size: .9rem; }
  .attachment-preview { width: 48px; height: 43px; }
  .stage-footer nav { width: 100%; justify-content: space-between; }
  .budget thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .budget, .budget tbody { display: block; }
  .budget tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
  .budget tr + tr { margin-top: 10px; }
  .budget th, .budget td { min-width: 0; padding: 0; border: 0; }
  .budget tbody th, .budget td:nth-child(2), .budget td:last-child { grid-column: 1 / -1; }
  .budget tbody th { font-size: .9rem; color: var(--ink); }
  .budget-label { position: static; width: auto; height: auto; clip-path: none; white-space: normal; overflow: visible; font-size: .8rem; }
  .budget-field { display: grid; gap: 4px; }
}
