/* The chat window's looks (owner decision 2026-11-13, the chat window
   mockups): Modern (the default), Compact and Classic, chosen in
   Settings › Chat › Chat lines (chatlines.js draws them, chat.js places
   them). Text in Spectral; each line's channel colour is --c on its row
   (the game's colour type in the theme now). */

/* ----- the window's parts ----- */
#chat .chat-tabs { white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
#chat .chat-tabs::-webkit-scrollbar { display: none; }
#chat .chat-tabs button { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px 5px; flex: none; }
.chat-badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; box-sizing: border-box;
  background: var(--ember); color: var(--ink); font: 600 11px/17px "Spectral", Georgia, serif; text-align: center;
}
.theme-light .chat-badge { color: #fff; }
.chat-badge.quiet { background: var(--rule-strong); color: var(--parchment); }

.chat-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
#chat .chat-lines {
  padding: 6px 0 8px; font-family: "Spectral", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", Georgia, serif;
  font-size: 15px; line-height: 1.38;
}
#chat .chat-lines a { color: var(--gilt-bright); text-decoration: underline dotted 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
#chat .chat-lines a:is(:hover, :focus-visible) { text-decoration-style: solid; text-decoration-color: currentColor; }
.theme-light #chat .chat-lines a { color: var(--gilt); }
#chat .chat-lines p { margin: 0; }
#chat .chat-empty { font-family: "Spectral", Georgia, serif; font-size: 14px; }

/* day lines, the "New" line, the history caught up on connecting */
.chat-day { display: flex; align-items: center; gap: 10px; margin: 8px 12px 6px; color: var(--muted); font: 12px var(--chrome-font); letter-spacing: 0.04em; }
.chat-day::before, .chat-day::after { content: ""; flex: 1; height: 1px; background: var(--rule-strong); }
.chat-new { display: flex; align-items: center; gap: 8px; margin: 6px 12px 4px; color: var(--ember); font: 600 11px "Spectral", Georgia, serif; text-transform: uppercase; letter-spacing: 0.06em; }
.chat-new::before { content: ""; flex: 1; height: 1px; background: var(--ember); opacity: 0.7; }
.chat-hist { opacity: 0.86; }
/* Settings › Chat › Dim mob chatter: a mob's own channel lines (chatlines.js
   isMobChatter), the whole row fainter, in the chat window and the game
   window's rows known by id */
.dim-mob #chat .chat-line.chat-mob, .dim-mob #lines > .rows > .chat-mob, .dim-mob #tail-lines > .rows > .chat-mob { opacity: 0.55; }

/* every row: pointing at it shows the ⋯ button */
#chat .chat-line { position: relative; padding-right: 12px; }
#chat .chat-line:hover, #chat .chat-line:focus-within { background: color-mix(in srgb, var(--gilt) 7%, transparent); }
#chat .chat-more {
  position: absolute; right: 10px; top: -12px; z-index: 2; width: 28px; height: 24px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink-raised); border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: var(--shadow-small, var(--shadow));
  color: var(--muted); font: 15px/1 "Spectral", Georgia, serif; cursor: pointer; opacity: 0; pointer-events: none;
}
.chat-more { user-select: none; -webkit-user-select: none; }
.chat-gap { font-size: 0; }
#chat .chat-line:first-child .chat-more, #chat .chat-day + .chat-line .chat-more, #chat .chat-new + .chat-line .chat-more { top: 0; }
#chat .chat-line:hover .chat-more, #chat .chat-more:focus-visible, #chat .chat-more[aria-expanded="true"] { opacity: 1; pointer-events: auto; }
#chat .chat-more:hover, #chat .chat-more:focus-visible { color: var(--gilt-bright); outline: none; }
@media (hover: none) { #chat .chat-more { opacity: 0; } }
.chat-removed { color: var(--muted); font-style: italic; }

/* pictures: true shape, rounded, at most 240 × 240 (Compact 200) */
#chat .quill-chat-img { margin: 4px 0 2px; }
/* The width comes from the img's width attribute (already fitted to 240)
   and the height from its w/h ratio, so the picture's box is there before
   the file comes and the list doesn't grow under a reader at the bottom;
   never width: auto, which leaves no box until the picture has loaded. */
#chat .quill-chat-img img { max-width: min(240px, 100%); max-height: 240px; height: auto; object-fit: contain; border-radius: 6px; outline: 1px solid var(--rule); }
#chat .cb .quill-chat-img img { max-width: min(200px, 100%); max-height: 200px; }

/* the tags */
.cm-pill {
  display: inline-block; font: 11.5px/1 "Spectral", Georgia, serif; padding: 2px 7px 3px; border-radius: 9px; white-space: nowrap;
  color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 13%, transparent);
}
.cb-tag {
  font: 11px/1 "Spectral", Georgia, serif; padding: 1px 5px 2px; border-radius: 3px; margin-right: 5px; vertical-align: 1px; white-space: nowrap;
  color: var(--c, var(--muted)); border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 45%, transparent);
}
.cm-pill.room { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.cb-tag.room { color: var(--muted); border-color: color-mix(in srgb, var(--muted) 45%, transparent); }

/* emotes: an action, not speech */
#chat .emo .chat-text { font-style: italic; }
.emo-star { color: var(--muted); font-style: normal; margin-right: 3px; }
.cm-who { font-weight: 600; color: var(--c, var(--parchment-bright)); }

/* ----- Modern ----- */
#chat .chat-line.cm { padding: 1px 14px; white-space: normal; overflow-wrap: anywhere; }
#chat .chat-line.cm.first { margin-top: 9px; }
#chat .chat-line.cm.emo { margin-top: 5px; }
.cm-head { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; line-height: 1.25; }
.cm-name { font-weight: 600; color: var(--c, var(--parchment-bright)); }
.cm-time { font-size: 11.5px; color: var(--muted); font-style: normal; }
.cm.emo .cm-pill { font-style: normal; margin-left: 4px; }
.cm-end { white-space: nowrap; font-style: normal; }
.cm-text, .cb-text { color: var(--parchment); }
.cm-plain { white-space: pre-wrap; }
.cm-text .quill-chat > p:first-child, .cm-text .quill-chat > p:last-child { display: block; }
.cm-text .quill-chat > p:first-child + p:last-child::before { content: none; }

/* ----- Compact ----- */
#chat .chat-line.cb { padding: 2px 12px 2px calc(12px + 36px); text-indent: -36px; white-space: normal; overflow-wrap: anywhere; }
#chat .chat-line.cb > * { text-indent: 0; }
.cb-time { display: inline-block; width: 40px; white-space: nowrap; font-size: 11.5px; color: var(--muted); }
.cb-name { font-weight: 600; color: var(--c, var(--parchment-bright)); margin-right: 4px; }
.cb-text .quill-chat > p:first-child { display: inline; }
.cb-text .quill-chat > p + p, .cb-text .quill-chat > .quill-list, .cb-text .quill-chat > blockquote { display: block; }

/* ----- Classic (and every line Modern can't draw) ----- */
/* The time in its own column and the text beside it: a gap after any time
   (a 12-hour "4:28 PM" in Modern is wider than the column), and every row
   of the text, wrapped or a line of its own, starts under its first. */
#chat .chat-line.ce { display: flex; align-items: baseline; padding: 1px 12px; overflow-wrap: anywhere; }
#chat .chat-line.ce .chat-time { flex: none; min-width: 36px; white-space: nowrap; margin: 0 6px 0 0; font-size: 11.5px; color: var(--muted); }
#chat .chat-line.ce .chat-text { flex: 1 1 auto; min-width: 0; }
#chat .chat-line.ce .quill-list { text-indent: 0; }
#chat .chat-line.ce-plain .chat-text { color: var(--c, inherit); }
/* A line that is a notice (Quill <notice>: a system announcement): the
   strip runs the window's width, its time at the right of its top line. */
#chat .chat-line.ce:has(.quill-notice) { display: block; padding: 0; }
/* (the strip's margin collapses outside the row: its top line starts 7px
   down, under the rule and the padding) */
#chat .chat-line.ce:has(.quill-notice) .chat-time { position: absolute; top: 7px; right: 12px; width: auto; line-height: 15px; text-align: right; }
#chat .chat-line.ce .quill-notice { margin: 8px 0; padding-inline: 12px; }
#chat .chat-line.ce .quill-notice-head { padding-right: 44px; }
#chat .chat-line.ce .chat-text:has(.quill-notice) .quill-chat { display: block; }

/* scrolled up while new lines came */
.chat-jump {
  position: absolute; left: 10px; right: 10px; bottom: 6px; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 4px 10px; border: 0; border-radius: 6px; background: var(--gilt); color: var(--on-accent);
  font: 600 12.5px "Spectral", Georgia, serif; box-shadow: var(--shadow-small, var(--shadow)); cursor: pointer;
}
.chat-jump[hidden] { display: none; }
.chat-jump:focus-visible { outline: 2px solid var(--parchment); }

/* Settings › Chat */
#set-chat-lines { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 4px; }
#set-chat-lines legend { padding: 0; margin-bottom: 4px; color: var(--muted); }
#set-chat-lines .eg { color: var(--muted); font-size: 13px; font-family: "Spectral", Georgia, serif; }
#set-chat-lines .eg b { font-weight: 600; color: var(--parchment); }
#sec-chat .picture-settings { display: flex; flex-direction: column; gap: 8px; }
#sec-chat .picture-settings[hidden] { display: none; }

@media (max-width: 600px) {
  #chat .chat-line.cm { padding: 1px 10px; }
  #chat .quill-chat-img img { max-width: min(220px, 60%); }
}

/* the header's look switcher (Modern, Compact, Classic) */
.chat-seg { display: inline-flex; margin-left: auto; margin-right: 4px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--ink); cursor: default; }
.chat-seg button { position: relative; width: 28px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.chat-seg button:first-child { border-radius: 5px 0 0 5px; }
.chat-seg button:last-child { border-radius: 0 5px 5px 0; }
.chat-seg button + button { border-left: 1px solid var(--rule); }
.chat-seg button svg { width: 15px; height: 15px; }
.chat-seg button:hover { color: var(--parchment); }
.chat-seg button[aria-checked="true"] { color: var(--gilt-bright); background: color-mix(in srgb, var(--gilt) 16%, transparent); }
.chat-seg button:focus-visible { outline: 1px solid var(--gilt); outline-offset: -1px; }
.chat-seg button[data-tip]::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: 0; z-index: 6; padding: 3px 8px; white-space: nowrap;
  background: var(--ink-raised); color: var(--parchment); border: 1px solid var(--rule-strong); border-radius: 4px; box-shadow: var(--shadow-small, var(--shadow));
  font: 12px var(--chrome-font); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.chat-seg button[data-tip]:hover::after, .chat-seg button[data-tip]:focus-visible::after { opacity: 1; transition-delay: .35s; }
.chat-seg button:focus-visible::after { transition-delay: 0s; }
/* the switcher takes the free space; the pin and × sit right after it */
#chat > header .chat-seg ~ .lay-place, #chat > header .chat-seg ~ .lay-max-btn, #chat > header .chat-seg ~ .panel-close { margin-left: 0; }

/* your own name (never "You" in the chat window): just bolder (owner:
   no underline). Spectral ships only up to SemiBold, so the extra weight
   is a thin text-shadow. */
.cm-name.you, .cb-name.you, .cm-who.you, #chat .chat-line.mine .ce-me {
  font-weight: 600;
  text-shadow: 0.45px 0 0 currentColor;
}
