:root {
  color-scheme: light;
  --bg: #f2ecd8;
  --panel: #f8f1db;
  --panel-alt: #efe7cf;
  --ink: #071d2a;
  --muted: #49616a;
  --line: #09263a;
  --accent: #7df063;
  --accent-strong: #4bc93f;
  --amber: #9b6a16;
  --amber-bg: #f6e7bf;
  --blue: #1269f3;
  --blue-bg: #e5edf2;
  --assistant: #f6efdc;
  --user: #fff6e8;
  --shadow: 0 8px 0 rgba(7, 29, 42, 0.08);
}

/* R28POSTMERGE4: reduced magazine-like product surface. Dashboard keeps diagnostics. */
body[data-ui-mode="chat"] {
  background: #dce5de;
}

.app-shell[data-ui-mode="chat"] {
  --cover-green: #1f5138;
  --cover-green-deep: #123428;
  --ivory: #eee5c9;
  --ivory-soft: #f6efd8;
  --sage: #9fb4a3;
  --gold: #cfaa5a;
  --paper: #1f5138;
  --paper-soft: #244f39;
  --paper-line: rgba(238, 229, 201, 0.52);
  --ink: #eee5c9;
  --muted: #c9d2c4;
  --line: rgba(238, 229, 201, 0.72);
  --accent: #eee5c9;
  --accent-strong: #cfaa5a;
  --amber: #cfaa5a;
  --amber-bg: rgba(207, 170, 90, 0.14);
  --blue: #9fb4a3;
  --assistant: rgba(246, 239, 216, 0.98);
  --user: rgba(31, 81, 56, 0.88);
  width: min(1320px, 100%);
  padding: clamp(10px, 2.2vw, 28px);
  gap: 10px;
  color: var(--ink);
}

.app-shell[data-ui-mode="chat"] .app-header,
.app-shell[data-ui-mode="chat"] .conversation-pane {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: none;
}

.app-shell[data-ui-mode="chat"] .app-header {
  min-height: auto;
  padding: 12px 16px;
}

.app-shell[data-ui-mode="chat"] .header-copy {
  display: block;
}

.app-shell[data-ui-mode="chat"] .brand-lockup {
  gap: 0;
}

.app-shell[data-ui-mode="chat"] .croc-logo,
.app-shell[data-ui-mode="chat"] h1,
.app-shell[data-ui-mode="chat"] .brand-linework {
  display: none !important;
}

.app-shell[data-ui-mode="chat"] .eyebrow {
  margin: 0;
  color: var(--ivory);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: lowercase;
}

.app-shell[data-ui-mode="chat"] .mode-toggle {
  width: 176px;
  padding: 2px;
  background: transparent;
  border: 1px solid var(--line);
}

.app-shell[data-ui-mode="chat"] .mode-button {
  min-height: 28px;
  color: var(--ivory);
  font-size: 0.72rem;
}

.app-shell[data-ui-mode="chat"] .mode-button.active,
.app-shell[data-ui-mode="chat"] .mode-button:hover,
.app-shell[data-ui-mode="chat"] .mode-button:focus-visible {
  color: var(--cover-green-deep);
  background: var(--ivory);
}

.app-shell[data-ui-mode="chat"] .conversation-pane {
  grid-template-rows: auto auto minmax(0, 2fr) minmax(0, 0.9fr);
  overflow: hidden;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip {
  padding: 12px 14px 0;
  gap: 8px;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div {
  min-height: 30px;
  padding: 6px 9px;
  color: var(--ivory);
  background: transparent;
  border: 1px solid rgba(238, 229, 201, 0.42);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-pass {
  color: var(--ivory);
  background: rgba(238, 229, 201, 0.08);
  border-color: rgba(238, 229, 201, 0.78);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-warn {
  color: var(--gold);
  background: rgba(207, 170, 90, 0.12);
  border-color: rgba(207, 170, 90, 0.78);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip span,
.app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
  font-size: 0.68rem;
}

.app-shell[data-ui-mode="chat"] .model-loading-panel {
  padding: 7px 14px 10px;
  background: var(--paper);
  border-color: var(--paper-line);
}

.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-progress {
  height: 5px;
  background: rgba(238, 229, 201, 0.12);
  border: 1px solid rgba(238, 229, 201, 0.64);
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  color: rgba(238, 229, 201, 0.78);
  font-size: 0.72rem;
  font-weight: 700;
}

.app-shell[data-ui-mode="chat"] .message-list {
  width: min(100%, 940px);
  padding: clamp(18px, 4vw, 42px) clamp(16px, 4vw, 44px) 18px;
}

.app-shell[data-ui-mode="chat"] .message {
  width: min(74%, 660px);
  border: 1px solid rgba(238, 229, 201, 0.78);
  color: var(--cover-green-deep);
  background: var(--assistant);
  box-shadow: -5px 5px 0 rgba(238, 229, 201, 0.16);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  font-weight: 700;
}

.app-shell[data-ui-mode="chat"] .message-user {
  color: var(--ivory);
  background: var(--user);
  box-shadow: 5px 5px 0 rgba(238, 229, 201, 0.1);
}

.app-shell[data-ui-mode="chat"] .message-role {
  color: var(--gold);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: 0.67rem;
}

.app-shell[data-ui-mode="chat"] .composer {
  width: min(100%, 940px);
  padding: 14px clamp(16px, 4vw, 44px) clamp(14px, 3vw, 28px);
  border-top: 1px solid rgba(238, 229, 201, 0.5);
  background: var(--paper);
}

.app-shell[data-ui-mode="chat"] textarea {
  color: var(--ivory);
  background: rgba(18, 52, 40, 0.38);
  border: 1px solid rgba(238, 229, 201, 0.76);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-weight: 700;
}

.app-shell[data-ui-mode="chat"] textarea::placeholder {
  color: rgba(238, 229, 201, 0.54);
}

.app-shell[data-ui-mode="chat"] textarea:focus {
  border-color: var(--ivory);
  box-shadow: 4px 4px 0 rgba(238, 229, 201, 0.16);
}

.app-shell[data-ui-mode="chat"] #send-button {
  min-height: 48px;
  color: var(--cover-green-deep);
  background: var(--ivory);
  border-color: var(--ivory);
}

.app-shell[data-ui-mode="dashboard"] {
  background: #f1ead6;
}

.app-shell[data-ui-mode="dashboard"] .app-header,
.app-shell[data-ui-mode="dashboard"] .status-grid,
.app-shell[data-ui-mode="dashboard"] .conversation-pane,
.app-shell[data-ui-mode="dashboard"] .process-panel {
  box-shadow: none;
}

@media (max-width: 720px) {
  .app-shell[data-ui-mode="chat"] {
    padding: 0;
  }

  .app-shell[data-ui-mode="chat"] .app-header {
    padding: 10px 12px;
    border-top: 0;
  }

  .app-shell[data-ui-mode="chat"] .conversation-pane {
    grid-template-rows: auto auto minmax(0, 2fr) minmax(0, 0.9fr);
  }

  .app-shell[data-ui-mode="chat"] .message-list,
  .app-shell[data-ui-mode="chat"] .composer {
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-shell[data-ui-mode="chat"] .message {
    width: min(86%, 520px);
  }

  .app-shell[data-ui-mode="chat"] .composer-actions {
    right: 24px;
    bottom: 24px;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", sans-serif;
}

body[data-ui-mode="chat"] {
  background: #dce5de;
}

body[data-ui-mode="dashboard"] {
  overflow-y: auto;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 18px;
  overflow: hidden;
}

.app-header,
.status-grid,
.conversation-pane,
.process-panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  min-height: 86px;
}

.header-copy {
  min-width: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.croc-logo {
  flex: 0 0 auto;
  width: clamp(58px, 7vw, 88px);
  height: auto;
  color: var(--accent);
}

.croc-body {
  fill: currentColor;
}

.croc-mark {
  fill: none;
  stroke: var(--line);
  stroke-width: 5;
  stroke-linecap: square;
  stroke-linejoin: round;
}

.croc-eye {
  fill: var(--line);
}

.header-side {
  display: grid;
  justify-items: end;
  gap: 10px;
  min-width: 280px;
}

.brand-linework {
  display: grid;
  grid-template-columns: 90px 22px 12px 42px;
  gap: 8px;
  align-items: center;
  width: min(210px, 100%);
  margin-top: 16px;
}

.brand-linework span {
  display: block;
  height: 8px;
  border: 2px solid var(--line);
  background: transparent;
}

.brand-linework span:nth-child(2),
.brand-linework span:nth-child(4) {
  background: var(--accent);
}

.brand-linework span:nth-child(3) {
  height: 22px;
}

.chat-subtitle {
  max-width: 700px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.45;
}

.mode-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  width: min(240px, 100%);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
}

.mode-button {
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 0;
  color: var(--accent-strong);
  background: transparent;
  font-size: 0.84rem;
}

.mode-button:hover,
.mode-button:focus-visible,
.mode-button.active {
  color: #ffffff;
  background: var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3.8rem);
  line-height: 1.25;
  font-weight: 950;
  text-transform: uppercase;
}

h2 {
  font-size: 1.08rem;
}

h3 {
  font-size: 0.92rem;
}

.header-warning {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--amber);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.45;
}

.header-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 620px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 260px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.8rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.badge-local {
  color: var(--ink);
  border-color: var(--accent-strong);
  background: #e9ffd9;
}

.badge-backend,
.badge-warn {
  color: var(--amber);
  border-color: #e3c07e;
  background: var(--amber-bg);
}

.badge-version {
  color: var(--blue);
  border-color: var(--blue);
  background: #ecf3ff;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  margin-top: 14px;
  overflow: hidden;
}

.status-grid > div,
.compact-status > div,
.answer-status-card > div,
.debug-grid > div {
  min-width: 0;
  padding: 11px 13px;
  border-right: 1px solid var(--line);
}

.status-grid > div:last-child,
.compact-status > div:last-child,
.answer-status-card > div:last-child,
.debug-grid > div:last-child {
  border-right: 0;
}

.status-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

strong {
  display: block;
  min-width: 0;
  font-size: 0.88rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
  height: calc(100dvh - 130px);
  min-height: 0;
}

.app-shell[data-ui-mode="chat"] {
  --panel: #1f5138;
  --panel-alt: #244f39;
  --ink: #eee5c9;
  --muted: #c9d2c4;
  --line: rgba(238, 229, 201, 0.72);
  --accent: #eee5c9;
  --accent-strong: #cfaa5a;
  --amber: #cfaa5a;
  --amber-bg: rgba(207, 170, 90, 0.14);
  --blue: #9fb4a3;
  --blue-bg: rgba(159, 180, 163, 0.16);
  --assistant: rgba(246, 239, 216, 0.98);
  --user: rgba(31, 81, 56, 0.88);
  --shadow: none;
  width: min(1360px, 100%);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  color: var(--ink);
}

.app-shell[data-ui-mode="chat"] .dashboard-only {
  display: none !important;
}

.app-shell[data-ui-mode="dashboard"] {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

.app-shell[data-ui-mode="dashboard"] .chat-only {
  display: none !important;
}

.app-shell[data-ui-mode="chat"] .chat-subtitle,
.app-shell[data-ui-mode="chat"] .header-warning,
.app-shell[data-ui-mode="chat"] .header-badges {
  display: none !important;
}

.app-shell[data-ui-mode="chat"] .workspace-grid {
  display: block;
  min-height: 0;
  height: 100%;
  margin-top: 0;
}

.app-shell[data-ui-mode="chat"] .conversation-pane {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  grid-template-rows: auto auto minmax(0, 2fr) minmax(0, 0.9fr);
}

.app-shell[data-ui-mode="chat"] .app-header,
.app-shell[data-ui-mode="chat"] .conversation-pane {
  background: var(--panel);
  border-color: var(--line);
}

.app-shell[data-ui-mode="chat"] .app-header {
  align-items: center;
  min-height: 128px;
  padding: 20px 22px;
}

.app-shell[data-ui-mode="chat"] .header-copy {
  display: grid;
  gap: 14px;
}

.app-shell[data-ui-mode="chat"] h1 {
  font-size: clamp(2.4rem, 5.2vw, 5.4rem);
  line-height: 0.9;
}

.app-shell[data-ui-mode="chat"] .eyebrow {
  color: var(--accent);
}

.app-shell[data-ui-mode="chat"] .mode-toggle {
  background: transparent;
  border-color: var(--line);
}

.app-shell[data-ui-mode="chat"] .mode-button {
  color: var(--accent);
}

.app-shell[data-ui-mode="chat"] .mode-button.active,
.app-shell[data-ui-mode="chat"] .mode-button:hover,
.app-shell[data-ui-mode="chat"] .mode-button:focus-visible {
  color: #123428;
  background: var(--accent);
}

.app-shell[data-ui-mode="chat"] .brand-linework span {
  border-color: var(--line);
}

.app-shell[data-ui-mode="dashboard"] {
  width: min(1440px, 100%);
}

.app-shell[data-ui-mode="dashboard"] .workspace-grid {
  height: auto;
  min-height: calc(100dvh - 130px);
  align-items: start;
}

.app-shell[data-ui-mode="dashboard"] .conversation-pane,
.app-shell[data-ui-mode="dashboard"] .process-panel {
  height: auto;
  min-height: calc(100dvh - 210px);
  overflow: visible;
}

.app-shell[data-ui-mode="dashboard"] .chat-intro {
  border-bottom: 1px solid var(--line);
}

.conversation-pane {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 2.5fr) auto minmax(118px, 1fr);
  overflow: hidden;
}

.chat-intro {
  display: grid;
  gap: 10px;
  padding: 17px 18px 14px;
  background: var(--panel-alt);
}

.chat-intro p {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.48;
}

.chat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-signal-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 18px 0;
}

.chat-signal-strip div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 2px solid var(--line);
  background: var(--panel-alt);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip {
  gap: 8px;
  padding: 12px 18px 0;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div {
  border-width: 1px;
  color: var(--ink);
  background: transparent;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-pass {
  color: var(--accent);
  background: rgba(238, 229, 201, 0.08);
  border-color: var(--accent);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-warn {
  color: var(--amber);
  background: #21190c;
  border-color: var(--amber);
}

.chat-signal-strip div.is-pass {
  background: #e9ffd9;
  border-color: var(--accent-strong);
}

.chat-signal-strip div.is-warn {
  background: var(--amber-bg);
  border-color: #e3c07e;
}

.chat-signal-strip span,
.chat-signal-strip strong {
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.chat-signal-strip span {
  color: var(--accent-strong);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-pass {
  color: var(--accent);
  background: #111d13;
  border-color: var(--accent);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-warn {
  color: var(--amber);
  background: #21190c;
  border-color: var(--amber);
}

.model-loading-panel {
  display: grid;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.app-shell[data-ui-mode="chat"] .model-loading-panel {
  display: block;
  padding: 8px 18px 12px;
  background: var(--panel);
  border-color: rgba(220, 232, 223, 0.45);
}

.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-progress {
  height: 8px;
  border-color: var(--line);
  background: #080b0d;
}

.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-head,
.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-stages,
.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-completion-summary,
.app-shell[data-ui-mode="chat"] .model-loading-panel .q4-retry-status,
.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-skeleton {
  display: none !important;
}

.chat-loading-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.35;
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  color: var(--muted);
}

.model-loading-panel[data-loading-result="passed"] .loading-progress span {
  background: var(--accent);
}

.model-loading-panel[data-loading-result="blocked"] .loading-progress span,
.model-loading-panel[data-loading-result="failed"] .loading-progress span {
  background: var(--amber);
}

.model-loading-panel[data-loading-result="checking"] .loading-progress span {
  background: var(--blue);
}

.model-loading-panel[hidden] {
  display: none;
}

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

.loading-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.loading-progress {
  height: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-alt);
}

.loading-progress span {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.loading-stages {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loading-stages li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  line-height: 1.25;
}

.loading-stages li span {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border: 1px solid #8fa5a8;
  border-radius: 50%;
  background: #ffffff;
}

.loading-stages li.active {
  color: var(--accent-strong);
}

.loading-stages li.active span {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(19, 116, 111, 0.14);
}

.loading-stages li.done {
  color: var(--blue);
}

.loading-stages li.done span {
  border-color: var(--blue);
  background: var(--blue);
}

.loading-stages li.warn {
  color: var(--amber);
}

.loading-stages li.warn span {
  border-color: var(--amber);
  background: var(--amber);
}

.q4-retry-status {
  margin: 0;
  min-height: 22px;
  color: var(--amber);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.loading-completion-summary {
  margin: 0;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.loading-completion-summary.warn {
  color: var(--amber);
}

.loading-completion-summary.done {
  color: var(--accent-strong);
}

.loading-skeleton {
  display: grid;
  gap: 7px;
  width: min(420px, 100%);
}

.loading-skeleton.is-complete {
  display: none;
}

.loading-skeleton span {
  height: 9px;
  border-radius: 999px;
  background: var(--panel-alt);
  animation: loading-sheen 1.2s ease-in-out infinite;
}

.loading-skeleton span:nth-child(2) {
  width: 72%;
}

.loading-skeleton span:nth-child(3) {
  width: 46%;
}

@keyframes loading-sheen {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

.compact-status,
.answer-status-card,
.debug-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--panel-alt);
  border-bottom: 1px solid var(--line);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 16px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-shell[data-ui-mode="chat"] .message-list {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 18px 14px;
}

.message {
  width: min(72%, 680px);
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  line-height: 1.48;
  font-size: 1rem;
  font-weight: 760;
}

.app-shell[data-ui-mode="chat"] .message {
  width: min(74%, 740px);
  border-width: 1px;
  color: var(--ink);
  background: var(--assistant);
}

.message p {
  margin: 0;
}

.message-footer {
  display: none;
}

.message-role {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.message-assistant {
  align-self: flex-start;
  background: var(--assistant);
  box-shadow: -5px 5px 0 rgba(126, 240, 99, 0.35);
}

.app-shell[data-ui-mode="chat"] .message-assistant {
  box-shadow: -5px 5px 0 rgba(120, 239, 99, 0.28);
}

.message-user {
  align-self: flex-end;
  background: var(--user);
  box-shadow: 5px 5px 0 rgba(18, 105, 243, 0.18);
}

.app-shell[data-ui-mode="chat"] .message-user {
  color: #f8fbfa;
  background: var(--user);
  box-shadow: 5px 5px 0 rgba(122, 167, 255, 0.18);
}

.app-shell[data-ui-mode="chat"] .message-role {
  color: var(--accent);
}

.composer {
  position: relative;
  display: block;
  padding: 14px;
  border-top: 2px solid var(--line);
  background: var(--panel);
  min-height: 0;
}

.app-shell[data-ui-mode="chat"] .composer {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 16px 18px;
  border-top: 1px solid rgba(220, 232, 223, 0.6);
  background: var(--panel);
}

.composer-actions {
  position: absolute;
  right: 28px;
  bottom: 28px;
  display: block;
}

.app-shell[data-ui-mode="chat"] .composer-actions {
  right: 34px;
  bottom: 32px;
}

.context-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.composer-actions [hidden] {
  display: none !important;
}

#send-button {
  width: 132px;
  min-height: 48px;
}

.app-shell[data-ui-mode="chat"] #send-button {
  min-height: 54px;
  color: #123428;
  background: var(--accent);
  border-color: var(--line);
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  resize: none;
  padding: 12px 154px 12px 13px;
  border: 2px solid var(--line);
  border-radius: 0;
  outline: none;
  color: var(--ink);
  background: #fffaf0;
  font-size: 1rem;
  font-weight: 760;
}

.app-shell[data-ui-mode="chat"] textarea {
  color: var(--ink);
  background: #0b0f12;
  border-width: 1px;
  border-color: var(--line);
}

.app-shell[data-ui-mode="chat"] textarea::placeholder {
  color: #7f8d8f;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 4px 4px 0 rgba(126, 240, 99, 0.45);
}

.app-shell[data-ui-mode="chat"] textarea:focus {
  border-color: var(--accent);
  box-shadow: 4px 4px 0 rgba(120, 239, 99, 0.26);
}

button {
  min-width: 92px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--accent);
  font-weight: 850;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--blue);
  color: #ffffff;
}

button:disabled {
  color: #7b878b;
  background: #e3e8ea;
  cursor: not-allowed;
}

.button-secondary {
  color: var(--ink);
  background: var(--panel-alt);
  border: 2px solid var(--line);
}

.button-secondary:hover,
.button-secondary:focus-visible {
  color: #ffffff;
}

.small-button {
  min-width: 150px;
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.process-panel {
  height: 100%;
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

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

.self-check-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.self-check {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-bg);
}

.self-check div {
  min-width: 0;
}

.self-check span {
  display: block;
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 850;
}

.self-check p {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.reasoning-viz {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
}

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

.reasoning-viz-head strong {
  color: var(--blue);
  text-align: right;
}

.viz-bars {
  display: grid;
  gap: 10px;
}

.viz-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 92px;
  gap: 9px;
  align-items: center;
}

.viz-row span,
.viz-row strong {
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.2;
}

.viz-row span {
  color: var(--muted);
}

.viz-row strong {
  color: var(--ink);
  text-align: right;
}

.viz-track {
  height: 12px;
  border: 1px solid var(--line);
  background: var(--panel-alt);
}

.viz-track i {
  display: block;
  width: 8%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.viz-row.is-warn .viz-track i {
  background: var(--amber);
}

.viz-row.is-blue .viz-track i {
  background: var(--blue);
}

.viz-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.viz-flow span {
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.trace-steps {
  display: grid;
  gap: 9px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.process-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.step-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-weight: 850;
}

.process-step p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.context-bridge,
.debug-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.context-bridge + .debug-panel {
  margin-top: 10px;
}

summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
  cursor: pointer;
}

.context-bridge-body {
  display: grid;
  gap: 9px;
  padding: 0 12px 12px;
}

.context-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.context-actions button,
.composer-actions button {
  min-width: 0;
  width: 100%;
}

#context-validation {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.debug-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.debug-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.debug-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.debug-grid > div:nth-child(2n) {
  border-right: 0;
}

.debug-grid > div:nth-child(-n + 6) {
  border-bottom: 1px solid var(--line);
}

#debug-output {
  max-height: 260px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: #213133;
  background: #f1f5f5;
  font-size: 0.8rem;
  line-height: 1.45;
}

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

@media (max-width: 1080px) {
  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-grid > div:nth-child(3n) {
    border-right: 0;
  }

  .status-grid > div:nth-child(-n + 6) {
    border-bottom: 1px solid var(--line);
  }

  .workspace-grid {
    grid-template-columns: 1fr;
    height: calc(100dvh - 130px);
  }

  .app-shell[data-ui-mode="dashboard"] .workspace-grid {
    display: grid;
    height: auto;
  }

  .conversation-pane,
  .process-panel {
    min-height: 0;
  }

  .process-panel {
    order: 2;
  }

  .app-shell[data-ui-mode="dashboard"] .conversation-pane,
  .app-shell[data-ui-mode="dashboard"] .process-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0;
    height: 100dvh;
  }

  .app-header,
  .status-grid,
  .conversation-pane,
  .process-panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .app-header {
    min-height: 64px;
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
  }

  .brand-lockup {
    gap: 8px;
  }

  .croc-logo {
    width: 42px;
  }

  .app-header h1 {
    font-size: 1.45rem;
  }

  .brand-linework {
    display: none;
  }

  .app-header .eyebrow {
    margin-bottom: 0;
    font-size: 0.62rem;
  }

  .header-side {
    display: none;
  }

  .mode-toggle {
    display: none;
  }

  .header-badges {
    justify-content: flex-start;
  }

  .app-shell[data-ui-mode="chat"] .workspace-grid {
    height: auto;
    min-height: 0;
    margin-top: 0;
  }

  .app-shell[data-ui-mode="chat"] .conversation-pane {
    height: 100%;
    border-bottom: 0;
    grid-template-rows: auto auto minmax(0, 2fr) minmax(0, 0.9fr);
  }

  .app-shell[data-ui-mode="chat"] .model-loading-panel {
    padding: 7px 12px;
  }

  .chat-signal-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 7px 10px 0;
  }

  .chat-signal-strip div {
    padding: 6px 5px;
  }

  .chat-signal-strip span {
    display: none;
  }

  .chat-signal-strip strong {
    font-size: 0.64rem;
    text-align: center;
  }

  .status-grid,
  .compact-status,
  .answer-status-card,
  .debug-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-grid > div:nth-child(2n),
  .compact-status > div:nth-child(2n),
  .answer-status-card > div:nth-child(2n),
  .debug-grid > div:nth-child(2n) {
    border-right: 0;
  }

  .status-grid > div,
  .compact-status > div,
  .answer-status-card > div,
  .debug-grid > div {
    border-bottom: 1px solid var(--line);
  }

  .message {
    width: min(88%, 100%);
    padding: 11px 12px;
    font-size: 0.96rem;
  }

  .chat-intro,
  .model-loading-panel {
    padding-left: 14px;
    padding-right: 14px;
  }

  .loading-head {
    display: grid;
  }

  .loading-stages {
    grid-template-columns: 1fr;
  }

  .composer {
    min-height: 0;
    padding: 10px;
  }

  .app-shell[data-ui-mode="chat"] .composer {
    width: 100%;
    padding: 10px 12px;
  }

  .composer-actions {
    right: 18px;
    bottom: 18px;
  }

  .app-shell[data-ui-mode="chat"] .composer-actions {
    right: 20px;
    bottom: 20px;
  }

  textarea {
    min-height: 0;
    padding-right: 112px;
    resize: none;
  }

  button {
    min-width: 0;
    min-height: 52px;
    padding: 0 8px;
  }

  #send-button {
    width: 92px;
  }

  .self-check {
    grid-template-columns: 1fr;
  }

  .viz-row {
    grid-template-columns: 42px minmax(0, 1fr) 72px;
  }

  .viz-flow {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .viz-flow span {
    padding: 6px 3px;
    font-size: 0.62rem;
  }

  .panel-head {
    flex-direction: column;
  }

  .self-check-actions {
    width: 100%;
  }

  .small-button {
    width: 100%;
  }
}

/* R28POSTMERGE5: accessibility and Safari fit pass.
   Palette follows the user's color reference:
   GrassLand #C4CD23, SheepWhite #F0EDE5, BlueSky #AFC7E6, YellowFlower #FEDB00. */
body[data-ui-mode="chat"] {
  background: #dbe4dd;
}

.app-shell[data-ui-mode="chat"] {
  --grassland: #c4cd23;
  --sheep-white: #f0ede5;
  --blue-sky: #afc7e6;
  --yellow-flower: #fedb00;
  --cover-green: #1d593d;
  --cover-green-deep: #0a1515;
  --cover-green-mid: #173d2c;
  --ink: #f0ede5;
  --muted: #dce4d9;
  --line: #f0ede5;
  --accent: #c4cd23;
  --accent-strong: #fedb00;
  --amber: #d9b95d;
  --panel: #1d593d;
  --panel-alt: #183f2d;
  --assistant: #f0ede5;
  --user: #142d25;
  font-family: "Bodoni 72", Didot, Georgia, "Times New Roman", "Songti SC", "STSong", serif;
}

.app-shell[data-ui-mode="chat"] .app-header,
.app-shell[data-ui-mode="chat"] .conversation-pane {
  color: var(--sheep-white);
  background: var(--cover-green);
  border-color: rgba(240, 237, 229, 0.78);
}

.app-shell[data-ui-mode="chat"] .app-header {
  min-height: clamp(118px, 14vh, 186px);
  padding: clamp(22px, 3.2vw, 42px);
}

.app-shell[data-ui-mode="chat"] .eyebrow {
  color: var(--sheep-white);
  font-family: "Bodoni 72", Didot, Georgia, "Times New Roman", serif;
  font-size: clamp(1.15rem, 1.8vw, 1.75rem);
  font-weight: 900;
  line-height: 1.1;
}

.app-shell[data-ui-mode="chat"] .mode-toggle {
  width: min(320px, 42vw);
  border-color: var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .mode-button {
  min-height: 46px;
  color: var(--sheep-white);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: clamp(1rem, 1.2vw, 1.25rem);
  font-weight: 900;
}

.app-shell[data-ui-mode="chat"] .mode-button.active,
.app-shell[data-ui-mode="chat"] .mode-button:hover,
.app-shell[data-ui-mode="chat"] .mode-button:focus-visible {
  color: #10231c;
  background: var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip {
  padding: clamp(16px, 2vw, 26px) clamp(20px, 3vw, 42px) 0;
  gap: clamp(10px, 1.4vw, 18px);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div {
  min-height: 56px;
  padding: 12px 16px;
  color: var(--sheep-white);
  background: var(--cover-green-deep);
  border: 2px solid var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-pass {
  color: var(--sheep-white);
  background: #12291f;
  border-color: var(--grassland);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-warn {
  color: var(--yellow-flower);
  background: #21190c;
  border-color: #d8b654;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip span,
.app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
  color: inherit;
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: clamp(1rem, 1.35vw, 1.32rem);
  font-weight: 950;
  line-height: 1.08;
}

.app-shell[data-ui-mode="chat"] .model-loading-panel {
  padding: 12px clamp(20px, 3vw, 42px) 18px;
  background: var(--cover-green);
  border-color: rgba(240, 237, 229, 0.58);
}

.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-progress {
  height: 13px;
  background: #0a1515;
  border: 2px solid var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .model-loading-panel[data-loading-result="passed"] .loading-progress span,
.app-shell[data-ui-mode="chat"] .loading-progress span {
  background: var(--grassland);
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  margin-top: 14px;
  color: var(--sheep-white);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: clamp(1.18rem, 1.6vw, 1.55rem);
  font-weight: 900;
  line-height: 1.38;
}

.app-shell[data-ui-mode="chat"] .message-list {
  width: min(100%, 1050px);
  gap: clamp(22px, 3vw, 36px);
  padding: clamp(28px, 4vw, 58px) clamp(24px, 5vw, 64px) 20px;
}

.app-shell[data-ui-mode="chat"] .message {
  width: min(78%, 820px);
  min-height: 92px;
  padding: clamp(22px, 2.3vw, 34px) clamp(24px, 3vw, 42px);
  border: 2px solid rgba(240, 237, 229, 0.86);
  color: #143524;
  background: var(--sheep-white);
  box-shadow: -10px 10px 0 rgba(196, 205, 35, 0.28);
  font-family: "Bodoni 72", Didot, Georgia, "Times New Roman", "Songti SC", "STSong", serif;
  font-size: clamp(1.75rem, 2.15vw, 2.5rem);
  font-weight: 900;
  line-height: 1.28;
}

.app-shell[data-ui-mode="chat"] .message-user {
  color: var(--sheep-white);
  background: #16392a;
  box-shadow: 10px 10px 0 rgba(175, 199, 230, 0.22);
}

.app-shell[data-ui-mode="chat"] .message-role {
  margin-bottom: 12px;
  color: #2e6a3f;
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: clamp(0.98rem, 1.1vw, 1.24rem);
  font-weight: 950;
}

.app-shell[data-ui-mode="chat"] .message-user .message-role {
  color: var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .composer {
  width: min(100%, 1050px);
  padding: clamp(18px, 2.4vw, 30px) clamp(24px, 5vw, 64px);
  border-top: 2px solid rgba(240, 237, 229, 0.62);
  background: var(--cover-green);
}

.app-shell[data-ui-mode="chat"] textarea {
  color: var(--sheep-white);
  background: #0a1515;
  border: 2px solid rgba(240, 237, 229, 0.86);
  font-family: "Bodoni 72", Didot, Georgia, "Times New Roman", "Songti SC", "STSong", serif;
  font-size: clamp(1.55rem, 1.9vw, 2.1rem);
  font-weight: 900;
  line-height: 1.28;
}

.app-shell[data-ui-mode="chat"] textarea::placeholder {
  color: #9aa8a4;
  opacity: 1;
}

.app-shell[data-ui-mode="chat"] #send-button {
  min-height: 72px;
  min-width: 156px;
  color: #10231c;
  background: var(--sheep-white);
  border: 2px solid var(--sheep-white);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: clamp(1.32rem, 1.55vw, 1.7rem);
  font-weight: 950;
}

@media (max-width: 720px) {
  html,
  body {
    min-height: -webkit-fill-available;
  }

  body {
    overflow: hidden;
  }

  .app-shell[data-ui-mode="chat"] {
    width: 100%;
    height: 100svh;
    min-height: -webkit-fill-available;
    padding: env(safe-area-inset-top) 0 max(env(safe-area-inset-bottom), 10px);
    gap: 8px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-shell[data-ui-mode="chat"] .app-header {
    min-height: clamp(96px, 19svh, 148px);
    padding: clamp(20px, 7vw, 34px) clamp(22px, 6vw, 30px);
  }

  .app-shell[data-ui-mode="chat"] .eyebrow {
    font-size: clamp(1.45rem, 7vw, 2rem);
  }

  .app-shell[data-ui-mode="chat"] .mode-toggle {
    display: none;
  }

  .app-shell[data-ui-mode="chat"] .conversation-pane {
    height: 100%;
    min-height: 0;
    border-top: 2px solid var(--sheep-white);
    border-bottom: 0;
    grid-template-rows: auto auto minmax(0, 2fr) minmax(150px, 0.9fr);
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 14px 14px 0;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip div {
    min-height: 56px;
    padding: 9px 8px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip span {
    display: none;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
    display: block;
    font-size: clamp(0.95rem, 4.3vw, 1.25rem);
    text-align: center;
  }

  .app-shell[data-ui-mode="chat"] .model-loading-panel {
    padding: 10px 14px 16px;
  }

  .app-shell[data-ui-mode="chat"] .chat-loading-note {
    font-size: clamp(1.2rem, 5vw, 1.5rem);
  }

  .app-shell[data-ui-mode="chat"] .message-list {
    width: 100%;
    padding: 26px 24px 18px;
    gap: 22px;
  }

  .app-shell[data-ui-mode="chat"] .message {
    width: min(88%, 100%);
    min-height: 112px;
    padding: 22px 24px;
    font-size: clamp(1.75rem, 7.2vw, 2.3rem);
    line-height: 1.24;
  }

  .app-shell[data-ui-mode="chat"] .message-role {
    font-size: clamp(0.92rem, 3.7vw, 1.1rem);
  }

  .app-shell[data-ui-mode="chat"] .composer {
    width: 100%;
    padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  }

  .app-shell[data-ui-mode="chat"] textarea {
    min-height: 100%;
    padding: 22px 134px 22px 22px;
    font-size: clamp(1.35rem, 5.6vw, 1.75rem);
  }

  .app-shell[data-ui-mode="chat"] .composer-actions {
    right: 34px;
    bottom: calc(34px + env(safe-area-inset-bottom));
  }

  .app-shell[data-ui-mode="chat"] #send-button {
    width: 112px;
    min-width: 112px;
    min-height: 70px;
    font-size: clamp(1.18rem, 5vw, 1.45rem);
  }
}

/* R28POSTMERGE6: Safari-safe product palette and legibility floor.
   Reference palette:
   GrassLand #C4CD23, SheepWhite #F0EDE5, BlueSky #AFC7E6, YellowFlower #FEDB00. */
html {
  background: #afc7e6;
}

body[data-ui-mode="chat"] {
  min-height: 100%;
  color: #f0ede5;
  background: #afc7e6;
  font-size: 18px;
}

.app-shell[data-ui-mode="chat"] {
  --grassland: #c4cd23;
  --sheep-white: #f0ede5;
  --blue-sky: #afc7e6;
  --yellow-flower: #fedb00;
  --cover-green: #1e5a3d;
  --cover-green-deep: #071111;
  --cover-green-mid: #143b2a;
  --cover-green-soft: #246644;
  --ink: #f0ede5;
  --muted: #d8ddd5;
  --line: rgba(240, 237, 229, 0.86);
  --accent: #c4cd23;
  --accent-strong: #fedb00;
  --amber: #d8b85e;
  --panel: #1e5a3d;
  --panel-alt: #173d2c;
  --assistant: #f0ede5;
  --user: #122f24;
  width: min(1480px, calc(100% - 56px));
  color: var(--sheep-white);
  background: transparent;
  font-family: "Bodoni 72", Didot, Georgia, "Times New Roman", "Songti SC", "STSong", serif;
}

.app-shell[data-ui-mode="chat"] .app-header,
.app-shell[data-ui-mode="chat"] .conversation-pane {
  color: var(--sheep-white);
  background: var(--cover-green);
  border: 2px solid var(--line);
}

.app-shell[data-ui-mode="chat"] .app-header {
  min-height: clamp(132px, 14svh, 190px);
  padding: clamp(28px, 3vw, 48px);
}

.app-shell[data-ui-mode="chat"] .eyebrow {
  color: var(--sheep-white);
  font-size: clamp(1.55rem, 1.9vw, 2rem);
  font-weight: 900;
  line-height: 1.08;
}

.app-shell[data-ui-mode="chat"] .mode-toggle {
  width: min(360px, 40vw);
  border: 2px solid var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .mode-button {
  min-height: 54px;
  color: var(--sheep-white);
  font-size: clamp(1.05rem, 1.15vw, 1.35rem);
  font-weight: 950;
}

.app-shell[data-ui-mode="chat"] .mode-button.active {
  color: #10261c;
  background: var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .conversation-pane {
  grid-template-rows: auto auto minmax(0, 2fr) minmax(180px, 0.9fr);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div {
  min-height: 64px;
  color: var(--sheep-white);
  background: #0d1a16;
  border: 2px solid rgba(240, 237, 229, 0.9);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-pass {
  color: var(--sheep-white);
  border-color: var(--grassland);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div.is-warn {
  color: var(--amber);
  background: #251a0a;
  border-color: var(--amber);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip strong,
.app-shell[data-ui-mode="chat"] .chat-signal-strip span {
  color: inherit;
  font-size: clamp(1.12rem, 1.25vw, 1.45rem);
  font-weight: 950;
}

.app-shell[data-ui-mode="chat"] .model-loading-panel {
  background: var(--cover-green);
  border-color: rgba(240, 237, 229, 0.62);
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  color: var(--muted);
  font-size: clamp(1.35rem, 1.55vw, 1.8rem);
  font-weight: 900;
}

.app-shell[data-ui-mode="chat"] .message-list {
  min-height: 0;
  padding: clamp(36px, 4vw, 64px) clamp(38px, 6vw, 84px) 26px;
}

.app-shell[data-ui-mode="chat"] .message {
  width: min(76%, 860px);
  min-height: 114px;
  padding: clamp(26px, 2.5vw, 42px) clamp(30px, 3.2vw, 50px);
  color: #10261c !important;
  background: var(--sheep-white);
  border: 2px solid var(--sheep-white);
  box-shadow: -10px 10px 0 rgba(196, 205, 35, 0.32);
  font-size: clamp(2rem, 2.35vw, 3rem);
  font-weight: 900;
  line-height: 1.26;
}

.app-shell[data-ui-mode="chat"] .message-user {
  color: var(--sheep-white) !important;
  background: var(--user);
  border-color: rgba(240, 237, 229, 0.82);
  box-shadow: 10px 10px 0 rgba(175, 199, 230, 0.28);
}

.app-shell[data-ui-mode="chat"] .message-role {
  color: #1e5a3d;
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: clamp(1.06rem, 1.05vw, 1.32rem);
  font-weight: 950;
}

.app-shell[data-ui-mode="chat"] .message-user .message-role {
  color: var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .composer {
  min-height: 0;
  padding: clamp(22px, 2.4vw, 34px) clamp(38px, 6vw, 84px);
  background: var(--cover-green);
  border-top: 2px solid rgba(240, 237, 229, 0.7);
}

.app-shell[data-ui-mode="chat"] textarea {
  color: var(--sheep-white);
  background: #071111;
  border: 2px solid rgba(240, 237, 229, 0.9);
  font-size: clamp(1.75rem, 2vw, 2.35rem);
  font-weight: 900;
  line-height: 1.26;
}

.app-shell[data-ui-mode="chat"] textarea::placeholder {
  color: rgba(240, 237, 229, 0.68);
}

.app-shell[data-ui-mode="chat"] #send-button {
  min-width: 170px;
  min-height: 78px;
  color: #10261c;
  background: var(--sheep-white);
  border-color: var(--sheep-white);
  font-size: clamp(1.4rem, 1.55vw, 1.85rem);
  font-weight: 950;
}

@media (max-width: 720px) {
  html {
    min-height: 100%;
    background: #afc7e6;
  }

  body[data-ui-mode="chat"] {
    width: 100%;
    height: 100svh;
    min-height: 100svh;
    max-height: 100svh;
    overflow: hidden;
    background: #afc7e6;
    -webkit-text-size-adjust: 100%;
  }

  @supports (height: 100dvh) {
    body[data-ui-mode="chat"] {
      height: min(100dvh, 100svh);
      max-height: min(100dvh, 100svh);
    }
  }

  .app-shell[data-ui-mode="chat"] {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    padding: max(env(safe-area-inset-top), 0px) 0 max(env(safe-area-inset-bottom), 10px);
    gap: 8px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-shell[data-ui-mode="chat"] .app-header {
    min-height: clamp(98px, 17svh, 136px);
    padding: clamp(24px, 7vw, 34px) clamp(24px, 7vw, 34px);
    border-left: 0;
    border-right: 0;
  }

  .app-shell[data-ui-mode="chat"] .eyebrow {
    font-size: clamp(1.62rem, 7.3vw, 2.18rem);
  }

  .app-shell[data-ui-mode="chat"] .conversation-pane {
    height: 100%;
    min-height: 0;
    border-left: 0;
    border-right: 0;
    grid-template-rows: auto auto minmax(0, 2fr) minmax(142px, 0.9fr);
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip {
    gap: 8px;
    padding: 14px 14px 0;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip div {
    min-height: 58px;
    padding: 9px 8px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
    font-size: clamp(1rem, 4.8vw, 1.34rem);
  }

  .app-shell[data-ui-mode="chat"] .model-loading-panel {
    padding: 10px 14px 14px;
  }

  .app-shell[data-ui-mode="chat"] .model-loading-panel .loading-progress {
    height: 10px;
  }

  .app-shell[data-ui-mode="chat"] .chat-loading-note {
    margin-top: 12px;
    font-size: clamp(1.22rem, 5.4vw, 1.58rem);
    line-height: 1.34;
  }

  .app-shell[data-ui-mode="chat"] .message-list {
    width: 100%;
    min-height: 0;
    padding: 28px 32px 20px;
    gap: 22px;
  }

  .app-shell[data-ui-mode="chat"] .message {
    width: min(88%, 100%);
    min-height: 116px;
    padding: 24px 26px;
    font-size: clamp(1.82rem, 7.7vw, 2.42rem);
    line-height: 1.22;
  }

  .app-shell[data-ui-mode="chat"] .message-role {
    font-size: clamp(1rem, 4vw, 1.2rem);
  }

  .app-shell[data-ui-mode="chat"] .composer {
    width: 100%;
    min-height: 0;
    padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  }

  .app-shell[data-ui-mode="chat"] textarea {
    min-height: 100%;
    padding: 22px 132px 22px 22px;
    font-size: clamp(1.42rem, 6.1vw, 1.86rem);
  }

  .app-shell[data-ui-mode="chat"] .composer-actions {
    right: 32px;
    bottom: calc(32px + env(safe-area-inset-bottom));
  }

  .app-shell[data-ui-mode="chat"] #send-button {
    width: 112px;
    min-width: 112px;
    min-height: 74px;
    font-size: clamp(1.24rem, 5.4vw, 1.56rem);
  }
}

/* R28POSTMERGE9: visual balance pass for the product chat surface. */
.app-shell[data-ui-mode="chat"] .eyebrow {
  text-transform: none;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip {
  padding: clamp(14px, 1.8vw, 22px) clamp(22px, 3.5vw, 44px) clamp(14px, 1.8vw, 22px);
  align-items: stretch;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: clamp(16px, 2.6vw, 34px);
  min-height: clamp(48px, 4.2vw, 58px);
  padding: 0 clamp(14px, 1.8vw, 22px);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip span,
.app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
  display: block;
  line-height: 1;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
  text-align: right;
  font-size: clamp(0.92rem, 1vw, 1.18rem);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip span {
  font-size: clamp(0.82rem, 0.9vw, 1.04rem);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip span {
  display: block !important;
}

.app-shell[data-ui-mode="chat"] .model-loading-panel {
  padding: clamp(8px, 1.2vw, 12px) clamp(22px, 3.5vw, 44px) clamp(12px, 1.4vw, 18px);
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  margin-top: clamp(8px, 1vw, 12px);
  color: rgba(240, 237, 229, 0.76);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: clamp(0.92rem, 0.95vw, 1.08rem);
  font-weight: 800;
  line-height: 1.28;
}

.app-shell[data-ui-mode="chat"] .message-list {
  padding-top: clamp(22px, 3.2vw, 44px);
  padding-bottom: clamp(16px, 2.2vw, 28px);
  gap: clamp(18px, 2.6vw, 34px);
}

.app-shell[data-ui-mode="chat"] .message {
  min-height: clamp(86px, 7vw, 108px);
  padding: clamp(18px, 1.9vw, 30px) clamp(22px, 2.4vw, 38px);
  font-size: clamp(1.35rem, 1.58vw, 1.95rem);
  line-height: 1.28;
  overflow-wrap: anywhere;
  word-break: normal;
}

.app-shell[data-ui-mode="chat"] .message-role {
  margin-bottom: clamp(8px, 0.9vw, 12px);
  font-size: clamp(0.8rem, 0.85vw, 1rem);
  line-height: 1;
}

.app-shell[data-ui-mode="chat"] textarea {
  font-size: clamp(1.12rem, 1.28vw, 1.48rem);
  line-height: 1.3;
}

.app-shell[data-ui-mode="chat"] textarea::placeholder {
  color: rgba(240, 237, 229, 0.58);
  font-size: 0.92em;
}

@media (max-width: 720px) {
  .app-shell[data-ui-mode="chat"] .chat-signal-strip {
    padding: 12px 14px;
    gap: 8px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip div {
    min-height: 48px;
    padding: 0 10px;
    column-gap: 8px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
    font-size: clamp(0.74rem, 3.5vw, 0.96rem);
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip span {
    font-size: clamp(0.72rem, 3.2vw, 0.9rem);
  }

  .app-shell[data-ui-mode="chat"] .model-loading-panel {
    padding: 8px 14px 12px;
  }

  .app-shell[data-ui-mode="chat"] .chat-loading-note {
    margin-top: 8px;
    font-size: clamp(0.86rem, 3.8vw, 1.02rem);
  }

  .app-shell[data-ui-mode="chat"] .message-list {
    padding: 20px 22px 14px;
    gap: 18px;
  }

  .app-shell[data-ui-mode="chat"] .message {
    width: min(88%, 100%);
    min-height: 92px;
    padding: 18px 20px;
    font-size: clamp(1.28rem, 5.5vw, 1.58rem);
    line-height: 1.3;
  }

  .app-shell[data-ui-mode="chat"] .message-role {
    font-size: clamp(0.76rem, 3.4vw, 0.95rem);
  }

  .app-shell[data-ui-mode="chat"] textarea {
    padding: 20px 126px 20px 20px;
    font-size: clamp(1.02rem, 4.5vw, 1.26rem);
  }

  .app-shell[data-ui-mode="chat"] textarea::placeholder {
    font-size: 0.88em;
  }
}

/* R28POSTMERGE10: adaptive chat bubbles and customer-safe product layout. */
.app-shell[data-ui-mode="chat"] .conversation-pane {
  grid-template-rows: auto auto minmax(0, 2fr) minmax(132px, 0.78fr);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip {
  padding: clamp(12px, 1.4vw, 20px) clamp(26px, 4vw, 58px) 8px;
  border-bottom: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div {
  min-height: clamp(42px, 3.2vw, 54px);
  border-color: var(--grassland);
  background: #10261c;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
  font-size: clamp(0.78rem, 0.82vw, 1rem);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip span {
  color: var(--yellow-flower);
  font-size: clamp(0.72rem, 0.78vw, 0.92rem);
}

.app-shell[data-ui-mode="chat"] .model-loading-panel {
  padding: 4px clamp(26px, 4vw, 58px) clamp(12px, 1.4vw, 18px);
  border-top: 0;
}

.app-shell[data-ui-mode="chat"] .model-loading-panel .loading-progress {
  height: 8px;
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  margin-top: 8px;
  color: rgba(240, 237, 229, 0.72);
  font-size: clamp(0.78rem, 0.86vw, 0.98rem);
  line-height: 1.35;
}

.app-shell[data-ui-mode="chat"] .message-list {
  width: min(100%, 1180px);
  padding: clamp(22px, 3vw, 44px) clamp(34px, 8vw, 108px) clamp(18px, 2.2vw, 30px);
  gap: clamp(16px, 2.2vw, 28px);
}

.app-shell[data-ui-mode="chat"] .message {
  box-sizing: border-box;
  width: fit-content;
  min-width: min(15ch, 100%);
  max-width: min(72ch, 76%);
  min-height: auto;
  padding: clamp(16px, 1.6vw, 24px) clamp(20px, 2.1vw, 32px);
  font-size: clamp(1.06rem, 1.18vw, 1.38rem);
  line-height: 1.42;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.app-shell[data-ui-mode="chat"] .message p {
  display: block;
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.app-shell[data-ui-mode="chat"] .message-assistant {
  align-self: flex-start;
}

.app-shell[data-ui-mode="chat"] .message-user {
  align-self: flex-end;
  max-width: min(46ch, 66%);
}

.app-shell[data-ui-mode="chat"] .message-role {
  margin-bottom: 8px;
  font-size: clamp(0.72rem, 0.78vw, 0.92rem);
  line-height: 1.15;
}

.app-shell[data-ui-mode="chat"] .composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: clamp(14px, 2vw, 24px);
  width: min(100%, 1120px);
  padding: clamp(18px, 2.2vw, 28px) clamp(34px, 8vw, 92px);
}

.app-shell[data-ui-mode="chat"] textarea {
  min-height: 104px;
  height: 100%;
  padding: clamp(16px, 1.6vw, 24px);
  font-size: clamp(1rem, 1.08vw, 1.24rem);
  line-height: 1.42;
}

.app-shell[data-ui-mode="chat"] textarea::placeholder {
  font-size: 0.86em;
}

.app-shell[data-ui-mode="chat"] .composer-actions {
  position: static;
  display: flex;
  align-items: stretch;
}

.app-shell[data-ui-mode="chat"] #send-button {
  min-width: clamp(118px, 9vw, 156px);
  min-height: 100%;
  padding: 0 clamp(22px, 2.2vw, 34px);
  font-size: clamp(1rem, 1.05vw, 1.28rem);
}

@media (max-width: 720px) {
  .app-shell[data-ui-mode="chat"] .conversation-pane {
    grid-template-rows: auto auto minmax(0, 2.1fr) minmax(120px, 0.72fr);
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip {
    padding: 10px 12px 6px;
    gap: 6px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip div {
    min-height: 42px;
    padding: 7px 8px;
    column-gap: 6px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
    font-size: clamp(0.68rem, 3vw, 0.86rem);
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip span {
    font-size: clamp(0.64rem, 2.7vw, 0.78rem);
  }

  .app-shell[data-ui-mode="chat"] .model-loading-panel {
    padding: 4px 12px 10px;
  }

  .app-shell[data-ui-mode="chat"] .chat-loading-note {
    margin-top: 7px;
    font-size: clamp(0.78rem, 3.2vw, 0.94rem);
  }

  .app-shell[data-ui-mode="chat"] .message-list {
    padding: 18px 20px 14px;
    gap: 16px;
  }

  .app-shell[data-ui-mode="chat"] .message {
    width: fit-content;
    min-width: min(12ch, 100%);
    max-width: min(88%, 34ch);
    padding: 15px 17px;
    font-size: clamp(0.98rem, 4.1vw, 1.18rem);
    line-height: 1.42;
  }

  .app-shell[data-ui-mode="chat"] .message-user {
    max-width: min(84%, 30ch);
  }

  .app-shell[data-ui-mode="chat"] .message-role {
    margin-bottom: 6px;
    font-size: clamp(0.68rem, 2.9vw, 0.82rem);
  }

  .app-shell[data-ui-mode="chat"] .composer {
    grid-template-columns: minmax(0, 1fr) minmax(82px, auto);
    gap: 10px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }

  .app-shell[data-ui-mode="chat"] textarea {
    min-height: 92px;
    padding: 14px;
    font-size: clamp(0.92rem, 3.7vw, 1.06rem);
    line-height: 1.42;
  }

  .app-shell[data-ui-mode="chat"] #send-button {
    min-width: 82px;
    min-height: 92px;
    padding: 0 14px;
    font-size: clamp(0.98rem, 4vw, 1.16rem);
  }
}

/* R28POSTMERGE12: iOS Safari keyboard fit, readable bubbles, and compact customer chat. */
html {
  min-height: 100%;
  min-height: -webkit-fill-available;
  overscroll-behavior: none;
}

body[data-ui-mode="chat"] {
  min-height: 100svh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overscroll-behavior: none;
}

.app-shell[data-ui-mode="chat"] {
  width: min(1480px, calc(100% - 56px));
  min-height: min(100dvh, 980px);
  height: min(100dvh, 980px);
  grid-template-rows: clamp(104px, 14vh, 160px) minmax(0, 1fr);
}

.app-shell[data-ui-mode="chat"] .header-copy {
  justify-content: center;
}

.app-shell[data-ui-mode="chat"] .eyebrow {
  font-size: clamp(1rem, 1.4vw, 1.55rem);
  color: var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .workspace-grid {
  min-height: 0;
}

.app-shell[data-ui-mode="chat"] .conversation-pane {
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip {
  align-items: stretch;
  padding: clamp(10px, 1.1vw, 16px) clamp(20px, 3vw, 48px) 8px;
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: clamp(44px, 4.2vw, 62px);
  padding: 8px clamp(12px, 1.6vw, 20px);
}

.app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
  font-size: clamp(0.9rem, 1vw, 1.2rem);
  line-height: 1.1;
}

.app-shell[data-ui-mode="chat"] .model-loading-panel {
  padding: 5px clamp(20px, 3vw, 48px) clamp(10px, 1vw, 14px);
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  margin-top: 8px;
  font-size: clamp(0.82rem, 0.9vw, 1rem);
  line-height: 1.35;
}

.app-shell[data-ui-mode="chat"] .message-list {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-padding-bottom: 28px;
  width: min(100%, 1180px);
  padding: clamp(20px, 3vh, 38px) clamp(28px, 6vw, 96px) clamp(18px, 2.5vh, 34px);
  gap: clamp(14px, 1.8vh, 26px);
}

.app-shell[data-ui-mode="chat"] .message {
  width: fit-content;
  min-width: min(12ch, 100%);
  max-width: min(64ch, 72%);
  padding: clamp(14px, 1.4vw, 22px) clamp(18px, 1.9vw, 30px);
  font-size: clamp(1rem, 1.05vw, 1.22rem);
  line-height: 1.45;
  color: #0b241a;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.app-shell[data-ui-mode="chat"] .message-user {
  max-width: min(44ch, 64%);
  color: var(--sheep-white);
}

.app-shell[data-ui-mode="chat"] .message-role {
  font-size: clamp(0.78rem, 0.82vw, 0.95rem);
  line-height: 1.1;
}

.app-shell[data-ui-mode="chat"] .composer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  grid-template-columns: minmax(0, 1fr) clamp(110px, 11vw, 156px);
  align-items: stretch;
  width: min(100%, 1120px);
  gap: clamp(12px, 1.5vw, 22px);
  padding: clamp(14px, 1.8vh, 22px) clamp(28px, 6vw, 92px) calc(clamp(14px, 1.8vh, 22px) + env(safe-area-inset-bottom));
  background: var(--cover-green);
  border-top: 2px solid rgba(240, 237, 229, 0.48);
}

.app-shell[data-ui-mode="chat"] textarea {
  min-height: clamp(96px, 15vh, 148px);
  max-height: 24vh;
  padding: clamp(16px, 1.6vw, 22px);
  font-size: clamp(1rem, 1.02vw, 1.16rem);
  line-height: 1.42;
  overflow-y: auto;
}

.app-shell[data-ui-mode="chat"] textarea::placeholder {
  color: rgba(240, 237, 229, 0.62);
  font-size: 0.82em;
}

.app-shell[data-ui-mode="chat"] #send-button {
  min-width: 0;
  min-height: clamp(96px, 15vh, 148px);
  padding: 0 clamp(14px, 1.6vw, 24px);
  font-size: clamp(1rem, 1.08vw, 1.24rem);
}

@supports (-webkit-touch-callout: none) {
  body[data-ui-mode="chat"] {
    min-height: -webkit-fill-available;
  }

  .app-shell[data-ui-mode="chat"] {
    height: 100svh;
    min-height: -webkit-fill-available;
  }

  .app-shell[data-ui-mode="chat"] textarea,
  .app-shell[data-ui-mode="chat"] #send-button {
    font-size: max(16px, 1rem);
  }
}

@media (max-width: 720px) {
  body[data-ui-mode="chat"] {
    background: var(--blue-sky);
  }

  .app-shell[data-ui-mode="chat"] {
    width: 100%;
    height: 100svh;
    min-height: 100svh;
    grid-template-rows: clamp(78px, 12svh, 118px) minmax(0, 1fr);
    border-inline: 0;
    padding-top: env(safe-area-inset-top);
  }

  .app-shell[data-ui-mode="chat"] .app-header {
    min-height: 0;
    padding: 16px 22px;
  }

  .app-shell[data-ui-mode="chat"] .header-side {
    display: none !important;
  }

  .app-shell[data-ui-mode="chat"] .eyebrow {
    font-size: clamp(1rem, 4.7vw, 1.35rem);
  }

  .app-shell[data-ui-mode="chat"] .conversation-pane {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 18px 8px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip div {
    grid-template-columns: 1fr;
    min-height: 46px;
    padding: 8px 10px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip span {
    font-size: 0.76rem;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip strong {
    font-size: clamp(0.78rem, 3.3vw, 0.98rem);
  }

  .app-shell[data-ui-mode="chat"] .model-loading-panel {
    padding: 6px 18px 10px;
  }

  .app-shell[data-ui-mode="chat"] .chat-loading-note {
    font-size: clamp(0.78rem, 3.3vw, 0.94rem);
  }

  .app-shell[data-ui-mode="chat"] .message-list {
    padding: 18px 20px 18px;
    gap: 16px;
  }

  .app-shell[data-ui-mode="chat"] .message {
    max-width: min(84%, 28ch);
    padding: 14px 16px;
    font-size: clamp(0.92rem, 3.8vw, 1.08rem);
    line-height: 1.45;
  }

  .app-shell[data-ui-mode="chat"] .message-assistant {
    max-width: min(82%, 28ch);
  }

  .app-shell[data-ui-mode="chat"] .message-user {
    max-width: min(78%, 24ch);
  }

  .app-shell[data-ui-mode="chat"] .message-role {
    margin-bottom: 6px;
    font-size: clamp(0.68rem, 2.8vw, 0.82rem);
  }

  .app-shell[data-ui-mode="chat"] .composer {
    grid-template-columns: minmax(0, 1fr) clamp(76px, 22vw, 94px);
    gap: 10px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }

  .app-shell[data-ui-mode="chat"] textarea {
    min-height: 86px;
    max-height: 128px;
    padding: 13px 14px;
    font-size: max(16px, 0.96rem);
    line-height: 1.38;
  }

  .app-shell[data-ui-mode="chat"] #send-button {
    min-height: 86px;
    font-size: max(16px, 1rem);
  }
}

@media (max-width: 720px) and (max-height: 700px) {
  .app-shell[data-ui-mode="chat"] {
    grid-template-rows: clamp(60px, 10svh, 84px) minmax(0, 1fr);
  }

  .app-shell[data-ui-mode="chat"] .app-header {
    padding-block: 10px;
  }

  .app-shell[data-ui-mode="chat"] .chat-signal-strip div {
    min-height: 38px;
  }

  .app-shell[data-ui-mode="chat"] .chat-loading-note {
    margin-top: 5px;
  }

  .app-shell[data-ui-mode="chat"] .composer {
    padding-block-start: 10px;
  }
}

/* R28POSTMERGE13: brand spacing and dialogue reasoning controls.
   Keep this at the end so the production chat identity does not regress. */
.app-shell[data-ui-mode="chat"] .eyebrow {
  font-size: clamp(1.22rem, 1.7vw, 1.9rem);
  letter-spacing: 0.035em;
  word-spacing: 0.26em;
  line-height: 1.08;
}

.app-shell[data-ui-mode="chat"] .chat-loading-note {
  max-width: 72ch;
}

@media (max-width: 720px) {
  .app-shell[data-ui-mode="chat"] .eyebrow {
    font-size: clamp(1.28rem, 5.4vw, 1.8rem);
    letter-spacing: 0.03em;
    word-spacing: 0.2em;
  }
}
