html body .mesa-page .page-intro { padding-block: 24px 16px; }
html body .mesa-page .page-intro h1 { max-width: 26ch; margin-block: .3em; }
.mesa-page .page-intro p { margin-bottom: 0; }

.mesa-activity {
  --mesa-red: #a12735;
  --mesa-rose: #fcebee;
  --mesa-amber: #624000;
  --mesa-gold: #ffeab2;
  --mesa-green: #216447;
  --mesa-mint: #e9f5ee;
  padding: clamp(12px, 2vw, 28px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--soft);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.mesa-activity :is(h2, h3, h4, p, ol, ul) { margin: 0; }
.mesa-controls { display: contents; }
.mesa-toolbar, .mesa-deskhead, .mesa-progress {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.mesa-toolbar, .mesa-deskhead { justify-content: space-between; }
.mesa-toolbar h2 { font-size: 1.3em; }
.mesa-activity button {
  min-height: 44px;
  padding: .5em 1em;
  border: 1px solid var(--olive);
  border-radius: 8px;
  background: var(--card);
  color: var(--olive);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.mesa-activity button:hover { box-shadow: inset 0 0 0 1px currentColor; }
.mesa-activity button:focus-visible { outline: 3px solid var(--olive); outline-offset: 3px; }
.mesa-activity button[hidden] { display: none; }
.mesa-activity .mesa-primary { background: var(--olive); color: #fff; }
.mesa-progress { margin: 12px 0; font-weight: 700; }
.mesa-progress progress { flex: 1; min-width: 0; accent-color: var(--olive); height: 12px; }

.mesa-grid {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 5fr);
  gap: clamp(10px, 2vw, 24px);
  align-items: start;
}
.mesa-chat, .mesa-deskbox, .mesa-desk-note:not(:empty) {
  padding: clamp(10px, 1.4vw, 20px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.mesa-chat, .mesa-story, .mesa-exchange, .mesa-deskbox { display: grid; gap: .55em; min-width: 0; }
.mesa-story:empty { display: none; }
.mesa-chat h3, .mesa-deskhead h3 { font-size: 1.2em; line-height: 1.2; }
.mesa-chat-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding-bottom: .45em;
  border-bottom: 1px solid var(--line);
}
.mesa-chat-head span { font-size: .8em; color: var(--muted); }
.mesa-prompt { display: grid; gap: .35em; border-left: 4px solid var(--olive); padding-left: .65em; }
.mesa-prompt.warn { border-color: var(--mesa-red); }
.mesa-prompt.sum { border-color: var(--mesa-amber); padding-block: .35em; background: var(--mesa-gold); }
.mesa-prompt.sum .mesa-label { color: var(--mesa-amber); }
.mesa-prompt.good { border-color: var(--mesa-green); }
.mesa-desk-note:not(:empty) { margin-top: 12px; }
.mesa-desk-note h3 { font-size: 1.2em; line-height: 1.2; }
.mesa-label, .mesa-deskhead strong { font-size: .88em; font-weight: 700; color: var(--muted); }
.mesa-quote, .mesa-verdict { border-radius: 8px; padding: .45em .65em; background: var(--soft); }
.mesa-quote strong { display: block; }
.mesa-quote.sent { justify-self: end; max-width: 93%; border-bottom-right-radius: 2px; }
.mesa-quote.reply { justify-self: start; max-width: 93%; background: var(--paper); border-bottom-left-radius: 2px; }
.mesa-compression { display: grid; gap: .35em; }
.mesa-quote.mesa-summary, .mesa-quote.mesa-omitted { border-inline-start: 4px solid; color: var(--ink); }
.mesa-quote.mesa-summary { background: var(--mesa-gold); border-color: var(--mesa-amber); }
.mesa-quote.mesa-omitted { background: var(--mesa-rose); border-color: var(--mesa-red); }
.mesa-summary strong { color: var(--mesa-amber); }
.mesa-omitted strong { color: var(--mesa-red); }
.mesa-composer {
  display: grid;
  gap: .5em;
  padding: .55em;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.mesa-composer:has(#mesa-draft[hidden]) { padding: 0; border: 0; }
.mesa-composer .mesa-primary { justify-self: end; }
.mesa-history summary { cursor: pointer; color: var(--olive); font-weight: 700; min-height: 32px; align-content: center; }
.mesa-history ol { display: grid; gap: .55em; list-style: none; padding: .35em 0 0; }
.mesa-history li { display: grid; gap: .3em; }
.mesa-verdict { font-weight: 700; }
.mesa-verdict.bad { color: var(--mesa-red); background: var(--mesa-rose); }
.mesa-verdict.ok { color: var(--mesa-green); background: var(--mesa-mint); }

.mesa-desk {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  list-style: none;
  padding: 0;
  font-size: .94em;
  line-height: 1.3;
}
.mesa-desk li {
  min-height: 4em;
  padding: .5em;
  border: 1px solid var(--olive);
  border-radius: 8px;
  background: var(--paper);
}
.mesa-desk li strong { display: block; color: var(--olive); margin-bottom: .18em; }
.mesa-desk li.slot {
  display: grid;
  place-items: center;
  border-style: dashed;
  border-color: #888ba3;
  background: var(--card);
  color: var(--muted);
  text-align: center;
}
.mesa-desk li.key, .mesa-quote.key { background: var(--mesa-rose); border-color: var(--mesa-red); }
.mesa-desk .key strong, .mesa-tray .key { color: var(--mesa-red); }
.mesa-desk li.sum { background: var(--mesa-gold); border-color: var(--mesa-amber); }
.mesa-desk .sum strong { color: var(--mesa-amber); }
.mesa-tray { border-top: 1px solid var(--line); padding-top: .45em; font-size: .86em; }
.mesa-tray summary { cursor: pointer; font-weight: 700; min-height: 32px; align-content: center; }
.mesa-tray ul { padding-left: 1.25em; }
.mesa-tray .key { font-weight: 700; }

.mesa-board-active { overflow: hidden; }
.mesa-board {
  position: fixed;
  inset: 0;
  margin: 0;
  border: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  padding: clamp(8px, 1vw, 20px);
  background: var(--soft);
  color: var(--ink);
  overflow: auto;
  overflow-anchor: none;
}
.mesa-board .mesa-activity {
  max-width: 1680px;
  margin-inline: auto;
  padding: clamp(10px, 1vw, 20px);
  font-size: clamp(17px, 1.4vw, 24px);
  line-height: 1.35;
}
.mesa-board .mesa-controls {
  display: block;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--soft);
}

@media (min-width: 1024px) and (max-height: 850px) {
  .mesa-board .mesa-chat { padding: 12px; line-height: 1.25; }
  .mesa-board .mesa-chat, .mesa-board .mesa-story, .mesa-board .mesa-exchange { gap: .4em; }
  .mesa-board .mesa-progress { margin-block: 6px; }
}
@media (max-width: 1000px) {
  .mesa-desk { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .mesa-grid { grid-template-columns: minmax(0, 1fr); }
  .mesa-activity { border-radius: 12px; }
  .mesa-desk li.slot { min-height: 2.6em; }
  .mesa-board .mesa-toolbar h2 { font-size: 1.05em; }
  .mesa-board .mesa-progress { margin-block: 6px; }
  .mesa-composer .mesa-primary { justify-self: stretch; }
  .mesa-progress { gap: 6px 8px; }
  .mesa-progress button { padding-inline: .55em; }
}
@media (prefers-reduced-motion: no-preference) {
  .mesa-new { animation: mesa-appear .25s ease-out; }
  @keyframes mesa-appear { from { opacity: .35; transform: translateY(4px); } }
}
