/* Goldmine brainstorm + app-chrome styles: setup cards, chat, scratchpad,
   stage-1 intake, demo chrome, side panel, plus shared chrome (toast, settings
   modal, intro splash). Extracted from index.html (pre-draft refactor step 1).
   The shared chrome can move to a base/shared sheet in a later tidy. */
  /* Toast for Save-to-Drive feedback */
  .toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translate(-50%, 12px);
    background: var(--ink);
    color: #fff;
    font-family: var(--sans);
    font-size: 0.88rem;
    padding: 0.7rem 1.1rem;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(2, 37, 89, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 200;
    max-width: 90vw;
  }
  .toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
  }
  .toast.error { background: #8a2a1a; }
  .toast.success { background: var(--brand); border: 1px solid var(--accent); }
  .toast a {
    color: var(--accent);
    margin-left: 0.4rem;
    text-decoration: underline;
  }

  /* Setup view: two-card service layout, mirrors collegebound-md.com */
  .setup {
    max-width: 1040px;
    margin: 1rem auto 0;
  }
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
  .setup-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: stretch;
    max-width: 560px;
    margin: 0 auto;
  }
  .setup-card {
    border-radius: 10px;
    padding: 1.85rem 1.85rem 1.6rem;
    display: flex;
    flex-direction: column;
  }
  .setup-card.primary {
    background: var(--bg);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    /* compensate for the thicker top border so card content stays aligned */
    padding-top: calc(1.85rem - 2px);
  }
  .card-eyebrow {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.55rem;
  }
  .card-title {
    font-family: var(--display);
    font-size: 1.65rem;
    font-weight: 400;
    letter-spacing: -0.005em;
    line-height: 1.2;
    margin: 0 0 0.65rem;
    color: var(--ink);
  }
  .card-desc {
    font-size: 0.93rem;
    line-height: 1.55;
    margin: 0 0 1.1rem;
    color: var(--body);
  }

  .setup-card textarea {
    width: 100%;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.8rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    resize: vertical;
    line-height: 1.55;
    background: var(--bg);
    color: var(--ink);
  }
  .setup-card textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .setup-card textarea::placeholder {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .link-btn {
    display: inline;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: inherit;
    font-style: italic;
    cursor: pointer;
    padding: 0;
    border-bottom: 1px solid transparent;
    color: var(--muted);
  }
  .link-btn:hover { color: var(--accent); border-bottom-color: var(--accent); }
  .setup-card .link-btn { margin-top: 0.65rem; align-self: flex-start; font-size: 0.82rem; }

  .card-cta-row {
    margin-top: auto;
    padding-top: 1.4rem;
  }
  .card-cta {
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 0.8rem 1.4rem;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    background: var(--brand);
    color: #fff;
  }
  .card-cta:hover { background: var(--accent); color: var(--brand); }
  .skip-to-wrapup-btn {
    display: block;
    margin-top: 0.75rem;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .skip-to-wrapup-btn:hover { color: var(--ink); }

  /* ---- Demo mode (served at /demo): persona picker + autoplay chrome.
     Hidden by default; revealed by body.demo-mode set in the DEMO_MODE boot. */
  .demo-only { display: none; }
  body.demo-mode .demo-only { display: flex; }
  body.demo-mode .setup-grid {
    grid-template-columns: 1fr 1fr;
    max-width: 900px;
  }
  @media (max-width: 800px) {
    body.demo-mode .setup-grid { grid-template-columns: 1fr; }
  }
  .setup-card.secondary {
    background: var(--bg);
    border: 1px solid var(--line);
  }
  .persona-dropdown {
    position: relative;
    margin-top: 0.4rem;
  }
  .persona-trigger {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.7rem 0.95rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    text-align: left;
    transition: border-color 0.15s;
  }
  .persona-trigger:hover { border-color: var(--brand-soft); }
  .persona-trigger:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .persona-dropdown.open .persona-trigger { border-color: var(--brand); }
  .persona-trigger .trigger-label {
    font-family: var(--serif);
    font-weight: 600;
    color: var(--ink);
  }
  .persona-trigger .trigger-label .t-title {
    font-weight: 400;
    font-style: italic;
    color: var(--muted);
    margin-left: 0.25rem;
  }
  .persona-trigger .trigger-caret {
    color: var(--muted);
    font-size: 0.7rem;
    transition: transform 0.15s;
  }
  .persona-dropdown.open .trigger-caret { transform: rotate(180deg); }
  .persona-options {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(2, 37, 89, 0.10);
    max-height: 400px;
    overflow-y: auto;
    z-index: 20;
  }
  .persona-dropdown.open .persona-options { display: block; }
  .persona-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.7rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    border-bottom: 1px solid var(--line-2);
  }
  .persona-option:last-child { border-bottom: none; }
  .persona-option:hover { background: var(--bg-soft); }
  .persona-option:focus-visible { outline: none; background: var(--bg-soft); box-shadow: inset 3px 0 0 var(--accent); }
  .persona-option.selected {
    background: var(--bg-soft);
    box-shadow: inset 3px 0 0 var(--brand);
  }
  .persona-option .p-name {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
  }
  .persona-option .p-title {
    font-weight: 400;
    font-style: italic;
    color: var(--muted);
  }
  .persona-option .p-desc {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.2rem;
    line-height: 1.45;
  }

  /* Demo status pill in chat header */
  .demo-status {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-right: auto;
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
  }
  .demo-status.hidden { display: none; }
  .demo-status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: demoPulse 1.6s infinite ease-in-out;
  }
  .demo-status.paused .dot { background: var(--muted); animation: none; }
  @keyframes demoPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
  }

  .chat-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1.5rem;
  }
  .chat-tools {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    overflow: hidden;
  }
  .chat-tools button {
    font-family: inherit;
    background: transparent;
    color: var(--muted);
    border: none;
    border-left: 1px solid var(--line);
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
  }
  .chat-tools button:first-child { border-left: none; }
  .chat-tools button svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }
  /* The real Google Drive logo is multi-color: let its own fills show and drop
     the toolbar's currentColor stroke. */
  .chat-tools button#saveDriveBtn svg { width: 14px; height: 14px; }
  .chat-tools button#saveDriveBtn svg path { stroke: none; }
  .chat-tools button:hover { color: var(--ink); background: var(--bg-soft); }
  .chat-tools button.hidden { display: none; }

  .chat {
    min-height: 440px;
    max-height: 62vh;
    overflow-y: auto;
    padding: 0.5rem 0 1rem;
    margin-bottom: 1rem;
  }

  .progress {
    margin: 0 0 1.25rem;
  }
  .progress-meta {
    display: flex;
    align-items: baseline;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
  }
  .progress-meta .label { font-style: italic; font-size: 0.8rem; }
  .progress-bar {
    height: 3px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
  }
  .progress-bar .fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .msg {
    max-width: 88%;
    font-family: var(--serif);
    font-size: 1.05rem;
    line-height: 1.5;
    white-space: pre-wrap;
  }
  .msg.coach {
    color: #1a1a1a;
    font-weight: 450;
    margin-bottom: 20px;
  }
  .msg.user {
    font-style: italic;
    color: var(--body);
    margin: 0 0 28px 24px;
    padding-left: 18px;
    border-left: 2px solid var(--accent);
  }
  .msg.typing { color: var(--muted); }
  .dots { display: inline-block; letter-spacing: 0.15em; }
  .dots span {
    display: inline-block;
    opacity: 0.25;
    animation: dotPulse 1.4s infinite ease-in-out;
  }
  .dots span:nth-child(2) { animation-delay: 0.2s; }
  .dots span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
  }

  .stage1-form {
    min-height: 440px;
    max-height: 62vh;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 1rem;
    margin-bottom: 1rem;
  }
  .stage1-form.hidden { display: none; }
  .stage1-header { margin-bottom: 1.25rem; }
  .stage1-title {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 0.3rem;
    color: var(--ink);
  }
  .stage1-sub {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
  }
  .stage1-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
  }
  .stage1-progress-bar {
    flex: 1;
    height: 3px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
  }
  .stage1-progress-bar .fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .stage1-progress-label {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
  }
  .stage1-sections {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  .stage1-section-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .stage1-section-card.expanded {
    border-color: var(--accent);
    box-shadow: 0 1px 6px rgba(212, 160, 23, 0.08);
  }
  .stage1-section-card.locked { background: var(--bg-soft); border-style: dashed; }
  .stage1-section-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font: inherit;
    cursor: pointer;
    color: var(--ink);
  }
  .stage1-section-card.locked .stage1-section-card-head { cursor: not-allowed; color: var(--muted); }
  .stage1-section-card.completed:not(.expanded) .stage1-section-card-head:hover {
    background: var(--bg-soft);
  }
  .stage1-section-card-head-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
  }
  .stage1-section-indicator {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
  }
  .stage1-section-card.expanded .stage1-section-indicator {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
  }
  .stage1-section-card.completed:not(.expanded) .stage1-section-indicator {
    border-color: #2d5a2a;
    background: #2d5a2a;
    color: white;
  }
  .stage1-section-card-title {
    font-family: var(--serif);
    font-size: 1.02rem;
    font-weight: 500;
    color: var(--ink);
  }
  .stage1-section-card.locked .stage1-section-card-title { color: var(--muted); }
  .stage1-section-card-meta {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
  }
  .stage1-section-card-meta.met { color: #2d5a2a; }
  .stage1-section-card-meta.unmet { color: #8a5a16; }
  .stage1-section-card-body {
    padding: 0.2rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--line);
  }
  .stage1-section-card-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.4rem;
  }
  .stage1-answered { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
  .stage1-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    background: var(--bg-soft);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .stage1-row:hover { border-color: var(--ink); background: var(--bg); }
  .stage1-row-q {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
    line-height: 1.3;
  }
  .stage1-row-a {
    font-family: var(--serif);
    font-size: 0.95rem;
    color: var(--body);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .stage1-row-followup {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.3rem;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .stage1-question-wrap { display: flex; flex-direction: column; gap: 0.35rem; }
  .stage1-field-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
  }
  .stage1-question {
    font-family: var(--serif);
    font-size: 1.05rem;
    color: var(--ink);
    line-height: 1.45;
    margin: 0 0 0.7rem;
  }
  .stage1-textarea {
    width: 100%;
    max-width: 100%;
    display: block;
    font-family: var(--serif);
    font-size: 0.98rem;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    resize: vertical;
    line-height: 1.55;
    background: var(--bg);
    color: var(--body);
    min-height: 160px;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  .stage1-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .stage1-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.6rem;
  }
  .stage1-hint { font-size: 0.74rem; color: var(--muted); }
  .stage1-btn-row { display: flex; gap: 0.5rem; }
  .stage1-skip {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
  }
  .stage1-skip:hover { color: var(--ink); border-color: var(--ink); }
  .stage1-next {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1.1rem;
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
  }
  .stage1-next:disabled { opacity: 0.5; cursor: not-allowed; }
  .stage1-followup {
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px dashed var(--line);
  }
  .stage1-followup-q {
    font-family: var(--serif);
    font-size: 0.95rem;
    color: var(--ink);
    margin: 0 0 0.5rem;
  }
  .stage1-followup .stage1-textarea { min-height: 60px; font-size: 0.92rem; }
  .stage1-processing { font-size: 0.78rem; color: var(--muted); font-style: italic; }

  .warmup-banner {
    margin-bottom: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-soft);
  }
  .warmup-banner.hidden { display: none; }
  .warmup-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    background: transparent;
    border: none;
    font: inherit;
    font-size: 0.82rem;
    color: var(--muted);
    cursor: pointer;
    text-align: left;
  }
  .warmup-toggle:hover { color: var(--ink); }
  .warmup-caret { transition: transform 0.15s; }
  .warmup-toggle[aria-expanded="true"] .warmup-caret { transform: rotate(180deg); }
  .warmup-details {
    padding: 0 0.85rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .warmup-details.hidden { display: none; }
  .warmup-qa {
    border-left: 2px solid var(--line);
    padding-left: 0.7rem;
  }
  .warmup-qa-q {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.2rem;
    line-height: 1.4;
  }
  .warmup-qa-a {
    font-family: var(--serif);
    font-size: 0.92rem;
    color: var(--body);
    line-height: 1.45;
    white-space: pre-wrap;
  }
  .warmup-qa-fq {
    font-size: 0.76rem;
    color: var(--muted);
    margin-top: 0.4rem;
    font-style: italic;
  }
  .warmup-qa-fa {
    font-family: var(--serif);
    font-size: 0.88rem;
    color: var(--body);
    line-height: 1.45;
    margin-top: 0.15rem;
    white-space: pre-wrap;
  }

  .brainstorm-done-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--brand);
    border-radius: 8px;
  }
  .brainstorm-done-banner.hidden { display: none; }
  .done-banner-content { min-width: 0; }
  .done-banner-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    margin: 0 0 0.15rem;
  }
  .done-banner-sub {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.72);
    margin: 0;
  }
  .done-banner-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    flex-shrink: 0;
    border-radius: 4px;
  }
  .done-banner-close:hover { color: #fff; }

  .coach-review-panel {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .coach-review-panel.hidden { display: none; }
  .coach-review-status {
    font-size: 0.85rem;
    color: var(--ink);
    margin: 0;
  }
  .coach-review-comment {
    font-family: var(--serif);
    font-size: 0.92rem;
    color: var(--body);
    background: var(--bg);
    border-left: 2px solid var(--accent);
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    white-space: pre-wrap;
  }
  .coach-review-comment.hidden { display: none; }
  .coach-review-resubmit {
    margin-top: 0.6rem;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.45rem 0.9rem;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
  }
  .coach-review-resubmit:hover { background: var(--ink); }
  .coach-review-resubmit.hidden { display: none; }

  /* "From your coach" notes, shown inside .coach-review-comment on approval
     (COACH_GATE_PLAN.md Phase 3). Read-only suggestions; no resolve. */
  .coach-notes { white-space: normal; }
  .coach-notes-title {
    font-family: var(--sans);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 0 0 0.5rem;
  }
  .coach-notes-list { list-style: none; margin: 0; padding: 0; }
  .coach-notes-list li {
    margin-bottom: 0.7rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--line);
  }
  .coach-notes-list li:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
  .coach-note-quote {
    display: block;
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--muted);
    border-left: 2px solid var(--accent);
    padding-left: 0.55rem;
    margin-bottom: 0.25rem;
  }
  .coach-note-text { display: block; font-size: 0.9rem; color: var(--ink); line-height: 1.45; }
  .coach-notes-threads {
    font-size: 0.82rem;
    color: var(--body);
    margin: 0.7rem 0 0;
  }

  .chat-input {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
  }
  .chat-input textarea {
    width: 100%;
    display: block;
    font-family: var(--serif);
    font-size: 0.98rem;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    resize: vertical;
    line-height: 1.5;
    background: var(--bg);
    color: var(--body);
  }
  .chat-input textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .chat-input button[type="submit"] { display: none; }
  .input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
    min-height: 1.6rem;
  }
  .input-actions {
    display: flex;
    gap: 0.35rem;
  }
  .input-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
  }
  .input-action-btn.hidden { display: none; }
  .input-action-btn:hover { color: var(--ink); background: var(--bg-soft); border-color: var(--ink); }
  .input-action-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
  #micBtn.recording { color: #b8421a; border-color: #b8421a; background: rgba(184, 66, 26, 0.08); animation: micPulse 1.2s ease-in-out infinite; }
  @keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(184, 66, 26, 0.35); } 50% { box-shadow: 0 0 0 4px rgba(184, 66, 26, 0); } }
  .input-hint {
    font-size: 0.75rem;
    color: var(--muted);
    font-style: italic;
  }

  .side {
    position: sticky;
    top: 2rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.5rem 1.35rem;
  }
  .side h3 {
    font-family: var(--display);
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: -0.005em;
    margin-top: 0;
    color: var(--ink);
  }
  .side h3 .count {
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--muted);
    margin-left: 0.45rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
  }
  .side .section + .section { margin-top: 2.25rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
  .hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0.2rem 0 0.9rem;
  }
  /* Quiet placeholder line shown when a side-panel section has no real content yet. */
  .empty-state {
    margin: 0.6rem 0 0;
    padding: 1rem 1.05rem;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.88rem;
    font-style: italic;
    line-height: 1.55;
    text-align: left;
  }
  .gold-list {
    list-style: none;
    padding: 0;
    margin: 0.6rem 0 0;
    max-height: 280px;
    overflow-y: auto;
  }
  .gold-list li {
    padding: 0.4rem 0 0.4rem 1.1rem;
    margin: 0;
    font-size: 0.9rem;
    color: var(--body);
    line-height: 1.5;
    position: relative;
    border-radius: 4px;
  }
  .gold-list li.just-updated {
    animation: goldPulse 1.4s ease-out 1;
  }
  @keyframes goldPulse {
    0%   { background: rgba(212, 160, 23, 0.28); }
    35%  { background: rgba(212, 160, 23, 0.18); }
    100% { background: rgba(212, 160, 23, 0); }
  }
  @media (prefers-reduced-motion: reduce) {
    .gold-list li.just-updated { animation: none; }
  }
  .gold-list li::before {
    content: '•';
    position: absolute;
    left: 0.1rem;
    top: 0.4rem;
    color: var(--accent);
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 700;
  }

  .threads { margin: 0.6rem 0 0; }
  .thread {
    padding: 1rem 1.1rem;
    margin-bottom: 0.7rem;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
  }
  .thread:last-child { margin-bottom: 0; }
  .thread.just-updated { animation: threadPulse 1.4s ease-out 1; }
  @keyframes threadPulse {
    0%   { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0.55); }
    35%  { box-shadow: 0 0 0 6px rgba(212, 160, 23, 0.18); }
    100% { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0); }
  }
  @media (prefers-reduced-motion: reduce) {
    .thread.just-updated { animation: none; }
  }
  .thread.forming {
    background: transparent;
    border-style: dashed;
    border-color: var(--line);
  }
  .thread.strong {
    background: var(--brand);
    border: 1px solid var(--brand);
    color: #fff;
  }
  .thread .t-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
  }
  .thread .t-name {
    font-family: var(--serif);
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
  }
  .thread.forming .t-name {
    font-style: italic;
    color: var(--body);
    font-weight: 500;
  }
  .thread.strong .t-name { color: #fff; }
  .thread .t-conf {
    font-family: var(--sans);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    flex-shrink: 0;
    padding-top: 0.2rem;
    font-weight: 700;
  }
  .thread.strong .t-conf { color: var(--accent); }
  .thread .t-summary {
    font-family: var(--serif);
    font-size: 0.92rem;
    color: var(--body);
    line-height: 1.5;
    margin: 0.2rem 0 0;
  }
  .thread.strong .t-summary { color: rgba(255, 255, 255, 0.85); }
  .thread .t-evidence {
    margin: 0.6rem 0 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line);
    padding-top: 0.55rem;
  }
  .thread.strong .t-evidence { border-top-color: rgba(255, 255, 255, 0.18); }
  .thread .t-evidence li {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.45;
    padding: 0.2rem 0 0.2rem 0.95rem;
    position: relative;
    font-style: italic;
  }
  .thread.strong .t-evidence li { color: rgba(255, 255, 255, 0.78); }
  .thread .t-evidence li::before {
    content: '•';
    position: absolute;
    left: 0.15rem;
    top: 0.2rem;
    color: var(--accent);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 700;
  }
  /* Settings modal */
  .modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
  }
  .modal.hidden { display: none; }
  .modal-body {
    background: var(--bg);
    padding: 2rem 2.25rem;
    border-radius: 10px;
    width: 460px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  }
  .modal-body h2 {
    font-family: var(--display);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -0.005em;
    margin-bottom: 0.4rem;
    color: var(--ink);
  }
  .modal-body label {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 500;
    margin: 1rem 0 0.35rem;
  }
  .modal-body input, .modal-body select {
    width: 100%;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink);
  }
  .modal-body input:focus, .modal-body select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .modal-body .cta {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.5rem;
  }
  .modal-body button {
    font-family: inherit;
    padding: 0.65rem 1.2rem;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    border: none;
  }
  .modal-body button.primary { background: var(--brand); color: #fff; }
  .modal-body button.primary:hover { background: var(--accent); color: var(--brand); }
  .modal-body button.ghost { background: transparent; color: var(--muted); }
  .modal-body button.ghost:hover { color: var(--ink); background: var(--bg-soft); }

  /* Intro splash */
  #intro {
    position: fixed; inset: 0; z-index: 9999;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    animation: introOut 0.5s ease 2.4s forwards;
  }
  #intro .stage {
    display: flex; align-items: center; gap: clamp(0.75rem, 3vw, 2.25rem);
    max-width: 100%;
  }
  #intro .logo { opacity: 0; animation: logoIn 0.55s ease 0.1s forwards; min-width: 0; }
  #intro .logo img { height: clamp(48px, 13vw, 140px); width: auto; max-width: 100%; display: block; object-fit: contain; }
  #intro .divider {
    width: 2px; height: clamp(40px, 9vw, 90px); background: #e6e8ee; flex-shrink: 0;
    opacity: 0; animation: dividerIn 0.4s ease 0.75s forwards;
  }
  #intro .word {
    opacity: 0;
    font-family: 'Fraunces', 'Ovo', serif;
    font-weight: 600;
    font-size: clamp(32px, 8vw, 96px);
    white-space: nowrap;
    letter-spacing: -0.02em;
    background: linear-gradient(100deg, #d4a017 0%, #f0c64a 45%, #022559 90%);
    background-size: 220% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: wordIn 0.6s cubic-bezier(.2,.8,.2,1) 0.85s forwards, shimmer 1.1s ease 1.2s forwards;
  }
  @keyframes logoIn    { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
  @keyframes dividerIn { from { opacity: 0; transform: scaleY(0.4); } to { opacity: 1; transform: none; } }
  @keyframes wordIn    { from { opacity: 0; transform: translateX(6px); }
                          to { opacity: 1; transform: none; } }
  @keyframes shimmer { to { background-position: 0 0; } } /* navy → gold, holds gold */
  @keyframes introOut { to { opacity: 0; visibility: hidden; } }
  @media (prefers-reduced-motion: reduce) {
    #intro { animation: introOut 0.2s ease 0.3s forwards; }
    #intro .logo, #intro .word { animation: none; opacity: 1; }
    #intro .word { background: none; -webkit-text-fill-color: #d4a017; }
  }

  /* Coach comment rail (student side): a third grid column shown post-approval
     (COACH_GATE_PLAN.md Phase 3). See app/brainstorm/index.js#renderCommentRail. */
  .grid.has-comment-rail {
    grid-template-columns: minmax(0, 1.5fr) minmax(200px, 0.82fr) minmax(212px, 0.82fr);
  }
  .comment-rail { position: sticky; top: 1rem; align-self: start; }
  .comment-rail.hidden { display: none; }
  .crail-head {
    font-family: var(--sans);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 0.7rem;
  }
  .crail-group { margin-bottom: 1.1rem; }
  .crail-group-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.4rem;
  }
  .crail-card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.12s, border-color 0.12s;
  }
  /* Only cards whose inline mark exists are interactive (see renderRailCard). */
  .crail-card.linked { cursor: pointer; }
  .crail-card.linked:hover, .crail-card.hl { box-shadow: 0 4px 14px rgba(2, 37, 89, 0.14); }
  .crail-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .crail-quote {
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
  }
  .crail-text { color: var(--ink); font-size: 0.88rem; line-height: 1.4; }

  @media (max-width: 900px) {
    .grid.has-comment-rail { grid-template-columns: 1fr; }
    .comment-rail { position: static; top: auto; }
  }
