/* Ravenpost — castle-dark theme with parchment scrolls */

:root {
  color-scheme: dark;
  --bg: #12141a;
  --bg-deep: #0c0d11;
  --panel: #1b1e26;
  --panel-2: #222631;
  --border: #333845;
  --ink: #e8e2d2;
  --muted: #918c7b;
  --faint: #6b675c;
  --gold: #c9a227;
  --gold-bright: #e6c15c;
  --online: #5aa469;
  --crimson: #8d2626;
  --parchment: #efe5cc;
  --parchment-edge: #d9c9a3;
  --parchment-ink: #2b2314;
  --parchment-muted: #7a6c50;
  --display: 'Cinzel', 'Times New Roman', serif;
  --medieval: 'IM Fell English', Georgia, serif;
  --body: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

/* The hidden attribute is only a UA-stylesheet display:none, so any rule like
   `.reply-bar { display: flex }` silently overrides it. Make it always win. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

/* dvh tracks the *dynamic* mobile viewport (browser chrome collapsing),
   so the composer never hides behind Safari's bottom toolbar. */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

/* Installed to a home screen there is no collapsing browser chrome, so dvh
   buys nothing — and on iOS it misbehaves around the software keyboard,
   leaving the page shrunk/shifted after dismissal (a dead strip below the
   composer). The plain containing-block height is stable there. app.js also
   snaps window scroll back to 0 when the keyboard goes away. */
@media (display-mode: standalone) {
  html, body { height: 100%; }
}

body {
  background:
    radial-gradient(1200px 700px at 70% -10%, #232838 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #1d2130 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Installed to a home screen (status bar black-translucent, viewport-fit
     cover) the page extends under the status bar / notch; keep the app
     inside the safe area. All zero in a normal browser tab. Bottom insets
     are handled per-component (composer, toast, …) so scrollable content
     can still run beneath the home indicator. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0
    env(safe-area-inset-left, 0px);
}

#app { height: 100%; }

/* app.js pins the app to the visual viewport while the software keyboard is
   up (iOS pans the layout viewport rather than resizing it). --vv-top/-height
   follow the pan so the app covers exactly the visible area; the padding keeps
   the header out from under the status bar, which stays overlaid at the
   physical top. Fixed positioning ignores body's safe-area padding, hence the
   env() here too. */
#app.vv-pinned {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top, 0px);
  height: var(--vv-height, 100%);
  padding-top: env(safe-area-inset-top, 0px);
}

h1, h2, h3 { font-family: var(--display); letter-spacing: 0.04em; margin: 0; }

button {
  font-family: var(--display);
  letter-spacing: 0.06em;
  cursor: pointer;
}

input, textarea {
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  /* 16px minimum: anything smaller makes iOS Safari zoom the page on focus. */
  font-size: 16px;
  width: 100%;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.18);
}

.btn {
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 13px;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}

.btn:hover { background: rgba(201, 162, 39, 0.12); }

.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #241d07;
  border: 1px solid #8a6d14;
  font-weight: 700;
}

.btn-primary:hover { background: linear-gradient(180deg, #f0cd6d, #d4ac2e); }

.btn-quiet {
  border-color: var(--border);
  color: var(--muted);
}

.btn:disabled { opacity: 0.5; cursor: default; }

.error-note {
  color: #e08585;
  font-family: var(--medieval);
  font-style: italic;
  margin: 8px 0 0;
  min-height: 1.2em;
}

/* ------------------------------------------------------------------ gate */

.gate {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.gate-brand {
  font-size: 34px;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.12em;
}

.gate-sub {
  font-family: var(--medieval);
  font-style: italic;
  color: var(--muted);
  margin: 6px 0 24px;
}

.gate-raven { font-size: 42px; line-height: 1; margin-bottom: 8px; }

.gate-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.gate-tabs button {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.gate-tabs button.active {
  background: var(--panel-2);
  color: var(--gold-bright);
}

.gate form { display: grid; gap: 12px; text-align: left; }

.gate label {
  font-family: var(--display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

/* ------------------------------------------------------------------ app shell */

/* minmax(0, 1fr): a plain 1fr track grows to fit content min-width, which on
   phones forces the layout viewport wider and zooms the whole app out. */
.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100%;
}

.sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.side-brand .name {
  font-family: var(--display);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
}

.side-brand .tag {
  font-family: var(--medieval);
  font-style: italic;
  font-size: 12px;
  color: var(--faint);
}

.side-user-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 12px;
  border-bottom: 1px solid var(--border);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 12px 18px;
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 0;
  flex: 1;
  min-width: 0;
  text-align: left;
  color: var(--ink);
  font-family: var(--body);
}

.side-user:hover { background: var(--panel); }

.side-user .who { min-width: 0; flex: 1; }

.side-user .who .dn {
  display: block;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-user .who .hn {
  display: block;
  font-family: var(--medieval);
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-icons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.icon-btn svg { width: 17px; height: 17px; }

.icon-btn:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.08);
}

/* Small variant: message-row actions, same visual language as the sidebar. */
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }

.icon-btn.sm svg { width: 14px; height: 14px; }

.side-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 14px;
}

.side-actions .btn { padding: 8px 6px; font-size: 11px; }

.side-form { padding: 0 14px 12px; display: grid; gap: 8px; }

.hall-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
  min-height: 0;
  padding: 4px 8px calc(16px + env(safe-area-inset-bottom, 0px));
}

.hall-item {
  width: 100%;
  display: block;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 10px;
  color: var(--ink);
  font-family: var(--body);
  margin-top: 4px;
  min-width: 0;
  overflow: hidden;
}

.hall-item:hover { background: var(--panel); }

.hall-item.active {
  background: var(--panel-2);
  border-color: var(--border);
}

.hall-item .hall-name {
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.03em;
  color: var(--gold-bright);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.hall-item .hall-name > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hall-item .hall-name .count {
  color: var(--faint);
  font-size: 12px;
  flex-shrink: 0;
}

.hall-item .hall-name .count svg { width: 11px; height: 11px; vertical-align: -1px; }

.hall-item .preview {
  display: block;
  max-width: 100%;
  font-family: var(--medieval);
  font-style: italic;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.hall-empty {
  color: var(--faint);
  font-family: var(--medieval);
  font-style: italic;
  text-align: center;
  padding: 24px 12px;
}

/* ------------------------------------------------------------------ content */

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.hall-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.hall-header .back { display: none; }

.hall-header h2 {
  font-size: 18px;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hall-header .code { flex-shrink: 0; }

.hall-header .code {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--gold-bright);
  background: var(--bg-deep);
  border: 1px dashed var(--gold);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}

.hall-header .code:hover { background: rgba(201, 162, 39, 0.1); }

.hall-header .code svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 2px; }

.hall-header .spacer { flex: 1; }

.member-strip { display: flex; gap: 4px; }

.member-strip .sigil-avatar { width: 30px; height: 36px; cursor: pointer; }

/* Presence dot: sits at the top-right of a roster sigil, hidden until the
   wrapper is marked .online. The ring matches the header background so the
   dot reads as a badge floating above the shield. */
.member-strip .sigil-wrap { position: relative; display: inline-flex; }

.pres-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px rgba(90, 164, 105, 0.7);
  display: none;
}

.sigil-wrap.online .pres-dot { display: block; }

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Horizontal padding grows on wide screens to keep the thread a readable
     centered column without a wrapper element. */
  padding: 22px max(22px, calc((100% - 1000px) / 2));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.load-older {
  align-self: center;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--medieval);
  font-style: italic;
  text-decoration: underline;
}

.msg {
  display: flex;
  gap: 12px;
  /* min(…, 100%) also beats the min-content width of nowrap children (the
     reply quote), which would otherwise push right-aligned bubbles offscreen. */
  max-width: min(760px, 100%);
  align-self: flex-start;
}

.msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg.mine .meta { justify-content: flex-end; }

.msg.mine .scroll-card {
  background: linear-gradient(175deg, #f2e2b8 0%, #e9d9ae 55%, #ddca94 100%);
  border-radius: 10px 3px 10px 3px;
}

.msg.mine .scroll-card::before { border-radius: 8px 2px 8px 2px; }

.msg .sigil-avatar {
  width: 42px;
  height: 50px;
  flex-shrink: 0;
  cursor: pointer;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
}

.msg .body { min-width: 0; }

.msg .meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin-bottom: 4px;
  min-height: 26px; /* room for the action icon buttons, no jump on hover */
}

.msg .meta .dn {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-bright);
  cursor: pointer;
}

.msg .meta .hn {
  font-family: var(--medieval);
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
}

.msg .meta .ts { font-size: 11px; color: var(--faint); }

.scroll-card {
  background: linear-gradient(175deg, #f4ebd3 0%, var(--parchment) 55%, #e6d8b6 100%);
  border: 1px solid var(--parchment-edge);
  border-radius: 3px 10px 3px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  padding: 10px 14px 8px;
  color: var(--parchment-ink);
  position: relative;
}

.scroll-card::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(122, 108, 80, 0.25);
  border-radius: 2px 8px 2px 8px;
  pointer-events: none;
}

.scroll-card .converted {
  font-family: var(--medieval);
  font-size: 17px;
  line-height: 1.45;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.scroll-card .original {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dotted rgba(122, 108, 80, 0.45);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 12px;
  color: var(--parchment-muted);
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.scroll-card .original .lbl {
  font-variant: small-caps;
  letter-spacing: 0.06em;
  margin-right: 6px;
  color: #a08e69;
}

/* Per-account preference: hide the plain-speech line under each scroll. */
.hide-common-tongue .scroll-card .original { display: none; }

.msg .meta .msg-actions {
  display: inline-flex;
  gap: 4px;
  align-self: center;
  opacity: 0;
  transition: opacity 0.12s;
}

.msg:hover .meta .msg-actions { opacity: 1; }

.reply-quote {
  font-family: var(--medieval);
  font-style: italic;
  font-size: 13px;
  color: var(--parchment-muted);
  border-left: 3px solid rgba(122, 108, 80, 0.45);
  padding: 2px 8px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-quote svg { width: 12px; height: 12px; vertical-align: -2px; }

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}

.msg.mine .reactions { justify-content: flex-end; }

.react-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.react-chip .n { font-size: 11px; color: var(--muted); font-family: var(--display); }

.react-chip:hover { border-color: var(--gold); }

.react-chip.mine {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.16);
}

.react-chip.mine .n { color: var(--gold-bright); }

.emoji-pop {
  position: fixed;
  z-index: 50;
  display: flex;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 6px 8px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}

.emoji-pop button {
  background: none;
  border: none;
  font-size: 19px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
}

.emoji-pop button:hover { background: rgba(201, 162, 39, 0.18); }

.typing-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 22px 6px;
  font-family: var(--medieval);
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
  min-width: 0;
}

.typing-bar b { color: var(--gold-bright); font-weight: 600; }

.typing-sigils { display: flex; gap: 3px; flex-shrink: 0; }

/* Slight bob, staggered per sigil, so a row of them reads as "scribbling". */
.typing-sigil svg { width: 16px; height: 19px; animation: quill-bob 1.3s ease-in-out infinite; }
.typing-sigil:nth-child(2) svg { animation-delay: 0.15s; }
.typing-sigil:nth-child(3) svg { animation-delay: 0.3s; }
.typing-sigil:nth-child(n + 4) svg { animation-delay: 0.45s; }

@keyframes quill-bob {
  0%, 50%, 100% { transform: translateY(0); }
  25% { transform: translateY(-2px); }
}

.typing-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-bar .dots span { animation: quill-dot 1.3s infinite; }
.typing-bar .dots span:nth-child(2) { animation-delay: 0.22s; }
.typing-bar .dots span:nth-child(3) { animation-delay: 0.44s; }

@keyframes quill-dot {
  0%, 55%, 100% { opacity: 0.2; }
  25% { opacity: 1; }
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 13px;
  min-width: 0;
}

.reply-bar .who { color: var(--gold-bright); font-family: var(--display); flex-shrink: 0; }

.reply-bar .who svg { width: 13px; height: 13px; vertical-align: -2px; }

.reply-bar .snip {
  font-family: var(--medieval);
  font-style: italic;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.reply-bar .cancel {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
}

.reply-bar .cancel:hover { color: var(--gold-bright); }

.messages-empty {
  margin: auto;
  text-align: center;
  color: var(--faint);
  font-family: var(--medieval);
  font-style: italic;
  font-size: 18px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 22px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--panel);
}

/* Keyboard up (see #app.vv-pinned): the home indicator sits behind the
   keyboard, so its safe-area padding would just be a gap above the keys. */
#app.vv-pinned .composer { padding-bottom: 18px; }

.composer textarea {
  resize: none;
  height: 52px;
  min-height: 52px;
  max-height: 140px; /* JS autogrows the inline height up to this */
  font-size: 16px;
}

.composer .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 22px;
  min-height: 52px;
  white-space: nowrap;
}

.composer .send-btn svg { width: 17px; height: 17px; }

.no-hall {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-family: var(--medieval);
  font-style: italic;
  font-size: 19px;
  padding: 40px;
}

/* ------------------------------------------------------------------ forge & profile */

.page {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  min-height: 0;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

/* The profile ("Thy Standard") page centers its column on the page. */
.page-profile .page-head,
.page-profile .profile-card,
.page-profile .settings {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.page-head h2 { color: var(--gold-bright); font-size: 22px; }

.page-head .sub {
  font-family: var(--medieval);
  font-style: italic;
  color: var(--muted);
}

.forge-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 28px;
  max-width: 1000px;
}

.forge-preview {
  text-align: center;
  position: sticky;
  top: 0;
}

.forge-preview .sigil-svg {
  width: 240px;
  height: 288px;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6));
}

.forge-preview .house-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  margin-top: 12px;
}

.forge-preview .house-words {
  font-family: var(--medieval);
  font-style: italic;
  color: var(--gold-bright);
  margin-top: 2px;
}

.forge-controls { display: grid; gap: 22px; }

.forge-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 10px;
}

.opt-row { display: flex; flex-wrap: wrap; gap: 8px; }

.opt {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 12px;
  font-size: 12px;
}

.opt:hover { border-color: var(--gold); }

.opt.selected {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.14);
  color: var(--gold-bright);
}

.opt .glyph-thumb { width: 34px; height: 34px; display: block; margin: 0 auto 4px; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid var(--border);
  padding: 0;
}

.swatch.selected {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(230, 193, 92, 0.35);
}

.forge-fields { display: grid; gap: 12px; max-width: 420px; }

.forge-fields .words-row { display: flex; gap: 8px; }

.forge-fields .words-row .btn {
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.forge-fields .words-row .btn svg { width: 14px; height: 14px; }

.forge-save { display: flex; gap: 12px; align-items: center; }

.save-note {
  font-family: var(--medieval);
  font-style: italic;
  color: #8fbf7f;
}

.profile-card {
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
  text-align: center;
}

.profile-card .sigil-svg {
  width: 210px;
  height: 252px;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6));
}

.profile-card .dn { font-family: var(--display); font-size: 26px; font-weight: 700; margin-top: 16px; }

.profile-card .un { color: var(--faint); font-size: 14px; }

.profile-card .presence {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--medieval);
  font-size: 14px;
  color: var(--muted);
}

.profile-card .presence .pres-dot {
  position: static;
  display: block;
  border-color: var(--panel);
}

.profile-card .presence.online { color: var(--gold-bright); }

.profile-card .presence.away .pres-dot {
  background: var(--faint);
  box-shadow: none;
}

.profile-card .hn {
  font-family: var(--display);
  color: var(--gold-bright);
  font-size: 18px;
  margin-top: 10px;
}

.profile-card .hw {
  font-family: var(--medieval);
  font-style: italic;
  font-size: 17px;
  color: var(--muted);
  margin-top: 4px;
}

.profile-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

/* Device settings (install + push) below the profile card */

.settings {
  max-width: 560px;
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.settings-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
}

.settings-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 10px;
}

.setting-note {
  font-family: var(--medieval);
  font-style: italic;
  color: var(--muted);
  font-size: 15px;
  margin: 8px 0 0;
}

.setting .setting-note:first-child { margin-top: 0; }

/* Tone-of-voice picker (settings) */
.setting-tone {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.setting-tone .toggle-title { display: block; }
.setting-tone .toggle-text .setting-note { margin-top: 2px; }

.tone-row { margin-top: 12px; }

.tone-row .opt {
  font-family: var(--medieval);
  font-size: 14px;
  padding: 7px 14px;
  cursor: pointer;
}

/* Toggle switch (settings) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.toggle-text { display: block; }

.toggle-title {
  display: block;
  font-family: var(--medieval);
  font-size: 16px;
  color: var(--parchment);
}

.toggle-row .setting-note { margin-top: 2px; }

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.switch input:checked + .switch-track {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--gold);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
  background: #1b1e26;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ modal */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 9, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}

.modal-back .profile-card { box-shadow: 0 40px 90px rgba(0, 0, 0, 0.7); }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--medieval);
  font-style: italic;
  z-index: 60;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 780px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar { display: flex; }
  .content { display: none; }

  .shell.in-room .sidebar { display: none; }
  .shell.in-room .content { display: flex; }

  .hall-header { padding: 10px 12px; gap: 10px; }
  .hall-header .back {
    display: inline-block;
    background: none;
    border: none;
    color: var(--gold-bright);
    font-size: 22px;
    padding: 4px 10px 4px 2px;
  }

  .member-strip { display: none; }
  .messages { padding: 14px 12px; gap: 12px; }

  /* Narrower bubbles so mine-right / theirs-left actually reads on a phone. */
  .msg { max-width: min(680px, 88%); gap: 8px; }
  .msg .sigil-avatar { width: 34px; height: 40px; }
  /* Your own sigil is redundant next to your own bubble; reclaim the width. */
  .msg.mine .sigil-wrap { display: none; }
  .msg .meta .hn { display: none; }
  .scroll-card { padding: 9px 12px 7px; }
  .scroll-card .converted { font-size: 16px; }

  /* No hover on touch screens: actions always visible, with finger-size targets. */
  .msg .meta .msg-actions { opacity: 1; }
  .msg .meta .msg-actions .icon-btn.sm { width: 32px; height: 32px; }
  .msg .meta .msg-actions .icon-btn.sm svg { width: 16px; height: 16px; }
  .react-chip { padding: 5px 12px; font-size: 14px; }

  /* Reaction picker becomes a bottom sheet (positioned here, not by JS). */
  .emoji-pop.sheet {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 10px 8px;
  }
  .emoji-pop button { font-size: 24px; padding: 8px 10px; }

  .composer { padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
  #app.vv-pinned .composer { padding-bottom: 10px; }
  .composer textarea { height: 46px; min-height: 46px; }
  /* Icon-only send button on phones. */
  .composer .btn-primary { min-height: 46px; padding: 0 16px; }
  .composer .send-btn .send-label { display: none; }
  .composer .send-btn svg { width: 19px; height: 19px; }
  .reply-bar { padding: 8px 12px; }
  .typing-bar { padding: 3px 12px 5px; }

  .page { padding: 18px 14px; }
  .forge-grid { grid-template-columns: 1fr; }
  .forge-preview { position: static; }
  /* Finger-size forge controls. */
  .swatch { width: 40px; height: 40px; }
  .opt { padding: 10px 12px; }

  .gate { padding: 16px; }
  .gate-card { padding: 28px 20px 22px; }

  .profile-card { padding: 26px 18px; }
  .profile-card .sigil-svg { width: 160px; height: 192px; }
  .profile-card .dn { font-size: 22px; }
  .profile-actions { flex-wrap: wrap; }
}
