:root {
  --ink: #302b3a;
  --muted: #716b7b;
  --line: #dedddb;
  --teal: #487a7b;
  --teal-dark: #315f61;
  --pink: #bd1a5d;
  --paper: #ffffff;
  --wash: #fbfaf8;
  font-family: Aptos, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 3px;
}

.topbar {
  display: flex;
  height: 62px;
  align-items: center;
  gap: 18px;
  padding: 0 32px;
  background: var(--ink);
  color: var(--paper);
}

.brand {
  color: var(--paper);
  font-size: 21px;
  font-weight: 700;
  text-decoration: none;
}

.divider {
  height: 25px;
  border-left: 1px solid #aaa6b3;
}

.product {
  font-size: 17px;
  letter-spacing: 0.2px;
}

.top-note {
  margin-left: auto;
  color: #d9d6df;
  font-size: 12px;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 94px);
  max-width: 1440px;
  margin: 0 auto;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, 0.9fr);
  background: var(--paper);
}

.workpane {
  padding: 34px 42px 28px;
  border-right: 1px solid var(--line);
}

.eyebrow {
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0;
  font-size: 27px;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.25;
}

.lede {
  max-width: 680px;
  margin: 12px 0 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.steps {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 28px;
}

.steps i {
  height: 1px;
  flex: 1;
  background: var(--line);
}

.step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  color: #77747d;
  white-space: nowrap;
}

.step span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid #aaa7af;
  border-radius: 50%;
  font-weight: 700;
}

.step.active {
  color: var(--teal-dark);
  font-weight: 700;
}

.step.active span {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--paper);
}

.panel {
  max-width: 880px;
  padding-top: 0;
}

#draft-status:empty { display: none; }

.panel label strong {
  display: block;
  font-size: 19px;
}

.panel label small {
  display: block;
  margin: 5px 0 13px;
  color: var(--muted);
}

.panel textarea {
  width: 100%;
  min-height: 176px;
  padding: 13px 15px;
  resize: vertical;
  border: 1px solid #88858f;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

.counter {
  position: relative;
  margin-top: -24px;
  margin-right: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.tip,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.example-picker {
  margin-top: 14px;
}

.example-picker > strong {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
}

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

.example-button {
  padding: 8px 9px;
  border: 1px solid #aaa7af;
  border-radius: 4px;
  background: var(--paper);
  text-align: left;
}

.example-button b,
.example-button span {
  display: block;
}

.example-button b {
  color: var(--teal-dark);
  font-size: 11px;
}

.example-button span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.example-button.selected {
  border-color: var(--teal);
  background: #f3f8f7;
  box-shadow: inset 0 0 0 1px var(--teal);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
}

.primary,
.quiet {
  padding: 11px 17px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
}

.primary {
  border: 1px solid var(--teal-dark);
  background: var(--teal-dark);
  color: var(--paper);
}

.primary:hover:not(:disabled) {
  background: #254c4d;
}

.quiet {
  border: 1px solid #88858f;
  background: var(--paper);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.choice-wide {
  grid-column: 1 / -1;
}

.choice {
  padding: 15px;
  border: 1px solid #a7a4ad;
  border-radius: 4px;
  background: var(--paper);
  text-align: left;
}

.choice b,
.choice span {
  display: block;
}

.choice span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.choice.selected {
  padding: 14px;
  border: 2px solid var(--teal);
  background: #f3f8f7;
}

.choice-item {
  display: flex;
  flex-direction: column;
}

.choice-item .choice {
  width: 100%;
}

.choice-learn {
  align-self: flex-start;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: underline;
}

.choice-learn:hover {
  color: var(--teal-dark);
}

.callout {
  margin-top: 22px;
  padding: 12px 14px;
  border-left: 3px solid var(--teal);
  background: #f1f7f6;
  color: #45424d;
  font-size: 13px;
}

.field-grid {
  display: grid;
  margin-top: 20px;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.field-grid label {
  font-size: 13px;
  font-weight: 700;
}

.field-grid input,
.field-grid textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid #9a979f;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.field-grid textarea {
  min-height: 98px;
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.brief {
  padding: 34px 30px 25px;
  background: #f6f7f5;
}

.brief-head h2 { font-size: 18px; }

.brief-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.status {
  padding: 4px 6px;
  border: 1px solid #a6a2ad;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.brief-fields {
  margin: 24px 0 0;
}

.brief-row {
  display: grid;
  padding: 14px 0;
  grid-template-columns: 125px 1fr;
  gap: 14px;
  border-top: 1px solid #e1e0e1;
}

.brief-row dt {
  font-size: 13px;
  font-weight: 700;
}

.brief-row dd {
  margin: 0;
}

.brief-row input,
.brief-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #b6b3bb;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.brief-row textarea {
  min-height: 76px;
  resize: vertical;
}

.brief-value {
  margin: 0;
}

.brief-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed #bdbbc0;
  color: var(--muted);
  font-size: 12px;
}

.agent-panel {
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.agent-panel h2 {
  margin-top: 5px;
}

.agent-messages {
  max-height: 290px;
  margin: 16px 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.agent-empty {
  margin: 0;
  padding: 16px 0;
  color: var(--muted);
  font-size: 13px;
}

.agent-message {
  padding: 12px 0;
  border-bottom: 1px solid #e1e0e1;
}

.agent-message:last-child {
  border-bottom: 0;
}

.agent-message strong {
  color: var(--teal-dark);
  font-size: 12px;
}

.message-avatar {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 6px 4px 0;
}

.agent-message p {
  margin: 3px 0 0;
  white-space: pre-wrap;
}

.agent-message.user p {
  color: var(--muted);
}

.agent-panel form > label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

.agent-panel textarea {
  width: 100%;
  min-height: 86px;
  padding: 10px 11px;
  resize: vertical;
  border: 1px solid #9a979f;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.agent-actions {
  margin-top: 4px;
}

.chat-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.chat-composer > button { padding: 10px 14px; min-height: 42px; }
.floating-chat .chat-composer textarea { min-height: 64px; padding: 8px 10px; }
#chat-shortcut { display: block; margin-top: 5px; font-size: 11px; line-height: 1.4; }
.floating-chat #agent-form { padding-top: 8px; }

#agent-status {
  color: var(--teal-dark);
  font-size: 12px;
}

.route-card {
  margin-top: 20px;
  padding: 17px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.route-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.route-card p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13px;
}

.route-card a {
  color: var(--teal-dark);
}

.prompt-preview {
  max-height: 190px;
  margin-top: 12px;
  padding: 13px;
  overflow: auto;
  border: 1px solid #d3d1d6;
  background: #f5f4f4;
  font-family: Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.copy-status {
  min-height: 18px;
  color: var(--teal-dark);
  font-size: 13px;
}

footer {
  height: 32px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 7px 42px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
}

.chat-launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  position: fixed;
  right: 24px;
  bottom: 20px;
  z-index: 20;
  border-radius: 999px;
  box-shadow: 0 4px 18px #302b3a26;
}

.agent-panel.floating-chat {
  max-width: calc(100vw - 48px);
  max-height: calc(100dvh - 112px);
  position: fixed;
  right: 24px;
  bottom: 80px;
  z-index: 21;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 32px));
  height: min(720px, calc(100dvh - 112px));
  margin: 0;
  padding: 22px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 12px 48px #302b3a30;
}

.floating-chat h2,
.floating-chat > .eyebrow {
  padding-right: 36px;
}

.tutor-avatar { width: 32px; height: 32px; object-fit: contain; }
.chat-avatar { width: 40px; height: 40px; margin-bottom: 8px; }
.chat-resize { position: absolute; top: 0; left: 0; width: 28px; height: 28px; padding: 0; background: transparent; color: var(--muted); border: 0; cursor: nwse-resize; touch-action: none; user-select: none; font-size: 18px; }
.choice.recommended::before { content: "Recommended by Nirvana"; display: block; color: var(--teal-dark); font-size: 11px; font-weight: 700; margin-bottom: 6px; }
.floating-chat .agent-message {
  width: fit-content;
  max-width: 88%;
  margin: 10px 0;
  padding: 11px 14px;
  border: 0;
  border-radius: 14px 14px 14px 3px;
  background: #f0f1ef;
  overflow-wrap: anywhere;
}
.floating-chat .agent-message.user {
  margin-left: auto;
  border-radius: 14px 14px 3px 14px;
  background: var(--teal-dark);
}
.floating-chat .agent-message.user p,
.floating-chat .agent-message.user strong { color: white; }
.floating-chat .agent-message.assistant { margin-right: auto; }
.chat-decision {
  margin: 10px auto;
  padding: 2px 12px;
  max-width: 92%;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.chat-close {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 12px;
  font-size: 24px;
}

.floating-chat .agent-messages {
  flex: 1;
  min-height: 80px;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.floating-chat #agent-form {
  flex-shrink: 0;
}

.floating-chat textarea {
  min-height: 68px;
  max-height: 120px;
}

@media (max-width: 480px) {
  .chat-launcher { right: 16px; bottom: 16px; }
  .agent-panel.floating-chat { right: 16px; bottom: 76px; padding: 18px; }
}

.brief-proposals { max-height: 260px; overflow-y: auto; flex-shrink: 0; font-size: 13px; border-top: 1px solid var(--line); }
.brief-proposals section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.brief-proposals p { margin: 7px 0; padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-before { background: #fff1ef; border-left: 3px solid #a45147; }
.diff-after { background: #edf6ef; border-left: 3px solid var(--teal); }
.brief-proposals button { margin: 4px 8px 4px 0; padding: 6px 12px; }
.chat-plain { white-space: pre-wrap; color: white; margin-top: 4px; }
.chat-markdown { line-height: 1.65; }
.floating-chat .chat-markdown p { white-space: normal; margin: 0 0 12px; }
.chat-markdown > :last-child { margin-bottom: 0 !important; }
.chat-markdown ul, .chat-markdown ol { margin: 8px 0 12px; padding-left: 22px; }
.chat-markdown li { margin: 5px 0; }
.chat-markdown strong { color: inherit; font-size: inherit; }
.chat-markdown h1, .chat-markdown h2, .chat-markdown h3 { padding: 0; margin: 14px 0 8px; font-size: 1.05em; }
.chat-markdown blockquote { margin: 10px 0; padding-left: 12px; border-left: 3px solid var(--teal); }
.chat-markdown a { color: var(--teal-dark); text-decoration: underline; }
.chat-markdown code { font-family: Consolas, monospace; background: #e4e6e3; padding: 1px 4px; border-radius: 3px; }
.chat-markdown pre { max-width: 100%; overflow-x: auto; padding: 12px; background: #e4e6e3; border-radius: 6px; }
.chat-markdown pre code { padding: 0; white-space: pre; }
.problem-editor-tools { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; }
.problem-editor-tools button { padding: 6px 14px; }
.problem-editor-tools button[aria-pressed="true"] { background: var(--teal-dark); color: white; }
.problem-preview { min-height: 176px; max-height: 440px; overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); overflow-wrap: anywhere; }
.problem-preview > :first-child { margin-top: 0; }
.problem-preview p { margin: 0 0 12px; }
.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .topbar {
    padding: 0 18px;
  }

  .product {
    font-size: 14px;
  }

  .top-note {
    display: none;
  }

  .workspace {
    display: block;
  }

  .workpane,
  .brief {
    padding: 25px 20px;
  }

  .workpane {
    border-right: 0;
  }

  .steps {
    gap: 5px;
  }

  .step {
    font-size: 12px;
  }

  .steps i {
    min-width: 8px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-wrap: wrap;
    gap: 12px;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

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

  .choice-wide {
    grid-column: auto;
  }

  .wide {
    grid-column: auto;
  }

  footer {
    height: auto;
    padding: 7px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
.field-help { display: inline-block; position: relative; margin-left: 6px; font-weight: normal; vertical-align: middle; }
.help-trigger { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 50%; color: var(--teal-dark); cursor: help; font-size: 12px; }
.help-tooltip { display: none; position: absolute; z-index: 30; top: 100%; left: 0; width: min(300px, 60vw); padding: 10px 12px; font-size: 13px; line-height: 1.55; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 18px #302b3a20; }
.field-help:hover .help-tooltip, .field-help:focus-within .help-tooltip { display: block; }
.help-trigger:focus-visible { outline: 2px solid var(--teal-dark); outline-offset: 2px; }
.help-tooltip { position: fixed; width: min(300px, calc(100vw - 24px)); }
.field-help.dismissed .help-tooltip { display: none; }
.agent-panel.floating-chat { overflow: hidden; padding: 16px; }
.floating-chat > .eyebrow { display: none; }
.floating-chat > .chat-avatar { position: absolute; top: 16px; left: 16px; width: 24px; height: 24px; margin: 0; }
.floating-chat > h2 { flex-shrink: 0; margin: 2px 35px 8px 0; padding-left: 34px; font-size: 18px; }
.floating-chat > #agent-description { flex-shrink: 0; margin: 0 25px 10px 0; font-size: 12px; }
.chat-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 6px; }
.floating-chat .agent-messages, .floating-chat .brief-proposals, .floating-chat #brief-check { max-height: none; min-height: 0; overflow: visible; }
.floating-chat .agent-messages { flex: none; }
.floating-chat #agent-form { border-top: 1px solid var(--line); }
.floating-chat #brief-check { margin-top: 12px; padding-bottom: 10px; }
#framing-lesson dt { font-weight: 600; margin-top: 10px; }
#framing-lesson h3 { margin: 22px 0 10px; }
#framing-lesson blockquote { margin: 0 0 10px; padding: 10px 14px; border-left: 3px solid var(--teal); background: #527c7910; line-height: 1.6; }
#framing-lesson blockquote + p { margin: 0 0 18px; line-height: 1.6; }
label[for="problem"] strong { display: flex; align-items: baseline; gap: 6px; }
label[for="problem"] strong .field-help { flex: 0 0 auto; }
.framing-actions { flex-wrap: wrap; gap: 8px; }
.framing-actions button { padding: 9px 10px; font-size: 13px; }
#framing-lesson dd { margin: 3px 0 12px; white-space: pre-wrap; }
.steps { flex-wrap: wrap; }
.diff-after { width: 100%; min-height: 80px; resize: vertical; }
#brief-check { border-top: 1px solid var(--line, #ddd); padding-top: 8px; max-height: 180px; overflow-y: auto; flex-shrink: 0; }
#check-question { white-space: pre-line; font-size: 13px; line-height: 1.5; }
#brief-check button { font-size: 12px; padding: 5px 8px; }
.route-tool { border-bottom: 1px solid var(--line, #ddd); padding: 10px 0; }
.route-tool summary { cursor: pointer; font-weight: 600; }
.route-tool p { font-size: 14px; }
