:root {
  --ink: #211d18;
  --ink-soft: #4d463c;
  --paper: #fbf7ee;
  --paper-2: #f2ebda;
  --line: #e3d9c2;
  --cinnabar: #be3a2b;
  --cinnabar-deep: #992b1f;
  --jade: #2f7a66;
  --jade-soft: #e3efe9;
  --radius: 14px;
  --font-display: "Fraunces", serif;
  --font-body: "Work Sans", sans-serif;
  --font-hanzi: "Noto Serif SC", serif;
}

.lang-switch {
  display: flex;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
  flex: none;
}

.lang-btn {
  border: 0;
  background: none;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-btn.active {
  background: var(--ink);
  color: var(--paper);
}

.lang-btn:focus-visible {
  outline: 3px solid var(--jade);
  outline-offset: -3px;
}

/* Floated over the page as a toast so it never reserves space or offsets the
 * layout it appears in. pointer-events are re-enabled per message, so the gaps
 * around the stack stay click-through. */
.flash-stack {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: min(32rem, calc(100% - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.flash {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(33, 29, 24, 0.14);
  animation: flash-in 0.25s ease-out;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.flash-leaving {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.flash-close {
  pointer-events: auto;
  flex: none;
  margin-left: auto;
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 0 0.1rem;
  font-size: 1.35rem;
  line-height: 1;
  color: inherit;
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.flash-close:hover {
  opacity: 0.9;
}

.flash-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 4px;
  opacity: 0.9;
}

@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; }
  .flash-leaving { transition: none; }
}

.flash p {
  margin: 0;
}

.flash-seal {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 6px;
  transform: rotate(-2deg);
  color: #fff;
  font-size: 0.8rem;
  font-family: "Noto Serif SC", serif;
}

.flash-info {
  border-left-color: var(--jade);
  background: var(--jade-soft);
  color: var(--ink);
}

.flash-info .flash-seal,
.flash-notice .flash-seal {
  background: var(--jade);
}

.flash-notice {
  border-left-color: var(--jade);
}

.flash-alert {
  border-left-color: var(--cinnabar);
  background: #fdf1ef;
  color: var(--ink);
}

.flash-alert .flash-seal {
  background: var(--cinnabar);
}

/* Chat: the viewer's own messages (marked by chat_controller.js in the browser,
   since the broadcast partial is rendered without knowing who is looking). */
.chat-bubble-mine {
  background-color: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

/* Someone else's message that just arrived live (chat_controller.js#highlight):
   an amber bubble with a "pop" on arrival, fading back once it's been seen. */
.chat-message .chat-bubble {
  transition: background-color 1.5s ease, border-color 1.5s ease, box-shadow 1.5s ease;
}
.chat-message-new .chat-bubble {
  background-color: #fef3c7;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgb(245 158 11 / 0.25);
}
.chat-message-new {
  animation: chat-message-pop 0.4s ease-out;
}
@keyframes chat-message-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* A conversation in the chat list with unread messages (its count pill is
   showing — see conversations/_unread_pill). */
.chat-row:has(.chat-unread) {
  background-color: #fffbeb;
  box-shadow: inset 3px 0 0 #b91c1c;
}
.chat-row:has(.chat-unread) .chat-row-title {
  font-weight: 800;
  color: #1c1917;
}

/* Pop-ups for new chat messages (chat_messages/_toast), bottom-right on every page. */
.chat-toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  width: min(22rem, calc(100% - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #f59e0b;
  border-left-width: 4px;
  border-radius: 0.75rem;
  background: #fffbeb;
  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(33, 29, 24, 0.18);
  animation: flash-in 0.25s ease-out;
}
.chat-toast:hover {
  background: #fef3c7;
}
.chat-toast-icon {
  font-size: 1.25rem;
  line-height: 1;
}
