/* Conversation list and rooms share the workshop's plum and pistachio palette. */
.chat-inbox, #app > .chat-room {
  --chat-paper: #f7f7f2;
  --chat-rule: #dcded3;
  --chat-secondary: #5e595c;
  width: 100%;
  max-width: 52rem;
  margin-inline: auto;
}
.chat-inbox h1 {
  margin: .8rem 0 1.4rem;
  color: var(--brand);
  font: 400 clamp(2.25rem,5vw,3.6rem)/1.15 var(--field-display);
  letter-spacing: -.06em;
}
.chat-inbox > .back { font-size: .94rem; }
.thread-list { border-top: 2px solid var(--brand); }
#app .thread-item {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: clamp(.7rem,2vw,1.3rem);
  width: 100%;
  margin: 0;
  padding: 1.05rem .65rem;
  border: 0;
  border-bottom: 1px solid var(--chat-rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: start;
  text-decoration: none;
}
#app .thread-item:is(:hover,:focus-visible) { background: #f0f1e7; }
.thread-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: .95rem;
  background: var(--plum-tint);
  color: var(--brand);
}
.thread-mark::before, .thread-mark::after {
  content: "";
  position: absolute;
  width: 1.1rem;
  height: .85rem;
  border: 2px solid currentColor;
  border-radius: .45rem .45rem .45rem .08rem;
}
.thread-mark::after { width: .48rem; height: 2px; border: 0; border-radius: 1px; background: currentColor; }
.thread-group .thread-mark { color: #334537; background: #e4ebd3; }
.thread-group .thread-mark::before { transform: translate(-.16rem,.12rem); background: inherit; z-index: 1; }
.thread-group .thread-mark::after { width: 1.02rem; height: .75rem; border: 2px solid currentColor; border-radius: .35rem; background: transparent; transform: translate(.18rem,-.15rem); }
.thread-copy,.thread-side { display: grid; min-width: 0; gap: .15rem; }
.thread-copy > :is(strong,span):not(.thread-kind) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread-kind { color: var(--plum); font: 600 .875rem/1.35 var(--sans); }
.thread-group .thread-kind { color: #42543e; }
.thread-copy strong { font: 700 1.15rem/1.45 var(--sans); letter-spacing: -.035em; }
.thread-context,.thread-side time { color: var(--chat-secondary); font-size: .875rem; font-weight: 400; }
.thread-preview { font-size: 1rem; font-weight: 400; }
.thread-side { justify-items: end; gap: .35rem; }
.thread-side time { font-size: .8125rem; }
.thread-unread { min-width: 1.55rem; padding: .12rem .45rem; border-radius: 99px; background: var(--brand); color: white; text-align: center; font: 700 .8125rem/1.45 var(--sans); }
.thread-empty { display: grid; justify-items: center; gap: .35rem; margin: auto; padding: 2rem 1rem; color: var(--ink); text-align: center; }
.thread-empty .thread-mark { margin-bottom: .35rem; }
.thread-empty strong { font-weight: 600; }
.thread-empty p { margin: 0; color: var(--chat-secondary); font-size: .95rem; }
/* A compact room brief sits beside the conversation on larger screens. */
#app > .chat-room {
  --room-ink: #202722;
  --room-muted: #545f59;
  --room-edge: #d2dbd3;
  display: grid;
  grid-template-columns: clamp(12rem,23%,17rem) minmax(0,1fr);
  max-width: 72rem;
  height: clamp(28rem,77dvh,55rem);
  background: #fff;
  color: var(--room-ink);
  border: 1px solid var(--room-edge);
  border-radius: .85rem;
  box-shadow: 0 .5rem 2rem rgb(41 54 44 / 5%);
}
#app .chat-room .chat-heading {
  display: flex; flex-direction: column; align-items: flex-start;
  min-width: 0; overflow-y: auto;
  padding: 1rem clamp(1rem,2vw,1.75rem) 1.3rem;
  border: 0; border-inline-end: 1px solid var(--room-edge);
  background: #f0f3ee; color: var(--room-ink);
}
.room-back,.room-tools { max-width: 100%; }
#app .room-back :is(a,button),#app .room-tools :is(a,button) {
  display: inline-flex; align-items: center; min-height: 44px;
  margin: 0; padding: .3rem .15rem; border: 0; border-radius: .25rem;
  background: transparent; color: #384a3d; text-decoration: none; font: 600 .875rem/1.35 var(--sans);
}
#app .room-tools :is(a,button) { text-decoration: underline; text-underline-offset: .24em; }
#app .chat-room .chat-identity { margin: 2.25rem 0 0; min-width: 0; }
#app .chat-room .chat-identity .thread-kind { display: block; margin-bottom: .48rem; color: #526153; }
#app .chat-room .chat-identity h1 {
  color: var(--room-ink); margin: 0; font: 400 clamp(1.55rem,2.6vw,2.36rem)/1.3 var(--field-display);
  letter-spacing: -.055em; overflow-wrap:anywhere;
}
#app .chat-room .chat-identity p { margin: .65rem 0 0; color: #414e44; font: 400 1rem/1.5 var(--sans); }
.room-schedule { display: grid; gap: .2rem; margin-top: 1.55rem; padding-top: .85rem; border-top: 1px solid var(--room-edge); width: 100%; font-size: .9rem; }
.room-schedule span { color: var(--room-muted); font-size: .875rem; }
.room-tools { margin-top: auto; padding-top: 1rem; }
.chat-stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: white; overflow: hidden; }
.chat-room .chat-log { gap: .95rem; padding: 1.45rem clamp(.9rem,3vw,2.2rem); scrollbar-width: thin; scrollbar-color: #b6c1b8 transparent; }
.chat-day { display: flex; flex: none; align-items: center; gap: .8rem; margin: .5rem 0; color: var(--room-muted); font: 600 .8125rem/1.4 var(--sans); }
.chat-day::after { content: ""; height: 1px; flex: 1; background: #e0e5df; }
.chat-room .chat-line, #classLog .chat-line { display: flex; align-items: flex-start; gap: .55rem; flex: none; width: fit-content; max-width: min(88%,41rem); min-width: 0; }
.chat-line.outgoing { align-self: flex-end; }
.chat-room .chat-line.continued { margin-top: -.7rem; }
.speaker-initial {
  flex: 0 0 2.15rem; display: grid; place-items: center; height: 2.15rem; margin-top: .05rem;
  border-radius: 50%; color: #414852; background: #e2e7ed; font: 600 .9375rem/1 var(--sans);
}
.speaker-initial.tone-1 { background: #e4eadd; color: #3d5041; }
.speaker-initial.tone-2 { background: #efe2da; color: #634634; }
.speaker-initial.tone-3 { background: #ebe4ec; color: #514353; }
.chat-line.incoming.continued { margin-inline-start: 2.7rem; }
.chat-content { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.outgoing .chat-content { align-items: flex-end; }
.chat-byline { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .5rem; max-width:100%; margin: 0 .15rem .24rem; }
.outgoing .chat-byline { justify-content: flex-end; }
.chat-author { color: #233228; font: 650 .9375rem/1.35 var(--sans); overflow-wrap:anywhere; }
.chat-author small { margin-inline-start:.15rem; color:var(--room-muted); font:400 .8125rem/1.35 var(--sans); }
.chat-byline time { color: var(--room-muted); font: 400 .8125rem/1.4 var(--sans); font-variant-numeric: tabular-nums; }
.chat-author.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.bubble-row { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; max-width:100%; }
.outgoing .bubble-row { justify-content:flex-end; }
.chat-room .bubble {
  min-width:0; max-width:100%; margin:0; padding:.66rem .92rem;
  border:0; border-radius:.25rem 1rem 1rem; background:#f1f3f0; color:var(--room-ink);
  font:400 1rem/1.55 var(--sans); overflow-wrap:anywhere; word-break:normal;
}
.chat-room .outgoing .bubble { background:#e0ebda; color:#1e3729; border-radius:1rem .25rem 1rem 1rem; }
.chat-room .bubble-menu summary { display:grid; place-items:center; min-width: 1.85rem; min-height: 1.85rem; color:var(--room-muted); font:700 1.05rem/1 var(--sans); border-radius:50%; cursor:pointer; }
.chat-room .bubble-menu summary:hover,.chat-room .bubble-menu[open] summary { background:#eef1ed; }
.chat-room .bubble-menu > div { display:flex; flex-wrap:wrap; gap:.2rem; }
.chat-room .bubble-menu button,#app #classEarlier { margin:0; padding:.35rem .7rem; min-height:44px; font-size:.875rem; }
#app #classEarlier { align-self:center; flex:none; margin:.35rem 0; background:white; border:1px solid var(--room-edge); border-radius:2rem; }
#app .chat-status:not(:empty),#app .chat-error:not(:empty) { margin:0; padding:.45rem 1rem; color:#5e253a; background:#f6edef; font:.9rem/1.5 var(--sans); }
#app .chat-error:empty { display:none; }
.room-name-prompt { flex:none; margin:.6rem 1rem; padding:.7rem 1rem; border:1px solid var(--room-edge); border-radius:.7rem; background:#f3f6f1; }
.room-name-prompt p { margin:0 0 .35rem; font-size:.95rem; }
.room-name-prompt button { margin:0; min-height:44px; }
#app .chat-room .chat-compose {
  display:flex; align-items:flex-end; flex:none; gap:.3rem;
  width:auto; max-width:none; margin:.4rem clamp(.7rem,2vw,1.6rem) max(1.05rem,env(safe-area-inset-bottom));
  padding:.35rem; border:1px solid #a1ada4; border-radius:1.6rem; background:white;
}
#app .chat-room .chat-compose[hidden] { display:none; }
#app .chat-room .chat-compose:focus-within { border-color:#48614e; box-shadow:0 0 0 2px #cbdac9; }
#app .chat-room .chat-compose textarea,#app .chat-room .chat-compose textarea:focus {
  min-width:0; min-height:44px; max-height:6.2rem; padding:.62rem .85rem; margin:0;
  border:0; outline:0; box-shadow:none; border-radius:1rem; background:transparent; color:var(--room-ink);
  font:400 1rem/1.5 var(--sans); resize:none; field-sizing:content;
}
#app .chat-room .chat-compose button { display:block; flex:none; min-height:44px; padding:.5rem 1.12rem; margin:0; border:0; border-radius:2rem; color:white; background:#2e4436; }
#app .chat-room .chat-compose button:disabled { opacity:.65; }
@media (max-width:48rem) {
  body:has(#app > .chat-room) > :is(header,footer) { display:none; }
  main#app:has(> .chat-room) { padding:0; margin:0; max-width:none; }
  #app > .chat-room { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); height:var(--chat-viewport,100dvh); max-width:none; border:0; border-radius:0; box-shadow:none; }
  #app .chat-room .chat-heading { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:.6rem; padding:max(.48rem,env(safe-area-inset-top)) .85rem .52rem; border:0; border-bottom:1px solid var(--room-edge); overflow:visible; }
  #app .chat-room .chat-identity { margin:0; }
  #app .chat-room .chat-identity .thread-kind { margin:0 0 .15rem; font-size:.8125rem; }
  #app .chat-room .chat-identity h1 { font:650 1.1rem/1.32 var(--sans); letter-spacing:-.035em; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
  #app .chat-room .chat-identity p { margin:.12rem 0 0; font-size:.875rem; line-height:1.25; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .room-tools { margin:0; padding:0; }
  .room-schedule { display:none; }
  #app .room-tools :is(a,button) { white-space:nowrap; }
  .chat-inbox h1 { margin-top:.3rem; }
  #app .thread-item { gap:.7rem; padding-inline:.1rem; }
  .thread-item .thread-mark { width:2.6rem; height:2.6rem; }
  .thread-side time { max-width:6rem; text-align:end; }
}
@media (max-width:24rem), (max-height:30rem) and (max-width:48rem) {
  #app .chat-room .chat-identity p { display:none; }
  .chat-room .chat-log { padding-inline:.65rem; }
}
