:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --line: #dfe3e8;
  --text: #121821;
  --muted: #5b6676;
  --accent: #0f766e;
  --accent-2: #115e59;
  --accent-soft: #e2f4f1;
  --accent-ink: #ffffff;
  --mine: #d6f1ec;
  --mine-ink: #0d2a27;
  --other: #ffffff;
  --danger: #b4232a;
  --danger-soft: #fdeceb;
  --warn: #9a5b00;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 18px rgba(16, 24, 40, 0.08);
  --radius: 14px;
  --wm-opacity: 0.075;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --panel: #121820;
    --panel-2: #18202a;
    --line: #26303c;
    --text: #e7edf3;
    --muted: #93a0b0;
    --accent: #2dd4bf;
    --accent-2: #5eead4;
    --accent-soft: #10302d;
    --accent-ink: #04201d;
    --mine: #134540;
    --mine-ink: #e6fbf7;
    --other: #1b2430;
    --danger: #f87171;
    --danger-soft: #3a1717;
    --warn: #f5b04c;
    --focus: #60a5fa;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --wm-opacity: 0.11;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  min-height: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-text {
  font: 700 7px var(--font);
  fill: currentColor;
  stroke: none;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.pad {
  padding: 12px 16px;
}

.center {
  text-align: center;
}

.block {
  display: block;
}

/* Screenshot deterrents: nothing selectable, nothing draggable, nothing printable. */
.chat,
.admin-layer,
.modal-layer,
.lightbox,
.auth-card pre {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
.allow-select,
.allow-select * {
  -webkit-user-select: text;
  user-select: text;
}

img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

#shield {
  display: none;
}

html.signed-in.shielded #shield {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}

html.signed-in.shielded body > :not(#shield) {
  filter: blur(26px) saturate(0.4);
}

.shield-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 28px;
  max-width: 320px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--muted);
}

.shield-card .icon {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.shield-card p {
  margin: 0;
}

.wm-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-image: var(--wm);
  background-size: var(--wm-size, 340px 190px);
  opacity: var(--wm-opacity);
}

@media print {
  body * {
    display: none !important;
  }

  body::after {
    content: "Ispis nije dozvoljen. Printing is disabled.";
    display: block;
    padding: 40px;
    font: 18px var(--font);
  }
}

/* Buttons and inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover {
  background: var(--accent-2);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}

.btn.ghost:hover {
  background: var(--panel-2);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
}

.btn.wide {
  width: 100%;
}

.btn:disabled,
.icon-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}

.icon-btn:hover,
.icon-btn.on {
  background: var(--panel-2);
  color: var(--text);
}

.icon-btn.accent {
  background: var(--accent);
  color: var(--accent-ink);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-align: left;
}

.link-btn:hover {
  text-decoration: underline;
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.input {
  resize: vertical;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
}

.field small {
  font-size: 12px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
}

.check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.password-wrap {
  position: relative;
}

.password-wrap .input {
  padding-right: 44px;
}

.reveal {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle-ui {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  margin-top: 1px;
  border-radius: 99px;
  background: var(--line);
  transition: background 0.15s;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.toggle input:checked + .toggle-ui {
  background: var(--accent);
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(18px);
}

.toggle input:focus-visible + .toggle-ui {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.toggle-label {
  display: grid;
  gap: 2px;
  font-weight: 600;
}

.toggle-label small {
  font-weight: 400;
  color: var(--muted);
}

.badge,
.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge .icon,
.chip .icon {
  width: 14px;
  height: 14px;
}

.badge.admin {
  margin-left: 6px;
  padding: 0 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pill.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.off,
.chip.off {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
}

.notice .icon {
  color: var(--accent);
}

.form-error {
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}

.avatar.online::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--panel);
}

/* Auth screens */
.auth {
  min-height: 100dvh;
  overflow-y: auto;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 24px 16px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.auth-card > p {
  margin: 0 0 16px;
}

.auth-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 22px;
}

.auth-brand p {
  margin: 0;
  font-size: 13px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
}

.brand-mark.big {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}

.brand-mark.big .icon {
  width: 26px;
  height: 26px;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.auth-links {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
  font-size: 14px;
}

.auth-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.lang-switch {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 600;
}

.rules-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
}

.rules-box summary {
  cursor: pointer;
  font-weight: 600;
}

.rules-text {
  margin: 10px 0 0;
  white-space: pre-wrap;
  font: 14px/1.55 var(--font);
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* Chat layout */
.chat {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: 100dvh;
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.side-tools {
  display: flex;
  gap: 8px;
  padding: 4px 12px 10px;
}

.search {
  border-radius: 99px;
  background: var(--panel-2);
}

.room-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.list-head {
  margin: 14px 8px 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.room {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
}

.room:hover {
  background: var(--panel-2);
}

.room.active {
  background: var(--accent-soft);
}

.room-hash {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 800;
  font-size: 18px;
}

.room.active .room-hash {
  background: var(--accent);
  color: var(--accent-ink);
}

.room-text {
  display: grid;
  min-width: 0;
  flex: 1;
}

.room-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room.has-unread .room-name {
  font-weight: 800;
}

.room-last {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.room-meta .icon {
  width: 15px;
  height: 15px;
}

.unread {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
}

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

.user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.conv-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
}

.conv-empty {
  margin: auto;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.conv-empty h2 {
  margin: 8px 0 0;
  color: var(--text);
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
}

.empty-mark .icon {
  width: 32px;
  height: 32px;
}

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

.conv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.conv-id {
  display: grid;
  flex: 1;
  min-width: 0;
  padding: 2px 4px;
  border: 0;
  background: none;
  text-align: left;
}

.conv-title {
  margin: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-sub {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-sub.typing-on {
  color: var(--accent);
  font-weight: 600;
}

.conv-badges {
  display: flex;
  gap: 6px;
}

.badge.timer {
  background: var(--accent-soft);
  color: var(--accent);
}

.only-narrow {
  display: none;
}

.conv-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.msgs {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px clamp(8px, 3vw, 28px) 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day {
  align-self: center;
  margin: 12px 0 8px;
  padding: 3px 12px;
  border-radius: 99px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.start-note,
.no-msgs {
  align-self: center;
  max-width: 420px;
  margin: 8px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.older {
  align-self: center;
  margin: 6px 0;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 600;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 8px;
  max-width: 100%;
}

.msg.cont {
  margin-top: 2px;
}

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

.msg-avatar {
  width: 36px;
  flex: none;
}

.msg-col {
  display: flex;
  flex-direction: column;
  max-width: min(640px, 78%);
  min-width: 0;
}

.msg.mine .msg-col {
  align-items: flex-end;
}

.bubble {
  position: relative;
  padding: 7px 10px 6px;
  border-radius: 14px;
  background: var(--other);
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.08);
  overflow-wrap: anywhere;
  min-width: 72px;
}

.msg:not(.mine) .bubble {
  border-bottom-left-radius: 4px;
}

.msg.mine .bubble {
  background: var(--mine);
  color: var(--mine-ink);
  border-bottom-right-radius: 4px;
}

.msg.cont:not(.mine) .bubble {
  border-top-left-radius: 6px;
}

.msg.cont.mine .bubble {
  border-top-right-radius: 6px;
}

.msg.flash .bubble {
  box-shadow: 0 0 0 3px var(--accent);
}

.msg-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}

.msg-text {
  white-space: pre-wrap;
}

.msg-text a {
  color: var(--accent);
  text-decoration: underline;
}

.msg.mine .msg-text a {
  color: inherit;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.msg.mine .msg-meta {
  color: color-mix(in srgb, var(--mine-ink) 65%, transparent);
}

.msg-meta .icon {
  width: 13px;
  height: 13px;
}

.msg-timer {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.ticks.seen {
  color: #0ea5e9;
}

.msg-ip {
  font-family: var(--mono);
}

.msg-more {
  position: absolute;
  top: 2px;
  right: 2px;
  display: none;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  color: var(--muted);
}

.msg-more .icon {
  width: 16px;
  height: 16px;
}

@media (hover: hover) {
  .bubble:hover .msg-more {
    display: grid;
  }
}

.quote {
  display: grid;
  width: 100%;
  margin: 0 0 6px;
  padding: 6px 10px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  text-align: left;
  font-size: 13px;
}

.quote strong {
  color: var(--accent);
}

.quote span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.media {
  position: relative;
  margin: 2px -4px 4px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--panel-2);
  max-width: 100%;
  cursor: zoom-in;
}

.media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.media.broken::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--panel-2);
}

.gif-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.vo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  margin: 2px 0;
  padding: 10px 12px;
  border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.vo span {
  display: grid;
}

.vo small {
  color: var(--muted);
}

.vo .icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.vo.action:hover {
  background: var(--accent-soft);
}

.vo.gone {
  color: var(--muted);
  border-style: solid;
  border-color: var(--line);
}

.vo.gone .icon {
  color: var(--muted);
}

.msg.system {
  justify-content: center;
  margin: 10px 0;
}

.msg.system span {
  max-width: 560px;
  padding: 5px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: -4px;
  padding: 0 6px;
  position: relative;
  z-index: 1;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  font-size: 12px;
  font-weight: 600;
}

.reaction.me {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.reaction .emoji {
  font-size: 15px;
}

.jump {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.typing {
  min-height: 0;
  padding: 0 16px;
  font-size: 12px;
  color: var(--accent);
}

/* Composer */
.composer-host {
  position: relative;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.composer-tools {
  display: flex;
  gap: 2px;
}

.composer-input {
  flex: 1;
  min-height: 42px;
  max-height: 160px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--panel-2);
  resize: none;
  outline: none;
  line-height: 1.4;
}

.composer-input:focus {
  border-color: var(--accent);
}

.icon-btn.send {
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}

.composer-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 6px 6px 6px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--panel-2);
}

.reply-bar > .icon {
  color: var(--accent);
}

.reply-text {
  display: grid;
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.reply-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.upload-progress {
  height: 3px;
  margin: -8px -12px 6px;
  background: var(--panel-2);
}

.upload-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}

/* Popovers */
.popover {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 6px);
  z-index: 20;
  width: min(380px, calc(100vw - 16px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.picker-head {
  display: flex;
  gap: 6px;
  padding: 8px;
}

.emoji-picker {
  display: flex;
  flex-direction: column;
  height: 360px;
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 0 6px 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.emoji-tab {
  flex: none;
  width: 36px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 18px;
}

.emoji-tab.on {
  background: var(--accent-soft);
}

.emoji-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  align-content: start;
  padding: 6px;
}

.emoji-cell {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.emoji-cell:hover,
.emoji-cell.on {
  background: var(--panel-2);
}

.gif-picker {
  display: flex;
  flex-direction: column;
  height: 420px;
}

.gif-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.gif-grid {
  columns: 2;
  column-gap: 6px;
}

.gif-cell {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  break-inside: avoid;
}

.gif-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.giphy-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.attach-menu {
  display: grid;
  padding: 6px;
}

.attach-pop {
  width: 220px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  font-weight: 600;
}

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

.menu-item .icon {
  color: var(--muted);
}

.menu-item.danger,
.menu-item.danger .icon {
  color: var(--danger);
}

/* Modals */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 12, 18, 0.55);
  overflow-y: auto;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 4px 20px 20px;
}

.modal-panel.small {
  width: min(440px, 100%);
}

.modal-panel.wide {
  width: min(1040px, 100%);
}

.modal-panel.tall {
  height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -20px 8px;
  padding: 12px 12px 8px 20px;
  background: var(--panel);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-layer.full {
  padding: 0;
}

.modal-layer.full .modal-panel {
  width: 100%;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  border: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.modal-layer.full .modal-head {
  margin: 0;
  padding: 10px 12px;
}

.sheet-modal .modal-head {
  min-height: 0;
  padding-top: 8px;
}

.sheet {
  display: grid;
  gap: 2px;
}

.sheet-pick {
  position: relative;
}

.sheet-pick .popover {
  position: static;
  width: 100%;
  margin: 6px 0;
  box-shadow: none;
}

.quick-reactions {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.quick-reactions .emoji-cell {
  flex: 1;
  max-width: 52px;
  height: 48px;
  font-size: 28px;
}

.quick-reactions .emoji-cell.more {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.me-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 12px 12px;
}

.me-card div {
  display: grid;
}

.dialog {
  display: grid;
  gap: 14px;
}

.dialog-text {
  margin: 4px 0 0;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.dialog-actions.sticky {
  position: sticky;
  bottom: 0;
  padding: 12px 0 4px;
  background: var(--panel);
  justify-content: space-between;
}

.info {
  display: grid;
  gap: 12px;
}

.info h3 {
  margin: 8px 0 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.info-topic {
  margin: 0;
}

.rules-list {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 8px 16px;
  margin: 0;
  font-size: 14px;
}

.rules-list dt {
  color: var(--muted);
}

.rules-list dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  overflow-wrap: anywhere;
}

.member-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.member-list li,
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-results {
  display: grid;
  gap: 2px;
  max-height: 50dvh;
  overflow-y: auto;
}

.user-row {
  width: 100%;
  min-height: 52px;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

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

.user-row-text {
  display: grid;
  flex: 1;
}

.user-row-text small {
  color: var(--muted);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 400;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  background: #121821;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--danger);
}

/* Editor */
.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #0b0f14;
  color: #e7edf3;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}

.editor-head h2 {
  margin: 0;
  font-size: 16px;
}

.editor .icon-btn {
  color: #cbd5e1;
}

.editor .icon-btn:hover,
.editor .icon-btn.on {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.editor-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px;
}

.editor-stage canvas,
.editor-stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  touch-action: none;
  object-fit: contain;
}

.editor-tools {
  display: grid;
  gap: 8px;
  padding: 6px 12px;
}

.tool-row,
.color-row,
.size-row,
.sticker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.size-row {
  margin-left: auto;
}

.swatch {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
}

.swatch.on {
  border-color: #fff;
  box-shadow: 0 0 0 2px #2dd4bf;
}

.size-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.size-btn span {
  display: block;
  border-radius: 50%;
  background: #e7edf3;
}

.size-btn.on {
  background: rgba(255, 255, 255, 0.16);
}

.sticker-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 24px;
}

.sticker-btn.on {
  background: rgba(255, 255, 255, 0.16);
}

.editor-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #121820;
}

.editor-foot .input {
  flex: 1 1 220px;
  background: #18202a;
  border-color: #26303c;
}

.editor-foot .toggle-label small {
  color: #93a0b0;
}

/* Lightbox */
.lightbox-modal {
  background: #05070a;
  color: #e7edf3;
}

.lightbox-modal .modal-head {
  background: #05070a;
}

.lightbox-modal .icon-btn {
  color: #e7edf3;
}

.lightbox {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px;
}

.lightbox-stage {
  overflow: hidden;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: calc(100dvh - 140px);
  object-fit: contain;
  pointer-events: none;
}

.lightbox-stage .wm-layer {
  opacity: calc(var(--wm-opacity) * 2.2);
}

.lightbox-caption,
.lightbox-note {
  margin: 0;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  text-align: center;
}

.lightbox-note {
  display: flex;
  justify-content: center;
  gap: 8px;
  color: #93a0b0;
  font-size: 13px;
}

/* Admin */
.admin-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  overflow-y: auto;
}

.admin {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.adm-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  background: var(--bg);
}

.adm-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.adm-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 40px;
  padding: 6px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.adm-tab.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.adm-content {
  display: grid;
  gap: 16px;
  padding-top: 16px;
}

.adm-section {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.modal-panel .adm-section {
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.adm-section h2 {
  margin: 0;
  font-size: 16px;
}

.adm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.adm-toolbar .input {
  width: auto;
  flex: 1 1 180px;
}

.adm-toolbar select.input {
  flex: 0 1 200px;
}

.inline-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.inline-label .input {
  flex: none;
  width: 160px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.stat {
  display: grid;
  gap: 2px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.adm-table th,
.adm-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.adm-table th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.adm-table tr:last-child td {
  border-bottom: 0;
}

.adm-table tr.clickable {
  cursor: pointer;
}

.adm-table tr.clickable:hover td {
  background: var(--panel-2);
}

.adm-table tr.dim td {
  opacity: 0.6;
}

.adm-table td.wrap {
  min-width: 160px;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.adm-table td.actions {
  white-space: nowrap;
}

.adm-table td.actions > * + * {
  margin-left: 4px;
}

.nowrap {
  white-space: nowrap;
}

.ev {
  font-weight: 600;
  white-space: nowrap;
}

.ev-login_fail .ev,
.ev-screenshot_attempt .ev,
.ev-blocked_ip .ev,
.ev-login_banned .ev,
.ev-report .ev,
.ev-login_locked .ev {
  color: var(--danger);
}

.cell-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cell-user > div {
  display: grid;
}

.cell-user.big .avatar {
  width: 52px;
  height: 52px;
  font-size: 22px;
}

.cell-user.big > div > div {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.adm-user {
  display: grid;
  gap: 16px;
}

.adm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.adm-form {
  display: grid;
  gap: 16px;
}

.adm-form.inline {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}

.adm-form .grow {
  grid-column: span 2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.toggles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 24px;
}

.member-picker {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 320px;
  overflow-y: auto;
}

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  font-size: 14px;
}

.code-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
}

.code-box code {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.code-list {
  margin: 0;
  padding: 12px;
  max-height: 40dvh;
  overflow: auto;
  border-radius: 10px;
  background: var(--panel-2);
  font: 13px/1.6 var(--mono);
  white-space: pre;
}

.inspect-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspect-wrap > p {
  margin: 0;
}

.inspect-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.msgs.inspect {
  padding: 12px;
}

/* Narrow screens: one pane at a time */
@media (max-width: 899px) {
  .chat {
    grid-template-columns: 1fr;
  }

  .conv-wrap {
    display: none;
  }

  .chat.show-conv .side {
    display: none;
  }

  .chat.show-conv .conv-wrap {
    display: flex;
  }

  .only-narrow {
    display: inline-grid;
  }

  .side {
    border-right: 0;
  }

  .msg-col {
    max-width: 84%;
  }

  .msg-avatar {
    width: 30px;
  }

  .msg-avatar .avatar {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .conv-badges .badge.timer {
    padding: 2px 6px;
  }

  .modal-layer:has(.sheet-modal) {
    place-items: end stretch;
    padding: 0;
  }

  .modal-panel.sheet-modal {
    width: 100%;
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .popover {
    left: 6px;
    right: 6px;
    width: auto;
  }

  .adm-form .grow {
    grid-column: auto;
  }

  .rules-list {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .rules-list dd {
    margin-bottom: 8px;
  }
}

@media (max-width: 560px) {
  .auth-card {
    padding: 20px 16px;
  }

  .modal-panel {
    padding: 4px 16px 16px;
  }

  .modal-head {
    margin: 0 -16px 8px;
    padding-left: 16px;
  }

  .conv-head {
    padding: 6px 6px;
    gap: 4px;
  }

  .composer-host {
    padding-left: 8px;
    padding-right: 8px;
  }

  .composer-tools .icon-btn {
    width: 36px;
  }

  .admin {
    padding: 0 12px 32px;
  }

  .adm-head h1 {
    font-size: 17px;
  }
}

/* Phone readability floor: labels at least 11 px, reading text 12 px, tap targets at least 24 px. Keep last. */
@media (max-width: 560px) {
  .msg-meta,
  .badge,
  .pill,
  .chip,
  .gif-tag,
  .badge.admin {
    font-size: 11px;
  }

  .room-last,
  .conv-sub,
  .typing,
  .day,
  .start-note,
  .no-msgs,
  .stat-label,
  .adm-table,
  .field small,
  .online-count {
    font-size: 12px;
  }

  .reaction,
  .link-btn,
  .msg-more,
  .size-btn,
  .swatch {
    min-height: 24px;
    min-width: 24px;
  }
}
