/* Feedback Chat: shared styles for the user page (/) and the admin page (/admin). */

:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef2;
  --text: #171b24;
  --text-2: #424a59;
  --muted: #5f6878;
  --border: #e0e3e8;
  --border-strong: #c8cdd6;
  --accent: #2f6fed;
  --accent-hover: #255fd5;
  --accent-text: #2160e0;
  --accent-soft: #e8effd;
  --on-accent: #ffffff;
  --note: #fff8e3;
  --note-border: #efd894;
  --note-text: #3b311b;
  --danger: #c62f2f;
  --danger-soft: #fdecec;
  --success: #1d7f45;
  --online: #22b357;
  --r1: #d63a3d;
  --r2: #b4500a;
  --r3: #8a6400;
  --r4: #46800b;
  --r5: #1b8048;
  --on-rating: #ffffff;
  --focus-ring: 0 0 0 3px rgba(47, 111, 237, 0.35);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.16);
  --radius: 14px;
  --topbar-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --cols: minmax(0, 1.25fr) minmax(0, 1fr);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1015;
    --surface: #161a21;
    --surface-2: #1b2029;
    --surface-3: #242a35;
    --text: #e8ebf0;
    --text-2: #c3c9d4;
    --muted: #949cab;
    --border: #272d38;
    --border-strong: #3a4252;
    --accent: #2563eb;
    --accent-hover: #2f6fed;
    --accent-text: #8cb0ff;
    --accent-soft: #1a2747;
    --on-accent: #ffffff;
    --note: #262010;
    --note-border: #51431a;
    --note-text: #f2e6c6;
    --danger: #ff7070;
    --danger-soft: #3a1a1d;
    --success: #4cc77f;
    --online: #3bd07c;
    --r1: #ff7b7e;
    --r2: #ff9f5a;
    --r3: #f2c94c;
    --r4: #a6d95e;
    --r5: #5ad595;
    --on-rating: #10131a;
    --focus-ring: 0 0 0 3px rgba(108, 152, 255, 0.45);
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus {
  outline: none;
}

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

code,
kbd {
  font-family: var(--mono);
  font-size: 0.86em;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  text-align: center;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.icon {
  flex: none;
}

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
}

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

.btn-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
}

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

.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
  height: 48px;
  font-size: 16px;
}

.icon-btn {
  width: 40px;
  padding: 0;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
}

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

.link-btn {
  overflow-wrap: anywhere;
  text-align: left;
}

.input {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea.input {
  height: auto;
  padding: 11px 14px;
  line-height: 1.5;
  resize: vertical;
}

.input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* Text fields show focus with their border and ring; the transparent outline appears in forced-colors mode. */
.input:focus-visible,
.composer-input:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 0;
}

.input-sm {
  height: 38px;
  border-radius: 10px;
  font-size: 15px;
}

/* ---------- Avatars, badges, ratings ---------- */

.avatar {
  position: relative;
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: hsl(var(--h, 220) 52% 47%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  user-select: none;
}

.avatar.lg {
  width: 48px;
  height: 48px;
  font-size: 19px;
}

.avatar .dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border: 2.5px solid var(--surface);
  border-radius: 50%;
  background: var(--border-strong);
}

.avatar .dot.on {
  background: var(--online);
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.badge.quiet {
  background: var(--surface-3);
  color: var(--text-2);
}

.rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--rc, var(--text-2));
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rating .stars {
  display: inline-flex;
  gap: 1px;
  font-size: 15px;
  line-height: 1;
}

.rating .stars .off {
  opacity: 0.22;
}

[data-r="1"] {
  --rc: var(--r1);
}

[data-r="2"] {
  --rc: var(--r2);
}

[data-r="3"] {
  --rc: var(--r3);
}

[data-r="4"] {
  --rc: var(--r4);
}

[data-r="5"] {
  --rc: var(--r5);
}

.rating-input {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rating-btn {
  height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--rc);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}

.rating-btn:hover {
  border-color: var(--rc);
  background: var(--surface-2);
}

.rating-btn:active {
  transform: scale(0.96);
}

.rating-btn:disabled {
  opacity: 0.5;
}

.rating-btn[aria-checked="true"] {
  border-color: var(--rc);
  background: var(--rc);
  color: var(--on-rating);
}

/* ---------- Status: toasts, connection banner, boot screen ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  box-shadow: var(--shadow-lg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
  /* A message never blocks the buttons underneath it; only its own action button is clickable. */
  pointer-events: none;
  animation: toast-in 0.18s ease-out;
}

.toast-action {
  flex: none;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  font-weight: 700;
  pointer-events: auto;
}

.toast.error {
  background: #c62f2f;
  color: #fff;
}

.toast.success {
  background: #1d7f45;
  color: #fff;
}

.toast.out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.conn-banner {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: 50%;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--text);
  box-shadow: var(--shadow-lg);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  transform: translateX(-50%);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.boot {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.boot .spinner {
  width: 22px;
  height: 22px;
}

/* ---------- Sign-in card ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 390px;
  padding: 30px 26px 26px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
}

.brand-mark.sm {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.auth-card h1 {
  margin: 18px 0 6px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.lead {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 15px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.pin-input {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.7em;
  text-align: center;
  text-indent: 0.7em;
}

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

.hint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chat-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.chat-title strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.me {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.me-name {
  max-width: 34vw;
  overflow: hidden;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Ledger: paragraph on the left, feedback on the right ---------- */

.ledger-wrap {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

.ledger-head {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top));
  z-index: 10;
  display: grid;
  grid-template-columns: var(--cols);
  padding: 14px 0 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.ledger-head span {
  padding: 0 17px;
}

.ledger {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 24px;
}

.row {
  display: grid;
  grid-template-columns: var(--cols);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.cell {
  min-width: 0;
  padding: 14px 16px 16px;
}

.cell-fb {
  border-left: 1px solid var(--border);
}

.cell-fb.has-fb {
  border-left-color: var(--note-border);
  background: var(--note);
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.num {
  color: var(--text-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.para-text,
.fb-text,
.up-next-item .preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  /* Each paragraph takes its direction from its own text (Arabic, Hebrew, …). */
  unicode-bidi: plaintext;
  text-align: start;
}

.undo-btn {
  margin-left: auto;
  padding: 2px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 700;
}

.undo-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

.load-error,
.load-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.load-error {
  margin-top: 14px;
}

.load-banner {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: 50%;
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  box-shadow: var(--shadow-lg);
}

.para-text {
  font-size: 16px;
  line-height: 1.62;
}

.fb-text {
  color: var(--note-text);
  font-size: 15px;
  line-height: 1.58;
}

.fb-label {
  color: var(--note-text);
  font-weight: 700;
}

.flash {
  animation: flash 2.2s ease-out;
}

@keyframes flash {
  from {
    box-shadow: inset 0 0 0 2px var(--r3);
  }
  to {
    box-shadow: inset 0 0 0 2px transparent;
  }
}

.empty {
  max-width: 420px;
  margin: 40px auto;
  padding: 28px 20px;
  color: var(--muted);
  text-align: center;
}

.empty h2 {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 18px;
}

.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ---------- User page ---------- */

.page-user .chat {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}

.composer-inner,
.composer-meta {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

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

.composer-input {
  flex: 1;
  min-height: 48px;
  max-height: 40vh;
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--surface);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.composer-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.send-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  transition: background-color 0.15s, opacity 0.15s, transform 0.08s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.send-btn:disabled {
  opacity: 0.4;
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
  margin-top: 6px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.char-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.char-count.over {
  color: var(--danger);
  font-weight: 700;
}

/* ---------- Admin page ---------- */

.admin-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.admin-shell .topbar {
  flex: none;
}

.admin-shell .topbar-inner {
  max-width: none;
}

.menu-btn {
  display: none;
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stat .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.menu-pop button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.menu-pop button:hover {
  background: var(--surface-3);
}

.menu-pop button.danger {
  color: var(--danger);
}

.admin-body {
  display: grid;
  flex: 1;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 0;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 12px 4px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: none;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.nav-item .badge {
  margin-left: auto;
}

.sidebar-search {
  padding: 8px 12px 6px;
}

.sidebar-label {
  display: flex;
  justify-content: space-between;
  padding: 10px 24px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

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

.user-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
}

.user-item:hover {
  background: var(--surface-2);
}

.user-item > *,
.up-next-item > * {
  pointer-events: none;
}

.user-item.active {
  background: var(--surface-3);
}

.user-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

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

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

.user-sub.online {
  color: var(--success);
}

.list-empty {
  padding: 18px 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.backdrop {
  display: none;
}

/* Review queue */

.review-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.review-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 16px;
}

.review-head h1 {
  font-size: 21px;
  letter-spacing: -0.01em;
}

.review {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 1fr);
  align-items: start;
  gap: 20px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.review-para {
  padding: 20px 22px 18px;
}

.review-who {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.who-name {
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.review-who-text {
  min-width: 0;
}

.review-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  font-size: 14px;
  font-weight: 600;
}

.who-sub {
  color: var(--muted);
  font-size: 13.5px;
}

.review-para .para-text {
  font-size: 17.5px;
  line-height: 1.7;
}

.review-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.fb-panel {
  position: sticky;
  top: 20px;
  padding: 18px;
}

.fb-panel h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

.fb-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fb-editor .fb-input {
  min-height: 150px;
  max-height: 50vh;
  font-size: 15.5px;
}

.fb-editor.compact .fb-input {
  min-height: 92px;
}

.fb-editor-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}

.fb-note {
  color: var(--muted);
  font-size: 12.5px;
}

.editor-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.editor-notice.warn {
  border: 1px solid var(--note-border);
  background: var(--note);
  color: var(--note-text);
}

.rating-prompt {
  margin-top: 8px;
  color: var(--accent-text);
  font-size: 13.5px;
  font-weight: 600;
}

.fb-input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

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

.fb-editor-actions .grow {
  flex: 1;
}

.kbd-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 13.5px;
}

.up-next {
  margin-top: 26px;
}

.up-next h2 {
  margin: 0 0 10px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

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

.up-next-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}

.up-next-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.up-next-item .who {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.up-next-item .who strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-next-item .preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-2);
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.caught-up {
  max-width: 460px;
  margin: 12vh auto 0;
  padding: 0 20px;
  text-align: center;
}

.caught-up h1 {
  margin-bottom: 6px;
  font-size: 22px;
}

.caught-up p {
  color: var(--muted);
}

.caught-up .btn {
  margin-top: 18px;
}

/* Chat view (one person) */

.chat-head {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.chat-head-info {
  min-width: 0;
  line-height: 1.3;
}

.chat-head-info .who-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.chat-head > .icon-btn,
.chat-head > .avatar {
  flex: none;
}

.main .ledger-wrap {
  max-width: 1240px;
  padding: 0 24px;
}

.main .ledger-head {
  top: 0;
  position: static;
}

.add-fb {
  color: var(--accent-text);
}

.fb-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.cell-fb.editing {
  background: var(--surface-2);
}

.row.pending .cell-fb:not(.editing) {
  display: flex;
  align-items: flex-start;
}

.row.selected {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* ---------- Narrow screens ---------- */

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

  .fb-panel {
    position: static;
  }
}

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

  .menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(320px, 86vw);
    border-right: 1px solid var(--border);
    visibility: hidden;
    transform: translateX(-102%);
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .sidebar.open {
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transform: none;
    transition: transform 0.2s ease, visibility 0s;
  }

  .backdrop.show {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: rgba(10, 14, 20, 0.35);
  }

  .topbar-stats .stat-pending {
    display: none;
  }

  .review-wrap {
    padding: 16px 16px 32px;
  }

  .chat-head {
    padding: 10px 16px;
  }

  .main .ledger-wrap {
    padding: 0 16px;
  }
}

@media (max-width: 639px) {
  :root {
    --topbar-h: 56px;
  }

  .ledger-head {
    display: none;
  }

  .ledger {
    padding-top: 14px;
  }

  .row {
    display: block;
  }

  .cell-fb {
    border-left: 0;
    padding-top: 0;
  }

  .cell-fb.has-fb {
    background: none;
  }

  .cell-fb.has-fb .fb {
    margin-left: 18px;
    padding: 10px 12px;
    border: 1px solid var(--note-border);
    border-radius: 12px;
    background: var(--note);
  }

  /* The highlight for new feedback sits on the note itself, not the indented strip. */
  .cell-fb.flash {
    animation: none;
  }

  .cell-fb.flash .fb {
    animation: flash 2.2s ease-out;
  }

  .brand .tag {
    display: none;
  }

  /* On the user page an unanswered paragraph simply has nothing under it. */
  .page-user .cell-fb:not(.has-fb) {
    display: none;
  }

  .page-admin .cell-fb.editing {
    border-top: 1px solid var(--border);
    padding-top: 12px;
  }

  .brand .brand-name {
    display: none;
  }

  .topbar-stats {
    font-size: 13px;
  }

  .topbar-actions .btn-label {
    display: none;
  }

  .me-name {
    max-width: 28vw;
  }

  .fb-editor .fb-input {
    min-height: 96px;
  }

  .chat-title span {
    display: none;
  }

  .para-text {
    font-size: 16px;
  }

  .review-para {
    padding: 16px 16px 14px;
  }

  .review-para .para-text {
    font-size: 16.5px;
  }

  .fb-panel {
    padding: 14px;
  }

  .kbd-hints {
    display: none;
  }
}

@media (pointer: coarse) {
  .kbd-hints,
  .composer-hint {
    display: none;
  }

  /* Comfortable touch targets. */
  .btn,
  .btn-sm {
    min-width: 44px;
    height: 44px;
  }

  .icon-btn {
    width: 44px;
  }

  .menu-pop button,
  .toast-action {
    min-height: 44px;
  }

  .input-sm {
    height: 44px;
  }

  .link-btn,
  .undo-btn {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
