    :root {
      --radius-desk: 16px;
      --radius-soft: 12px;
      --grain-opacity: 0.02;
      --app-height: 100dvh;
      --viewport-height: 100dvh;
      --composer-height: 124px;
      --keyboard-offset: 0px;
      --stream-bottom-gap: 24px;
    }

    html[data-theme="night"] {
      --grain-opacity: 0.04;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: var(--viewport-height);
      background: var(--bg);
      color: var(--ink);
      font-family: var(--font-sans);
      line-height: 1.6;
      transition: background-color 280ms ease, color 280ms ease;
      overscroll-behavior-y: none;
    }

    button,
    input,
    select,
    textarea {
      font-family: inherit;
    }

    .page {
      max-width: 100%;
      margin: 0 auto;
      padding: 18px 24px 24px;
      min-height: var(--viewport-height);
      display: flex;
      flex-direction: column;
    }

    body.chat-locked {
      overflow: hidden;
      overscroll-behavior: none;
    }

    .page.chat-active {
      height: var(--app-height);
      min-height: var(--app-height);
      overflow: hidden;
    }

    .page.chat-active .plaque,
    .page.chat-active .quiet-footer {
      flex-shrink: 0;
    }

    .page.chat-active .quiet-footer {
      display: none;
    }

    .plaque {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 14px;
      margin: 0 auto 14px;
      width: min(100%, 760px);
    }

    .plaque h1 {
      margin: 0;
      font-family: var(--font-serif);
      font-size: 2.15rem;
      line-height: 1.05;
      letter-spacing: -0.01em;
      font-weight: 500;
    }

    .plaque p {
      margin: 8px 0 0;
      color: var(--muted-ink);
      max-width: none;
      white-space: normal;
      font-size: 0.92rem;
    }

    .page.chat-active .plaque {
      margin-bottom: 10px;
    }

    .page.chat-active .plaque p {
      display: none;
    }

    .plaque-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: none;
    }

    .home-link {
      text-decoration: none;
      display: inline-flex;
      align-items: center;
    }

    .theme-toggle {
      border: 1px solid var(--border);
      background: color-mix(in srgb, var(--surface) 94%, var(--bg) 6%);
      color: var(--ink);
      border-radius: 999px;
      padding: 8px 14px;
      font-size: 0.88rem;
      min-height: 38px;
      cursor: pointer;
      transition: border-color 220ms ease, color 220ms ease, background-color 220ms ease;
      white-space: nowrap;
    }

    .theme-toggle:hover {
      border-color: var(--accent);
      color: var(--accent);
    }

    .theme-toggle:focus-visible,
    button:focus-visible,
    textarea:focus-visible,
    .chip input:focus-visible + span,
    .tool-link:focus-visible {
      outline: 2px solid var(--focus);
      outline-offset: 2px;
    }

    .desk {
      position: relative;
      border: 1px solid var(--border);
      background: var(--surface);
      border-radius: var(--radius-desk);
      padding: 26px;
      box-shadow: var(--shadow);
      overflow: hidden;
      transition: background-color 280ms ease, border-color 280ms ease;
    }

    .desk.chat-mode,
    .desk.arrival-mode {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      width: min(100%, 760px);
      margin: 0 auto;
      padding: 0 0 16px;
      border: 0;
      background: transparent;
      box-shadow: none;
      overflow: visible;
    }

    .desk.chat-mode::before,
    .desk.arrival-mode::before {
      display: none;
    }

    .desk.arrival-mode .ritual {
      border: 1px solid var(--border);
      background: color-mix(in srgb, var(--surface) 78%, var(--bg) 22%);
      padding: 20px;
      margin: 0;
      box-shadow: var(--shadow);
    }

    .desk::before {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      background-image: radial-gradient(rgba(21, 20, 18, var(--grain-opacity)) 0.6px, transparent 0.6px);
      background-size: 3px 3px;
      opacity: 0.9;
    }

    .desk > * {
      position: relative;
      z-index: 1;
    }

    .desk-top {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 12px;
      margin-bottom: 14px;
      min-height: 28px;
    }

    .session-badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 0.82rem;
      color: var(--muted-ink);
      letter-spacing: 0.02em;
      text-transform: uppercase;
    }

    .session-badge .badge-value {
      color: var(--ink);
      font-weight: 600;
      letter-spacing: 0.05em;
    }

    .tools-wrap {
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .tools-btn {
      border: 1px solid var(--border);
      background: transparent;
      color: var(--muted-ink);
      border-radius: 10px;
      padding: 9px 15px;
      font-size: 0.95rem;
      min-height: 42px;
      cursor: pointer;
    }

    .tools-btn.plus-btn {
      width: 30px;
      height: 30px;
      min-width: 30px;
      min-height: 30px;
      padding: 0;
      border: 0;
      border-radius: 999px;
      background: transparent;
      font-size: 1.5rem;
      font-weight: 400;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding-bottom: 2px;
    }

    .tools-btn.plus-btn[aria-expanded="true"] {
      color: var(--ink);
      background: color-mix(in srgb, var(--ink) 8%, transparent);
    }

    .tools-btn:hover {
      border-color: var(--accent);
      color: var(--accent);
    }

    .tools-drawer {
      position: absolute;
      bottom: calc(100% + 10px);
      left: 0;
      right: auto;
      width: min(300px, 78vw);
      border: 1px solid var(--border);
      background: color-mix(in srgb, var(--surface) 97%, var(--bg) 3%);
      border-radius: 14px;
      box-shadow: var(--shadow);
      padding: 10px;
      display: grid;
      gap: 4px;
      z-index: 55;
    }

    .tools-drawer[hidden] {
      display: none;
    }

    .tool-link {
      width: 100%;
      text-align: left;
      border: 1px solid transparent;
      background: transparent;
      color: var(--ink);
      border-radius: 8px;
      padding: 9px 10px;
      cursor: pointer;
      font-size: 0.89rem;
    }

    .tool-link:hover {
      border-color: var(--border);
      color: var(--accent);
    }

    .tool-link:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .ritual {
      border: 1px solid var(--border);
      border-radius: var(--radius-soft);
      padding: 20px;
      background: color-mix(in srgb, var(--surface) 78%, var(--bg) 22%);
      margin-top: 2px;
      margin-bottom: 8px;
      width: min(100%, 760px);
      margin-left: auto;
      margin-right: auto;
    }

    .ritual h2 {
      margin: 0 0 18px;
      font-family: var(--font-serif);
      font-size: 1.75rem;
      line-height: 1.12;
      font-weight: 500;
    }

    .ritual p {
      margin: 8px 0 14px;
      color: var(--muted-ink);
      font-size: 0.92rem;
    }

    .ritual .ritual-fine {
      margin: 14px 0 0;
      font-size: 0.8rem;
      text-wrap: pretty;
    }

    .ritual-fine a {
      color: inherit;
      text-underline-offset: 3px;
    }

    .chips {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 14px;
    }

    .chip {
      position: relative;
    }

    .chip input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }

    .chip span {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 36px;
      padding: 6px 12px;
      border: 1px solid var(--border);
      border-radius: 999px;
      color: var(--muted-ink);
      cursor: pointer;
      font-size: 0.9rem;
      transition: border-color 200ms ease, color 200ms ease, background-color 200ms ease;
      user-select: none;
    }

    .chip span:hover {
      border-color: color-mix(in srgb, var(--ink) 40%, var(--border) 60%);
      color: var(--ink);
    }

    .chip input:checked + span {
      color: var(--ink);
      border-color: color-mix(in srgb, var(--ink) 55%, var(--border) 45%);
      background: var(--surface-strong);
      font-weight: 600;
    }

    /* Onboarding questions, asked on every visit before the session starts. */
    .survey-question {
      border: 0;
      padding: 0;
      margin: 0 0 20px;
      min-width: 0;
    }

    .survey-question legend {
      padding: 0;
      margin: 0 0 10px;
      font-size: 0.98rem;
      font-weight: 500;
      color: var(--ink);
      text-wrap: pretty;
    }

    .survey-question .chips {
      margin-bottom: 0;
    }

    .survey-group {
      margin: 10px 0 6px;
      font-size: 0.74rem;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--muted-ink);
    }

    .survey-group:first-of-type {
      margin-top: 0;
    }

    .survey .primary-btn {
      margin-top: 4px;
    }

    /* Difficulty slider: five stops from casual to PhD, with the default marked. */
    .difficulty {
      width: min(100%, 420px);
      margin: 6px 0 20px;
    }

    .difficulty-head {
      display: flex;
      align-items: baseline;
      gap: 10px;
      font-size: 0.92rem;
    }

    .difficulty-head .difficulty-label {
      color: var(--muted-ink);
    }

    .difficulty-head .difficulty-value {
      color: var(--ink);
      font-weight: 600;
    }

    .difficulty-ends {
      display: flex;
      justify-content: space-between;
      margin-top: 10px;
      color: var(--muted-ink);
      font-size: 0.8rem;
    }

    .difficulty-track {
      position: relative;
      height: 30px;
      margin-top: 2px;
    }

    .difficulty-dots {
      position: absolute;
      left: 0;
      right: 0;
      top: 50%;
      height: 10px;
      transform: translateY(-50%);
      border-radius: 999px;
      background: color-mix(in srgb, var(--ink) 9%, var(--surface) 91%);
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 7px;
      pointer-events: none;
    }

    .difficulty-dots i {
      display: block;
      width: 4px;
      height: 4px;
      border-radius: 50%;
      background: color-mix(in srgb, var(--ink) 32%, transparent);
    }

    .difficulty-input {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      margin: 0;
      -webkit-appearance: none;
      appearance: none;
      background: transparent;
      border-radius: 999px;
      cursor: pointer;
    }

    .difficulty-input::-webkit-slider-runnable-track {
      height: 30px;
      background: transparent;
    }

    /* The native thumb stays for pointer and keyboard input but is invisible; the knob below
       follows the value and glides between stops. */
    .difficulty-input::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 14px;
      height: 22px;
      margin-top: 4px;
      opacity: 0;
    }

    .difficulty-input::-moz-range-track {
      height: 30px;
      background: transparent;
    }

    .difficulty-input::-moz-range-thumb {
      width: 14px;
      height: 22px;
      border: 0;
      opacity: 0;
    }

    .difficulty-knob {
      position: absolute;
      top: 50%;
      left: calc(7px + var(--pos, 0.5) * (100% - 14px));
      width: 14px;
      height: 22px;
      transform: translate(-50%, -50%);
      border-radius: 999px;
      background: var(--surface);
      border: 1px solid color-mix(in srgb, var(--ink) 45%, var(--border) 55%);
      box-shadow: var(--shadow);
      pointer-events: none;
      transition: left 180ms ease, border-color 200ms ease;
    }

    .difficulty-track.is-dragging .difficulty-knob {
      transition: border-color 200ms ease;
    }

    .difficulty-track:hover .difficulty-knob,
    .difficulty-input:focus-visible ~ .difficulty-knob,
    .difficulty-track.is-dragging .difficulty-knob {
      border-color: var(--accent);
    }

    .difficulty-pill {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      height: 28px;
      padding: 0 8px 0 11px;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: transparent;
      color: var(--muted-ink);
      font-family: inherit;
      font-size: 0.8rem;
      line-height: 1;
      white-space: nowrap;
      cursor: pointer;
      transition: border-color 200ms ease, color 200ms ease;
    }

    .difficulty-pill svg {
      width: 11px;
      height: 11px;
      flex: none;
    }

    .difficulty-pill:hover,
    .difficulty-pill[aria-expanded="true"] {
      border-color: var(--accent);
      color: var(--ink);
    }

    .difficulty-pill[hidden] {
      display: none;
    }

    .difficulty-popover {
      position: absolute;
      bottom: calc(100% + 10px);
      left: 0;
      width: min(300px, 80vw);
      border: 1px solid var(--border);
      background: color-mix(in srgb, var(--surface) 97%, var(--bg) 3%);
      border-radius: 14px;
      box-shadow: var(--shadow);
      padding: 12px 14px 6px;
      z-index: 55;
    }

    .difficulty-popover[hidden] {
      display: none;
    }

    .difficulty-in-popover {
      width: auto;
      margin: 0;
    }

    .difficulty-note {
      margin: 0 0 4px;
      color: var(--muted-ink);
      font-size: 0.78rem;
    }

    .primary-btn,
    .secondary-btn {
      border-radius: 999px;
      min-height: 42px;
      padding: 9px 18px;
      cursor: pointer;
      font-size: 0.95rem;
      font-weight: 500;
      transition: border-color 220ms ease, color 220ms ease, background-color 220ms ease;
    }

    .primary-btn {
      border: 1px solid var(--primary);
      background: var(--primary);
      color: var(--on-primary);
    }

    .primary-btn:hover:not(:disabled) {
      background: var(--accent);
      border-color: var(--accent);
    }

    .primary-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .secondary-btn {
      border: 1px solid var(--border);
      background: transparent;
      color: var(--ink);
    }

    .secondary-btn:hover {
      border-color: var(--accent);
      color: var(--accent);
    }

    #sessionArea:not([hidden]) {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;
      align-items: center;
    }

    .chat-lane {
      width: min(100%, 760px);
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .stream-shell {
      position: relative;
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      padding: 0;
      width: 100%;
    }

    .desk.chat-mode .stream-shell {
      min-height: 0;
    }

    .stream {
      margin: 0;
      height: auto;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding: 8px 0 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      display: flex;
      flex-direction: column;
      gap: 12px;
      scroll-padding-bottom: var(--stream-bottom-gap);
      overscroll-behavior-y: contain;
      -webkit-overflow-scrolling: touch;
    }

    .desk.chat-mode .stream {
      min-height: 0;
    }

    .stream {
      scrollbar-width: thin;
      scrollbar-color: color-mix(in srgb, var(--border) 70%, transparent) transparent;
    }

    .stream::-webkit-scrollbar {
      width: 8px;
    }

    .stream::-webkit-scrollbar-track {
      background: transparent;
    }

    .stream::-webkit-scrollbar-thumb {
      background: color-mix(in srgb, var(--border) 70%, transparent);
      border-radius: 999px;
      border: 2px solid transparent;
      background-clip: padding-box;
    }

    .stream::-webkit-scrollbar-thumb:hover {
      background: color-mix(in srgb, var(--muted-ink) 45%, var(--border) 55%);
      background-clip: padding-box;
    }

    .stream-empty {
      margin: auto 0;
      text-align: center;
      color: var(--muted-ink);
      font-size: 0.92rem;
      line-height: 1.6;
      padding: 24px 18px;
    }

    .stream-loader {
      margin: 0 auto 4px;
      color: var(--muted-ink);
      font-size: 0.78rem;
      letter-spacing: 0.02em;
      text-align: center;
    }

    .stream-end-spacer {
      flex: 0 0 var(--stream-bottom-gap);
      min-height: var(--stream-bottom-gap);
      pointer-events: none;
      width: 100%;
    }

    .jump-latest-btn {
      position: absolute;
      right: 0;
      bottom: 8px;
      border: 1px solid var(--border);
      background: color-mix(in srgb, var(--surface) 96%, var(--bg) 4%);
      color: var(--ink);
      border-radius: 999px;
      padding: 8px 12px;
      font-size: 0.8rem;
      letter-spacing: 0.02em;
      cursor: pointer;
      box-shadow: var(--shadow);
      z-index: 7;
    }

    .jump-latest-btn:hover {
      color: var(--accent);
      border-color: var(--accent);
    }

    .jump-latest-btn[hidden] {
      display: none;
    }

    .message-row {
      display: flex;
      flex-direction: column;
      width: 100%;
      max-width: 100%;
      margin: 0;
      gap: 5px;
    }

    .message-row.user {
      align-self: flex-end;
      align-items: flex-end;
    }

    .message-row.assistant {
      align-self: flex-start;
      align-items: flex-start;
    }

    .message-label {
      display: none;
    }

    .message-bubble {
      max-width: min(100%, 640px);
      border: 1px solid var(--border);
      border-radius: 22px;
      padding: 14px 18px;
      white-space: normal;
      overflow-wrap: anywhere;
      line-height: 1.62;
      font-size: 0.98rem;
      background: color-mix(in srgb, var(--surface) 98%, transparent);
      box-shadow: none;
      transition: background-color 280ms ease, border-color 280ms ease;
    }

    .message-row.user .message-bubble {
      max-width: min(82%, 640px);
      background: color-mix(in srgb, var(--ink) 12%, var(--surface) 88%);
      border-color: color-mix(in srgb, var(--ink) 26%, var(--border) 74%);
      color: var(--ink);
      border-bottom-right-radius: 10px;
    }

    .message-row.assistant .message-bubble {
      max-width: min(90%, 640px);
      background: color-mix(in srgb, var(--surface) 96%, var(--bg) 4%);
      border-color: color-mix(in srgb, var(--border) 92%, transparent);
      border-bottom-left-radius: 10px;
    }

    .message-bubble > :first-child {
      margin-top: 0;
    }

    .message-bubble > :last-child {
      margin-bottom: 0;
    }

    .message-bubble p {
      margin: 0 0 0.92em;
    }

    .message-bubble ul,
    .message-bubble ol {
      margin: 0 0 0.92em;
      padding-left: 1.3em;
    }

    .message-bubble li + li {
      margin-top: 0.28em;
    }

    .message-bubble strong {
      color: var(--ink);
      font-weight: 700;
    }

    .message-bubble em {
      font-style: italic;
    }

    .message-bubble code {
      font-family: var(--font-mono);
      font-size: 0.92em;
      padding: 0.1em 0.38em;
      border-radius: 8px;
      background: color-mix(in srgb, var(--ink) 8%, var(--surface) 92%);
    }

    .message-row.user .message-bubble code {
      background: color-mix(in srgb, var(--surface) 72%, transparent);
    }

    .pending-indicator {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      margin: 2px 0 4px;
      padding: 0 2px;
      background: transparent;
      color: var(--muted-ink);
      font-size: 0.84rem;
      letter-spacing: 0.01em;
      text-transform: none;
      box-shadow: none;
    }

    .pause-card {
      width: min(100%, 640px);
      border: 1px solid color-mix(in srgb, var(--border) 92%, transparent);
      border-radius: 22px;
      padding: 14px 16px;
      background: color-mix(in srgb, var(--surface) 97%, var(--bg) 3%);
      display: grid;
      gap: 10px;
      box-shadow: none;
    }

    .pause-card-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }

    .pause-card-copy {
      display: grid;
      gap: 5px;
    }

    .pause-card-eyebrow {
      font-size: 0.7rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted-ink);
      font-weight: 600;
    }

    .pause-card-title {
      margin: 0;
      color: var(--ink);
      font-family: var(--font-serif);
      font-size: 1.25rem;
      line-height: 1.2;
      font-weight: 600;
    }

    .pause-card p {
      margin: 0;
      color: var(--muted-ink);
      font-size: 0.92rem;
      line-height: 1.58;
    }

    .pause-card-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      flex-wrap: wrap;
    }

    .pause-card-window {
      font-size: 0.8rem;
      color: var(--muted-ink);
    }

    .pause-card-dismiss {
      border: 1px solid var(--border);
      background: transparent;
      color: var(--muted-ink);
      border-radius: 999px;
      padding: 6px 10px;
      font-size: 0.78rem;
      cursor: pointer;
    }

    .pause-card-dismiss:hover {
      border-color: var(--accent);
      color: var(--accent);
    }

    .pending-dots {
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .pending-dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: color-mix(in srgb, var(--muted-ink) 74%, transparent);
      animation: thinkingPulse 1.15s ease-in-out infinite;
    }

    .pending-dot:nth-child(2) {
      animation-delay: 0.14s;
    }

    .pending-dot:nth-child(3) {
      animation-delay: 0.28s;
    }

    .pending-text {
      white-space: nowrap;
    }

    .save-reminder {
      position: relative;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 2px 8px;
      width: fit-content;
      max-width: min(100%, 440px);
      margin: 0 0 20px 10px;
      padding: 6px 8px 6px 16px;
      border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
      border-radius: 20px;
      background: color-mix(in srgb, var(--surface) 90%, var(--bg) 10%);
      box-shadow: 0 8px 22px rgba(21, 20, 18, 0.06);
      color: var(--muted-ink);
      font-size: 0.82rem;
      line-height: 1.4;
      transform-origin: 24px 100%;
      animation: thoughtPop 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    .save-reminder::before,
    .save-reminder::after {
      content: "";
      position: absolute;
      border: inherit;
      border-radius: 999px;
      background: inherit;
    }

    .save-reminder::before {
      left: 22px;
      bottom: -10px;
      width: 10px;
      height: 10px;
    }

    .save-reminder::after {
      left: 15px;
      bottom: -18px;
      width: 6px;
      height: 6px;
    }

    .save-reminder[hidden],
    .save-cue[hidden] {
      display: none;
    }

    .save-reminder-text {
      margin: 0;
    }

    .save-reminder-actions {
      display: inline-flex;
      align-items: center;
      gap: 2px;
    }

    .save-link {
      border: 0;
      background: transparent;
      color: var(--ink);
      font-size: 0.82rem;
      font-weight: 500;
      padding: 4px 6px;
      border-radius: 999px;
      cursor: pointer;
      text-decoration: underline;
      text-decoration-color: color-mix(in srgb, var(--ink) 30%, transparent);
      text-underline-offset: 3px;
      transition: color 200ms ease;
    }

    .save-link:hover {
      color: var(--accent);
      text-decoration-color: currentColor;
    }

    .cue-dismiss {
      border: 0;
      background: transparent;
      color: var(--muted-ink);
      font-size: 1rem;
      line-height: 1;
      cursor: pointer;
      padding: 3px 7px;
      border-radius: 999px;
    }

    .cue-dismiss:hover {
      color: var(--accent);
      background: color-mix(in srgb, var(--ink) 6%, transparent);
    }

    .save-cue {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 2px 8px;
      margin: 0;
      padding: 0 8px;
      color: var(--muted-ink);
      font-size: 0.8rem;
      line-height: 1.5;
    }

    @media (max-width: 480px) {
      .save-long {
        display: none;
      }
    }

    @keyframes thoughtPop {
      0% {
        opacity: 0;
        transform: translateY(8px) scale(0.94);
      }
      100% {
        opacity: 1;
        transform: none;
      }
    }

    .tools-btn.plus-btn.has-save-cue {
      position: relative;
    }

    .tools-btn.plus-btn.has-save-cue::after {
      content: "";
      position: absolute;
      top: 3px;
      right: 3px;
      width: 8px;
      height: 8px;
      border-radius: 999px;
      background: var(--accent);
      box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface) 84%, transparent);
    }

    @keyframes thinkingPulse {
      0% {
        transform: translateY(0);
        opacity: 0.34;
      }
      40% {
        transform: translateY(-2px);
        opacity: 1;
      }
      100% {
        transform: translateY(0);
        opacity: 0.34;
      }
    }

    .conclusion-cta {
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px;
      background: color-mix(in srgb, var(--surface) 85%, var(--bg) 15%);
    }

    .conclusion-cta h3,
    .artifact-card h3 {
      margin: 0;
      font-family: var(--font-serif);
      font-size: 1.4rem;
      font-weight: 600;
      line-height: 1.15;
    }

    .conclusion-cta p,
    .artifact-card p {
      margin: 7px 0 0;
      color: var(--muted-ink);
      font-size: 0.92rem;
    }

    .conclusion-grid {
      display: grid;
      gap: 10px;
      margin-top: 12px;
    }

    .artifact-claims {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      margin-top: 0;
    }

    .conclusion-item h4 {
      margin: 0 0 4px;
      font-size: 0.7rem;
      font-weight: 600;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted-ink);
    }

    .conclusion-item p,
    .conclusion-item ul {
      margin: 0;
      font-size: 0.95rem;
      line-height: 1.58;
    }

    .conclusion-item ul {
      padding-left: 18px;
    }

    .artifact-intro {
      margin: -4px 0 0;
      color: var(--muted-ink);
      font-size: 0.94rem;
      line-height: 1.62;
    }

    .artifact-list {
      margin: 0;
      padding-left: 18px;
      color: var(--ink);
      font-size: 0.95rem;
      line-height: 1.62;
    }

    .artifact-list li + li {
      margin-top: 0.4em;
    }

    .artifact-modal {
      position: fixed;
      inset: 0;
      background: var(--overlay);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      z-index: 45;
    }

    .artifact-modal[hidden] {
      display: none;
    }

    .artifact-card {
      width: min(740px, 100%);
      max-height: min(84vh, 860px);
      overflow-y: auto;
      border: 1px solid var(--border);
      background: var(--surface);
      border-radius: 14px;
      padding: 16px;
      box-shadow: var(--shadow);
      display: grid;
      gap: 12px;
    }

    .artifact-summary {
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 10px;
      background: color-mix(in srgb, var(--surface) 86%, var(--bg) 14%);
    }

    .artifact-summary h4 {
      margin: 0 0 6px;
      font-size: 0.7rem;
      font-weight: 600;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted-ink);
    }

    .conclusion-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 12px;
    }

    .composer {
      display: block;
      width: 100%;
      margin: 0;
      position: sticky;
      bottom: 0;
      z-index: 10;
      padding-top: 8px;
      padding-bottom: calc(10px + env(safe-area-inset-bottom));
      background: linear-gradient(to top, color-mix(in srgb, var(--bg) 98%, transparent), color-mix(in srgb, var(--bg) 68%, transparent));
    }

    .composer-row {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      gap: 8px;
      align-items: center;
      border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
      border-radius: 24px;
      background: color-mix(in srgb, var(--surface) 97%, var(--bg) 3%);
      padding: 10px 12px;
      box-shadow: 0 12px 30px rgba(21, 20, 18, 0.06);
    }

    .composer textarea {
      width: 100%;
      min-height: 72px;
      max-height: 180px;
      resize: none;
      border: 0;
      border-radius: 14px;
      background: transparent;
      color: var(--ink);
      padding: 18px 8px 10px;
      font-size: 1rem;
      font-family: inherit;
      font-weight: 400;
      line-height: 1.5;
      transition: border-color 220ms ease, background-color 220ms ease;
    }

    .composer textarea:focus-visible {
      outline: none;
    }

    .composer textarea::placeholder {
      color: color-mix(in srgb, var(--muted-ink) 85%, transparent);
      font-family: inherit;
      letter-spacing: 0.01em;
    }

    .composer-meta {
      display: grid;
      gap: 8px;
      margin-top: 10px;
    }

    body.mobile-composer-mode .page.chat-active {
      padding-bottom: 0;
    }

    body.mobile-composer-mode .page.chat-active .chat-lane {
      width: min(100%, 760px);
    }

    body.mobile-composer-mode .page.chat-active .composer {
      position: fixed;
      left: 50%;
      bottom: calc(var(--keyboard-offset) + env(safe-area-inset-bottom));
      transform: translateX(-50%);
      width: min(calc(100vw - 24px), 760px);
      max-width: calc(100vw - 24px);
      margin: 0;
      z-index: 20;
      padding-top: 12px;
      padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    body.mobile-composer-mode .page.chat-active .jump-latest-btn {
      right: 0;
      bottom: calc(var(--composer-height) + var(--keyboard-offset) + env(safe-area-inset-bottom) + 14px);
    }

    body.keyboard-open .page.chat-active .plaque {
      margin-bottom: 4px;
    }

    body.keyboard-open .page.chat-active .save-reminder,
    body.keyboard-open .page.chat-active .save-cue {
      display: none !important;
    }

    .send-circle-btn {
      width: 32px;
      height: 32px;
      border: 1px solid var(--primary);
      background: var(--primary);
      color: var(--on-primary);
      font-size: 1rem;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: border-color 220ms ease, background-color 220ms ease;
      border-radius: 999px;
      padding: 0;
    }

    .send-circle-btn:hover:not(:disabled) {
      background: var(--accent);
      border-color: var(--accent);
    }

    .send-circle-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .status {
      min-height: 1.2em;
      margin: 0;
      color: var(--muted-ink);
      font-size: 0.82rem;
    }

    .status:empty {
      display: none;
    }

    .quiet-footer {
      margin-top: 24px;
      border-top: 1px solid var(--border);
      padding-top: 16px;
      color: var(--muted-ink);
      font-size: 0.78rem;
      letter-spacing: 0.02em;
      text-align: center;
      line-height: 1.7;
    }

    .quiet-footer a {
      color: inherit;
      text-decoration-color: color-mix(in srgb, var(--muted-ink) 70%, transparent);
      text-underline-offset: 3px;
    }

    .quiet-footer a:hover {
      color: var(--accent);
      text-decoration-color: currentColor;
    }

    .share-modal {
      position: fixed;
      inset: 0;
      background: var(--overlay);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      z-index: 40;
    }

    .share-modal[hidden] {
      display: none;
    }

    .share-card {
      width: min(440px, 100%);
      border: 1px solid var(--border);
      background: var(--surface);
      border-radius: 14px;
      padding: 16px;
      box-shadow: var(--shadow);
    }

    .share-card h3 {
      margin: 0;
      font-family: var(--font-serif);
      font-size: 1.45rem;
      line-height: 1.15;
      font-weight: 600;
    }

    .share-card p {
      margin: 7px 0 10px;
      color: var(--muted-ink);
      font-size: 0.9rem;
    }

    .format-list {
      display: grid;
      gap: 7px;
      margin-top: 8px;
    }

    .share-labs-text p {
      margin: 8px 0 12px;
      color: var(--muted-ink);
      font-size: 0.9rem;
      text-wrap: pretty;
    }

    .share-labs-status {
      min-height: 1.2em;
      margin: 10px 0 0;
      color: var(--muted-ink);
      font-size: 0.85rem;
    }

    .format-item {
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 8px;
      font-size: 0.9rem;
      display: flex;
      gap: 8px;
      align-items: center;
      background: color-mix(in srgb, var(--surface) 88%, var(--bg) 12%);
    }

    .modal-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 2px;
    }

    .modal-actions a {
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      border: 0;
    }

    .plaque h1 a {
      color: inherit;
      text-decoration: none;
    }

    @media (max-width: 720px) {
      .page {
        padding: 14px 12px 18px;
      }

      .page.chat-active {
        padding: 14px 12px 12px;
      }

      .desk {
        padding: 16px;
        border-radius: 14px;
      }

      .desk.chat-mode {
        padding: 4px 0 14px;
      }

      .plaque {
        flex-direction: column;
        align-items: flex-start;
      }

      .plaque p {
        white-space: normal;
      }

      .tools-drawer {
        width: min(280px, 82vw);
      }

      .stream-shell {
        padding: 0;
      }

      .stream {
        padding-top: 8px;
      }

      .message-row {
        width: 100%;
        max-width: 100%;
      }

      .composer textarea {
        min-height: 64px;
        max-height: 160px;
      }

      .tools-btn.plus-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
      }

      .composer-row {
        gap: 8px;
        border-radius: 22px;
        padding: 8px 10px;
      }

      .jump-latest-btn {
        right: 10px;
        bottom: 10px;
      }

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

      .artifact-claims {
        grid-template-columns: 1fr;
      }

      .modal-actions {
        flex-direction: column;
      }

      .pending-indicator {
        width: 100%;
        max-width: 100%;
      }

      .primary-btn,
      .secondary-btn,
      .tools-btn {
        width: 100%;
      }

      .send-circle-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
      }
    }

    @media (max-width: 720px), (pointer: coarse) {
      body.mobile-composer-mode .page.chat-active .plaque {
        margin-bottom: 8px;
      }

      body.mobile-composer-mode .page.chat-active .desk.chat-mode {
        padding-bottom: 0;
      }

      body.mobile-composer-mode .page.chat-active .stream-shell {
        overflow: visible;
      }

      body.mobile-composer-mode .page.chat-active .composer-row {
        border-radius: 22px;
      }

      body.mobile-composer-mode.keyboard-open .page.chat-active .theme-toggle {
        opacity: 0.7;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }

    /* Was an inline style attribute on two action rows; moved here for the CSP. */
    .conclusion-actions.is-spaced {
      margin-top: 10px;
    }
