/* WonderPost – invitations, the private circle and its shared conversation.
   Load after styles.css; the paper palette and common controls live there. */

.is-hidden { display: none !important; }

/* A complete entry screen, without the game's desktop side rail. */
#app.network-gate {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 15% 15%, var(--accent-pale), transparent 65%), var(--bg);
}
.gate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 1080px;
  min-width: 0;
  margin: 0 auto;
}
.gate-layout > * { min-width: 0; }
#app.network-gate > #main.gate-layout { max-width: 1080px; }
.gate-art {
  display: block;
  justify-self: center;
  width: 100%;
  max-width: 560px;
  max-height: 210px;
  margin-right: auto;
  margin-left: auto;
  object-fit: contain;
}
.gate-art img { display: block; width: 100%; max-height: inherit; object-fit: contain; }
.gate-card {
  width: 100%;
  max-width: 500px;
  min-width: 0;
  justify-self: center;
  padding: clamp(21px, 5vw, 36px);
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.gate-brand {
  display: flex;
  align-items: center;
  gap: 0;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 25px;
  color: var(--ink);
  font-size: clamp(24px, 5vw, 30px);
  font-weight: 850;
  letter-spacing: -1px;
  line-height: 1.2;
  text-decoration: none;
}
.gate-brand > .ui-icon { flex: 0 0 34px; width: 34px; height: 34px; color: var(--accent); }
.gate-brand > span { color: var(--accent); }
.gate-brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .3px; }
.gate-eyebrow { display: block; margin-bottom: 10px; color: var(--accent-ink); font-size: 11px; font-weight: 800; letter-spacing: 1.4px; line-height: 1.4; text-transform: uppercase; }
.gate-card h1 { font-size: clamp(26px, 4.5vw, 35px); }
.gate-card h1 + p, .gate-card h2 + p { margin-top: 13px; }
.gate-card > p { color: var(--muted); font-size: 14px; line-height: 1.65; }
.gate-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 22px; }
.gate-actions > .button { flex: 1 1 145px; }
.entry-form { display: grid; gap: 18px; min-width: 0; margin-top: 24px; }
.entry-form .form-field { margin-bottom: 0; }
.entry-form > .button { width: 100%; min-height: 48px; }
.entry-form label { overflow-wrap: anywhere; }
.entry-form :is(input[type="checkbox"], input[type="radio"]) { flex-shrink: 0; }
:is(.entry-form, .invite-panel, .profile-name-form) input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.entry-form select, .entry-form textarea, textarea.chat-textarea { font-size: 16px; }
.form-error { padding: 11px 13px; color: var(--danger); background: var(--danger-soft); border: 1px solid #efced2; border-radius: 11px; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.form-error:empty { display: none; }
.gate-card .form-error { color: var(--danger); }
.gate-status { display: flex; align-items: center; gap: 10px; margin-top: 19px; padding: 14px 16px; color: var(--accent-ink); background: var(--accent-pale); border: 1px solid var(--line-soft); border-radius: 15px; font-size: 14px; line-height: 1.6; }
.gate-card .gate-status { color: var(--accent-ink); }
.gate-status > .ui-icon { flex-shrink: 0; }
.gate-card .gate-fineprint { margin-top: 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.browser-note, .reentry-note { margin-top: 19px; padding: 13px 15px; background: var(--peach-soft); border: 1px solid #eddbcd; border-radius: 13px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.browser-note strong, .reentry-note strong { color: var(--ink); }
.reentry-note { background: var(--accent-pale); border-color: var(--line-soft); }
.browser-note p + p, .reentry-note p + p { margin-top: 8px; }
.pending-steps { margin: 20px 0; padding-left: 23px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.pending-steps li { padding-left: 3px; }
.pending-steps li + li { margin-top: 10px; }
.pending-steps li::marker { color: var(--accent-ink); font-weight: 800; }
div.pending-steps { display: grid; gap: 12px; padding: 16px; background: var(--accent-pale); border: 1px solid var(--line-soft); border-radius: 15px; }
.pending-steps p { display: flex; align-items: flex-start; gap: 10px; margin: 0; }
.pending-steps .ui-icon { flex-shrink: 0; margin-top: 2px; color: var(--accent-ink); }

/* A real identity replaces the demonstration profile switch. */
.profile-identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  max-width: 225px;
  padding: 3px 12px 3px 4px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}
.profile-identity:hover { color: var(--accent-ink); background: var(--accent-pale); border-color: rgb(var(--accent-rgb), .3); }
.profile-identity > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-identity .profile-avatar { flex-shrink: 0; box-shadow: none; }
.profile-avatar.has-art { position: relative; }
.profile-avatar.has-art > img { display: block; object-fit: cover; }
.profile-crown { position: absolute; right: -6px; top: -8px; display: grid; place-items: center; width: 24px; height: 21px; color: #976427; background: #fff3c8; border: 1px solid #e1bd69; border-radius: 8px; transform: rotate(12deg); }
.profile-avatar .profile-crown .ui-icon { width: 17px; height: 17px; }
.account-identity { display: flex; align-items: center; gap: 16px; }
.account-identity .profile-avatar { flex-basis: 64px; width: 64px; height: 64px; }
.account-identity > strong { font-size: 20px; }
.avatar-picker { display: grid; gap: 13px; margin-top: 24px; }
.avatar-picker h3 { font-size: 16px; }
.avatar-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 9px; }
.avatar-option { position: relative; display: grid; justify-items: center; align-content: start; gap: 7px; padding: 10px 5px; color: var(--muted); background: var(--paper); border: 2px solid var(--line-soft); border-radius: 15px; font-size: 11px; line-height: 1.35; }
.avatar-option > img { width: min(100%, 66px); aspect-ratio: 1; height: auto; border-radius: 50%; object-fit: cover; }
.avatar-option.is-selected { color: var(--accent-ink); background: var(--accent-pale); border-color: var(--accent); }
.avatar-option:hover:not(:disabled) { border-color: var(--accent); }
.avatar-check { position: absolute; right: 3px; top: 3px; display: grid; place-items: center; width: 21px; height: 21px; color: var(--paper); background: var(--accent); border-radius: 50%; }
.avatar-check .ui-icon { width: 14px; height: 14px; }
.avatar-picker .hint { margin: 0; }
.preview-notice { position: sticky; z-index: 1100; top: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px 17px; padding: 12px 18px; color: #503968; background: #f2e9ff; border-bottom: 1px solid #cbb8dd; font-size: 13px; line-height: 1.5; text-align: center; }
.preview-notice strong { font-size: 14px; }
.preview-mode .modal-backdrop { padding-top: 84px; }
.preview-mode .modal { max-height: calc(100dvh - 100px); }
.preview-mode [aria-disabled="true"] { cursor: default; }
.connection-note {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1120px;
  min-width: 0;
  margin: 15px auto 25px;
  padding: 9px 12px;
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid #dce8dc;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.connection-note .ui-icon { flex: 0 0 16px; width: 16px; height: 16px; }
.connection-note.offline { color: #87513b; background: var(--peach-soft); border-color: #ead4c2; }
.connection-note.offline .status-dot { background: #9d6a44; }
.account-summary { display: grid; gap: 12px; min-width: 0; padding: 18px; background: var(--accent-pale); border: 1px solid var(--line-soft); border-radius: 16px; overflow-wrap: anywhere; }
.account-summary p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.account-summary p + p { margin-top: 0; }
.account-summary strong { color: var(--ink); }
.account-summary > .pill { justify-self: start; }
.account-devices { display: grid; gap: 10px; min-width: 0; padding: 15px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 13px; }
.account-devices h3 { font-size: 16px; line-height: 1.4; }
.account-devices > .button { justify-self: start; max-width: 100%; white-space: normal; }
.device-entry-panel .device-entry-status { color: var(--accent-ink); font-weight: 700; }
.profile-name-nudge { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 13px; margin-bottom: 24px; padding: 17px 19px; background: var(--accent-pale); border: 1px solid var(--line-soft); border-radius: 17px; }
.profile-name-nudge > div { flex: 1 1 215px; min-width: 0; }
.profile-name-nudge strong { font-size: 15px; }
.profile-name-nudge p { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.profile-name-nudge .button { flex-shrink: 0; }
.profile-name-form { display: grid; gap: 12px; margin-top: 24px; }
.profile-name-form .form-field { margin: 0; }
.profile-name-form input[aria-invalid="true"] { border-color: var(--danger); }
.profile-name-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.profile-name-actions .hint { flex: 1 1 160px; margin: 0; }
.account-guide { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 14px; margin-top: 23px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.account-guide .hint { margin: 0; }
.invite-guide-intro { margin-bottom: 17px; }
.invite-guide-player { display: block; width: 100%; max-width: 360px; height: auto; max-height: 56vh; max-height: 56dvh; aspect-ratio: 3 / 4; margin: 0 auto 22px; object-fit: contain; background: var(--accent-pale); border: 1px solid var(--line-soft); border-radius: 15px; }
.invite-guide-player:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.invite-guide-steps { display: grid; gap: 13px; padding-left: 24px; margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.invite-guide-steps li { padding-left: 5px; }
.invite-guide-steps li::marker { color: var(--accent-ink); font-weight: 800; }
.invite-guide-steps strong { color: var(--ink); }
.friend-card h3, .mail-copy h3, .trade-card strong, .exhibit-item > span, .modal-header h2 { overflow-wrap: anywhere; }

/* Lumi has a separate, clearly labelled space, outside the circle's roster. */
.companion-card { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; min-width: 0; margin: 0 0 28px; padding: 23px; background: linear-gradient(120deg, #f5f0fb, #f2f7ef); border: 1px solid #dcd3e8; border-radius: var(--radius); }
.companion-card .lumi-mascot { flex: 0 0 96px; width: 96px; height: 104px; }
.companion-card-copy { flex: 1 1 190px; min-width: 0; }
.companion-label { display: inline-block; color: #64557f; font-size: 12px; font-weight: 800; line-height: 1.5; }
.companion-card h2 { margin: 4px 0 6px; font-size: 24px; line-height: 1.25; }
.companion-card p { max-width: 450px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.companion-card > .button { flex: 0 1 auto; min-height: 44px; }
.companion-card.compact { gap: 15px; padding: 16px 21px; }
.companion-card.compact .lumi-mascot { flex-basis: 70px; width: 70px; height: 76px; }
.companion-card.compact h2 { font-size: 20px; }
.lumi-mascot { display: block; object-fit: contain; transform-origin: 50% 80%; animation: lumi-bob 4s ease-in-out infinite; }
@keyframes lumi-bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-3px) rotate(1deg); } }
.modal[data-kind="companion"] { width: min(100%, 670px); }
#companion-room { min-width: 0; }
#companion-room:focus { outline: none; }
.companion-intro { display: flex; align-items: center; gap: 17px; margin-bottom: 17px; }
.companion-intro > img { flex: 0 0 78px; width: 78px; height: 84px; }
.companion-intro > div { min-width: 0; }
.companion-intro p { margin: 4px 0 8px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.companion-score { color: var(--accent-ink); font-size: 12px; line-height: 1.5; }
.companion-log { display: flex; flex-direction: column; gap: 11px; min-height: 112px; max-height: min(32vh, 290px); max-height: min(32dvh, 290px); padding: 13px; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-gutter: stable; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 17px; }
.companion-log:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.companion-message { align-self: flex-start; flex: 0 0 auto; width: fit-content; max-width: 92%; padding: 11px 13px; color: var(--ink); background: var(--paper); border: 1px solid var(--line-soft); border-radius: 14px 14px 14px 4px; }
.companion-message.own { align-self: flex-end; background: var(--accent-soft); border-radius: 14px 14px 4px 14px; }
.companion-message > strong { display: block; margin-bottom: 4px; color: var(--accent-ink); font-size: 11px; line-height: 1.5; }
.companion-message p { font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.companion-status { min-height: 25px; padding-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.companion-error { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 15px; padding: 13px; color: var(--danger); background: var(--danger-soft); border: 1px solid var(--line); border-radius: 12px; }
.companion-error p { flex: 1 1 180px; min-width: 0; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.companion-replies { display: flex; flex-wrap: wrap; gap: 9px; }
.companion-replies > .button { min-height: 44px; padding: 10px 14px; font-size: 13px; }
.companion-hint, .companion-preview-note { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.companion-preview-note { margin: 0 0 15px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; }
.companion-quiz { margin-top: 19px; padding: 17px; background: #f3f7ef; border: 1px solid #d5e0ca; border-radius: 17px; }
.companion-quiz-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px; margin-bottom: 10px; }
.companion-quiz-heading h3 { font-size: 18px; }
.companion-riddle { color: var(--ink); font-size: 15px; line-height: 1.6; }
.companion-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.companion-choice { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px; min-width: 0; min-height: 44px; padding: 12px 8px; color: var(--ink); background: var(--paper); border: 2px solid transparent; outline: 1px solid var(--line-soft); border-radius: 14px; }
.companion-choice img { width: min(100%, 100px); height: auto; aspect-ratio: 1; object-fit: contain; }
.companion-choice strong { font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.companion-choice small { font-size: 11px; line-height: 1.45; color: #526a41; }
.companion-choice:hover:not(:disabled), .companion-choice:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }
.companion-choice:disabled { cursor: default; }
.companion-choice.is-tried { opacity: .62; }
.companion-choice.is-correct { color: #3e592f; background: #e6f1dd; border-color: #83a467; opacity: 1; }
.companion-quiz.is-solved { animation: lumi-solved .5s ease-out both; }
.companion-feedback { margin: 13px 0 0; color: #476335; font-size: 14px; font-weight: 650; line-height: 1.6; }
.companion-quiz > .button { margin-top: 13px; }
@keyframes lumi-solved { from { transform: scale(.99); } to { transform: scale(1); } }
@media (max-width: 479px) {
  .companion-card { gap: 13px; padding: 18px; }
  .companion-card-copy { flex: 1 1 140px; }
  .companion-card .lumi-mascot { flex-basis: 72px; width: 72px; height: 78px; }
  .companion-card > .button { flex: 1 1 100%; }
  .companion-intro { gap: 12px; }
  .companion-intro > img { flex-basis: 66px; width: 66px; height: 72px; }
  .companion-quiz { padding: 13px; }
  .companion-choices { gap: 7px; }
  .companion-choice { padding: 9px 5px; }
  .companion-choice strong { font-size: 11px; }
  .companion-replies > .button { flex: 1 1 110px; }
}
@media (prefers-reduced-motion: reduce) {
  .lumi-mascot, .companion-quiz.is-solved { animation: none; transform: none; }
}
@media (forced-colors: active) {
  .companion-card, .companion-message, .companion-quiz, .companion-choice { border: 1px solid ButtonText; }
  .companion-choice.is-correct { border-width: 3px; }
}

/* Invites are readable, copyable and easy to withdraw. */
.circle-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 17px;
  min-width: 0;
  margin-bottom: 24px;
  padding: 22px;
  background: linear-gradient(115deg, var(--accent-pale), var(--peach-soft));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.circle-banner > div:first-child { flex: 1 1 230px; min-width: 0; }
.circle-banner h2, .circle-banner h3 { overflow-wrap: anywhere; }
.circle-banner p { max-width: 580px; margin-top: 7px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.circle-count { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; flex: 0 0 auto; max-width: 100%; padding: 11px 15px; color: var(--accent-ink); background: var(--paper); border: 1px solid var(--line-soft); border-radius: 13px; font-size: 13px; font-weight: 750; }
.circle-count strong { font-size: 27px; line-height: 1.2; }
.circle-count strong span { color: var(--muted); font-size: 16px; font-weight: 650; }
.circle-count small { color: var(--muted); font-size: 11px; }
.circle-actions { display: flex; flex-wrap: wrap; align-items: center; flex: 1 1 100%; gap: 10px; min-width: 0; }
.circle-banner > .hint { flex: 1 1 100%; margin: 0; font-size: 12px; }
.invites-list { display: flex; flex-direction: column; min-width: 0; margin-top: 15px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 17px; }
.circle-banner > .invites-list { flex: 1 1 100%; width: 100%; margin-top: 0; }
.invites-list > h3 { padding: 16px 17px 0; font-size: 15px; }
.invites-list > .hint { max-width: none; margin: 0; padding: 0 17px 17px; font-size: 12px; }
.invite-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; min-width: 0; padding: 15px 17px; }
.invite-row + .invite-row { border-top: 1px solid var(--line-soft); }
.invite-row > span { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.invite-row > small { color: var(--muted); font-size: 12px; }
.invite-meta { flex: 1 1 175px; min-width: 0; overflow-wrap: anywhere; }
.invite-meta strong { display: block; color: var(--ink); font-size: 13px; line-height: 1.5; }
.invite-meta small, .invite-meta p { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.invite-row > .button { flex-shrink: 0; }
.invite-panel { display: grid; gap: 14px; min-width: 0; margin-top: 18px; padding: 18px; background: var(--accent-pale); border: 1px dashed #c9bada; border-radius: 17px; overflow-wrap: anywhere; }
.invite-panel > p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.invite-panel .form-field { margin: 0; }
.invite-url { display: block; width: 100%; min-width: 0; max-width: 100%; font-family: system-ui, sans-serif; letter-spacing: 0; direction: ltr; unicode-bidi: isolate; }
.invite-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; min-width: 0; }
.invite-actions > .button { flex: 1 1 140px; }
.invite-empty { padding: 20px 16px; color: var(--muted); background: var(--accent-pale); border: 1px dashed var(--line); border-radius: 15px; font-size: 13px; line-height: 1.65; }

/* One shared conversation, with controls that remain easy to reach. */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 20px; min-width: 0; }
.chat-layout > * { min-width: 0; }
.chat-panel { min-width: 0; padding: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.chat-aside { display: grid; gap: 17px; min-width: 0; }
.chat-aside h2, .chat-aside h3 { font-size: 18px; }
.chat-aside > .section-heading { align-items: center; margin: 0; }
.chat-rules { padding: 16px; color: var(--muted); background: var(--accent-pale); border: 1px solid var(--line-soft); border-radius: 16px; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.chat-panel > .chat-rules { display: flex; align-items: flex-start; gap: 10px; padding: 15px 18px; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; }
.chat-rules > .ui-icon { margin-top: 3px; }
.chat-rules strong { color: var(--ink); }
.chat-rules ul { margin-top: 12px; margin-bottom: 0; padding-left: 19px; }
.chat-rules .ui-icon { flex: 0 0 17px; width: 17px; height: 17px; color: var(--accent); }
.chat-log {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  height: min(50vh, 520px);
  height: min(50dvh, 520px);
  max-height: 50vh;
  max-height: 50dvh;
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #cabbd2 transparent;
  scroll-behavior: auto;
}
.chat-log:focus-visible { outline-offset: -4px; }
.chat-message { display: flex; flex-direction: column; align-items: flex-start; align-self: flex-start; flex: 0 0 auto; min-width: 0; max-width: 94%; padding: 12px 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line-soft); border-radius: 16px 16px 16px 5px; }
.chat-message.own { align-self: flex-end; background: var(--accent-soft); border-color: rgb(var(--accent-rgb), .12); border-radius: 16px 16px 5px 16px; }
.chat-message.hidden { color: var(--muted); background: var(--paper); border-style: dashed; border-color: var(--line); }
.chat-message.hidden .message-text { color: var(--muted); font-style: italic; }
.chat-message.hunt-message { background: #f1f6e9; border-color: #d2dfc3; }
.hunt-message-content { display: flex; align-items: center; gap: 12px; min-width: 0; padding-top: 3px; }
.hunt-message-stamp { display: block; flex: 0 0 60px; width: 60px; height: 60px; padding: 5px; object-fit: contain; background: #fffef9; border: 1px dashed #a9ba96; border-radius: 7px; }
.hunt-message-copy { min-width: 0; }
.hunt-message-label { display: block; margin-bottom: 4px; color: #526a41; font-size: 10px; font-weight: 750; line-height: 1.5; }
.hunt-message-copy .message-text { margin: 0; }
.message-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; width: 100%; min-width: 0; margin-bottom: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.message-author { min-width: 0; color: var(--accent-ink); font-size: 12px; font-weight: 800; overflow-wrap: anywhere; }
.message-meta time, .message-meta small { flex-shrink: 0; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.message-text { width: 100%; min-width: 0; color: var(--ink); font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
.report-button { display: inline-flex; align-items: center; justify-content: center; align-self: flex-end; gap: 5px; min-width: 44px; min-height: 44px; max-width: 100%; margin: 3px -6px -5px 0; padding: 8px 9px; color: var(--muted); background: transparent; border: 0; border-radius: 9px; font-size: 11px; font-weight: 700; line-height: 1.4; }
.report-button .ui-icon { flex: 0 0 14px; width: 14px; height: 14px; }
.report-button:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1 0 auto; gap: 12px; min-width: 0; padding: 25px 12px; color: var(--muted); font-size: 14px; line-height: 1.6; text-align: center; }
.chat-empty > .ui-icon { flex: 0 0 58px; width: 58px; height: 58px; padding: 13px; color: var(--accent); background: var(--accent-soft); border-radius: 18px; }
.chat-empty h3, .chat-empty strong { color: var(--ink); font-size: 17px; }
.chat-empty p { max-width: 300px; }
.chat-composer { min-width: 0; padding: 16px 18px; background: var(--paper); border-top: 1px solid var(--line-soft); }
.chat-composer > label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.chat-composer .form-field { margin-bottom: 0; }
textarea.chat-textarea { display: block; width: 100%; min-width: 0; min-height: 90px; max-height: 240px; padding: 12px 13px; line-height: 1.5; resize: vertical; }
.chat-compose-bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; min-width: 0; margin-top: 10px; }
.chat-count { color: var(--muted); font-size: 11px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.chat-compose-bottom > .button { min-height: 44px; margin-left: auto; }
.chat-disabled { padding: 16px 18px; color: var(--muted); background: var(--accent-pale); border-top: 1px solid var(--line-soft); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-composer > .chat-disabled { margin-top: 12px; padding: 12px; border: 1px solid var(--line-soft); border-radius: 11px; font-size: 13px; }
.chat-member { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.chat-member:last-child { border-bottom: 0; padding-bottom: 0; }
.chat-member > div { flex: 1 1 auto; min-width: 0; }
.chat-member .profile-avatar { flex-shrink: 0; }
.chat-member strong, .chat-member > span:not(.profile-avatar) { min-width: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-member small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.chat-live { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--success); font-size: 11px; font-weight: 650; line-height: 1.5; }
.chat-live .status-dot { flex-basis: 6px; width: 6px; height: 6px; }
.chat-live.offline { color: var(--muted); }
.chat-live.offline .status-dot { background: currentColor; }

/* Six complete touch targets fit in the same bottom rail, including at 320 px. */
@media (max-width: 1019px) {
  .nav-list { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-flow: row; grid-auto-columns: auto; gap: 0; padding-right: max(2px, env(safe-area-inset-right)); padding-left: max(2px, env(safe-area-inset-left)); overflow-x: visible; }
  .nav-button { min-width: 44px; padding-right: 1px; padding-left: 1px; }
  .nav-label { font-size: clamp(9.5px, 2.5vw, 11px); letter-spacing: -.1px; }
}

@media (max-width: 479px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding-top: 11px; padding-bottom: 11px; }
  .topbar > .crumb { flex: 1 0 100%; font-size: 11px; }
  .topbar-actions { flex: 1 1 100%; width: 100%; gap: 8px; }
  .profile-identity { flex: 1 1 auto; max-width: none; }
  .profile-identity > span:last-child { flex: 1 1 auto; }
  .topbar-actions > .icon-button { flex: 0 0 44px; }
  .connection-note { margin-top: 12px; margin-bottom: 21px; font-size: 11px; }
  .gate-layout { gap: 12px; }
  .gate-art { max-height: 155px; }
  .gate-brand { margin-bottom: 21px; }
  .circle-banner { padding: 18px; gap: 14px; }
  .circle-actions { width: 100%; }
  .circle-actions > .button { flex: 1 1 140px; }
  .invite-row { padding: 14px; }
  .invite-panel { padding: 15px; }
  .chat-log { padding: 13px 11px; gap: 10px; }
  .chat-message { max-width: 97%; padding: 10px 12px; }
  .chat-composer { padding: 14px 12px; }
  .chat-compose-bottom { gap: 8px; }
  .chat-aside { gap: 14px; }
}

@media (min-width: 820px) {
  #app.network-gate { padding: 40px; }
  .gate-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 30px; }
  .gate-art { max-height: none; }
  .gate-card { justify-self: end; }
}

@media (min-width: 900px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr) minmax(210px, .42fr); }
  .chat-aside { position: sticky; top: 24px; }
  .chat-message { max-width: 88%; }
}

@media (prefers-contrast: more) {
  .gate-card, .circle-banner, .chat-panel, .chat-message, .invite-panel { border-color: #b7a9bc; }
  .chat-rules, .gate-fineprint, .chat-count, .message-meta, .report-button { color: #62556a; }
}

@media (forced-colors: active) {
  .profile-identity, .circle-count, .chat-message, .report-button { border: 1px solid ButtonText; }
  .chat-message.own { border-width: 2px; }
  .connection-note.offline { border-style: dashed; }
}
