/* ── Marco-Polliio — feature poll page ──────────────────────────────── */

/* Type --bd as a length so keyframe calc() interpolates correctly. */
@property --bd {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}

/* Brand override: cyan → red for this page only. */
:root {
  --color-primary:        #ef4444;
  --color-accent:         #ef4444;
  --color-link-text:      #fca5a5;
  --color-code-text:      #fecaca;
  --color-primary-5:      rgba(239, 68, 68, 0.05);
  --color-primary-10:     rgba(239, 68, 68, 0.10);
  --color-primary-15:     rgba(239, 68, 68, 0.15);
  --color-primary-20:     rgba(239, 68, 68, 0.20);
  --color-primary-30:     rgba(239, 68, 68, 0.30);
  --color-primary-50:     rgba(239, 68, 68, 0.50);
  --shadow-glow:          0 0 12px rgba(239, 68, 68, 0.30);
  --mp-brand:             #ef4444;
  --mp-brand-deep:        #b91c1c;
  --mp-brand-glow:        rgba(239, 68, 68, 0.30);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--color-foreground);
  background-color: var(--color-background);
  background-image:
    radial-gradient(ellipse 1100px 600px at 15% 0%, rgba(239,68,68,0.10), transparent 60%),
    radial-gradient(ellipse 900px 500px at 85% 35%, rgba(239,68,68,0.06), transparent 60%),
    radial-gradient(ellipse 800px 700px at 50% 100%, rgba(239,68,68,0.05), transparent 60%);
  background-attachment: fixed;
}

button { font-family: inherit; }

/* ── Top nav ────────────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 20px;
  background: var(--color-glass-bg);
  border-bottom: 1px solid var(--color-glass-border);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}
.topnav-left  { justify-self: start; display: flex; gap: 8px; align-items: center; }
.topnav-right { justify-self: end;   display: flex; gap: 10px; align-items: center; }

/* ── Wordmark stack (schedii ⇄ marco-polliio) ───────────────────────── */
.wordmark-stack {
  position: relative;
  height: 28px;
  min-width: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wm {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  line-height: 1;
}
.wm .rd {
  color: #ef4444;
  text-shadow: 0 0 14px rgba(239,68,68,0.45);
}
.wm-schedii { animation: fadeSchedii 16s ease-in-out infinite; }
.wm-marco   { animation: fadeMarco   16s ease-in-out infinite; }
@keyframes fadeSchedii {
  0%, 43%   { opacity: 1; }
  50%, 93%  { opacity: 0; }
  100%      { opacity: 1; }
}
@keyframes fadeMarco {
  0%, 43%   { opacity: 0; }
  50%, 93%  { opacity: 1; }
  100%      { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .wm-schedii, .wm-marco { animation-duration: 32s; }
}

/* ── User pill ──────────────────────────────────────────────────────── */
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 9999px;
  background: var(--color-overlay-light);
  border: 1px solid var(--color-glass-border);
  font-size: 13px;
  color: var(--color-foreground);
}
.user-pill .avatar {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.user-pill[data-role="admin"] .avatar {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}
.user-pill .role-tag {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-muted-foreground);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  appearance: none;
  cursor: pointer;
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 160ms cubic-bezier(0.4,0,0.2,1), background-color 160ms, border-color 160ms, color 160ms;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  color: white;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 4px 14px rgba(239,68,68,0.25);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost {
  color: var(--color-muted-foreground);
  background: transparent;
}
.btn-ghost:hover {
  color: var(--color-foreground);
  background: var(--color-overlay-light);
}
.btn-danger {
  color: #ef4444;
  background: transparent;
  border-color: rgba(239,68,68,0.25);
}
.btn-danger:hover {
  background: rgba(239,68,68,0.10);
  border-color: rgba(239,68,68,0.45);
}
.btn-secondary {
  color: var(--color-foreground);
  background: var(--color-overlay-light);
  border-color: var(--color-glass-border);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--color-primary-30);
}

/* ── Login screen ───────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(35, 35, 58, 0.86);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.42);
}
.signup-card {
  max-width: 520px;
}
.login-card .wordmark-stack { margin: 0 auto 8px; }
.login-card .tagline {
  text-align: center;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-muted-foreground);
  margin: 0 0 28px;
}
.login-card label {
  display: block;
  font-size: 12px;
  color: var(--color-muted-foreground);
  margin-bottom: 6px;
  font-weight: 500;
}
.login-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  color: var(--color-foreground);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 120ms;
}
.login-card input:focus { border-color: var(--color-primary-50); }
.login-card .err {
  color: #ef4444;
  font-size: 12px;
  margin: -4px 0 12px;
  min-height: 16px;
}
.login-card .hints {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
  font-size: 11px;
  color: var(--color-muted-foreground);
  line-height: 1.7;
  font-family: ui-monospace, Menlo, monospace;
}
.login-card .hints code {
  color: var(--color-link-text);
  background: rgba(239,68,68,0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Main canvas ────────────────────────────────────────────────────── */
.canvas {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 120px;
}
.canvas-head {
  display: block;
  margin-bottom: 16px;
}
.canvas-head h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-hero-text);
}
.canvas-head h1 em {
  font-style: italic;
  color: #ef4444;
  text-shadow: 0 0 24px rgba(252,165,165,0.35);
}

/* ── PollHero (marco ⇄ polio dance) ──────────────────────────────────── */
.poll-track {
  position: relative;
  width: 100%;
  height: clamp(64px, 6.5vw, 100px);
  margin-bottom: 8px;
  overflow: visible;
}
.anim-word {
  --bd: 400px;
  position: absolute;
  left: 0;
  bottom: 8px;
  display: inline-block;
  font-size: clamp(32px, 3.6vw, 52px);
  font-weight: 700;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  will-change: transform;
}
.anim-y {
  display: inline-block;
  will-change: transform;
}
.anim-marco {
  color: #ffffff;
  text-shadow: 0 0 22px rgba(255,255,255,0.20), 0 0 6px rgba(255,255,255,0.30);
  animation: marcoX 9s linear infinite;
}
.anim-marco .anim-y {
  animation: bounceY 9s linear infinite;
}
.anim-polio {
  color: #ef4444;
  text-shadow: 0 0 24px rgba(239,68,68,0.40);
  animation: polioX 9s linear infinite;
}
.anim-polio .anim-y {
  animation: bounceY 9s linear infinite;
  animation-delay: -0.5s;
}

@keyframes marcoX {
  0%, 100% { transform: translateX(0); animation-timing-function: linear; }
  44%, 50% { transform: translateX(calc(var(--bd) * 1.0)); animation-timing-function: linear; }
  94%      { transform: translateX(0); animation-timing-function: linear; }
}
@keyframes polioX {
  0%, 100% { transform: translateX(calc(var(--bd) * 1.0)); animation-timing-function: linear; }
  44%, 50% { transform: translateX(0); animation-timing-function: linear; }
  94%      { transform: translateX(calc(var(--bd) * 1.0)); animation-timing-function: linear; }
}

@keyframes bounceY {
  /* L→R: 4 arcs (0% → 44%) */
  0%    { transform: translateY(0);     animation-timing-function: ease-out; }
  5.5%  { transform: translateY(-32px); animation-timing-function: ease-in;  }
  11%   { transform: translateY(0);     animation-timing-function: ease-out; }
  16.5% { transform: translateY(-26px); animation-timing-function: ease-in;  }
  22%   { transform: translateY(0);     animation-timing-function: ease-out; }
  27.5% { transform: translateY(-26px); animation-timing-function: ease-in;  }
  33%   { transform: translateY(0);     animation-timing-function: ease-out; }
  38.5% { transform: translateY(-32px); animation-timing-function: ease-in;  }
  /* Pause */
  44%   { transform: translateY(0);     animation-timing-function: linear;   }
  50%   { transform: translateY(0);     animation-timing-function: ease-out; }
  /* R→L: 4 arcs (50% → 94%) */
  55.5% { transform: translateY(-32px); animation-timing-function: ease-in;  }
  61%   { transform: translateY(0);     animation-timing-function: ease-out; }
  66.5% { transform: translateY(-26px); animation-timing-function: ease-in;  }
  72%   { transform: translateY(0);     animation-timing-function: ease-out; }
  77.5% { transform: translateY(-26px); animation-timing-function: ease-in;  }
  83%   { transform: translateY(0);     animation-timing-function: ease-out; }
  88.5% { transform: translateY(-32px); animation-timing-function: ease-in;  }
  94%   { transform: translateY(0);     animation-timing-function: linear;   }
}

@media (prefers-reduced-motion: reduce) {
  .anim-word, .anim-y { animation: none !important; transform: none !important; }
  .anim-polio { transform: translateX(40%) !important; }
}

.canvas-head .sub {
  color: var(--color-muted-foreground);
  font-size: 13px;
  margin-top: 6px;
}

/* ── Feature stack ──────────────────────────────────────────────────── */
.stack {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.feature-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}
@media (max-width: 920px) {
  .feature-row { grid-template-columns: 1fr; }
}
.right-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ── Media panel (left — images / videos) ───────────────────────────── */
.media-panel {
  background: rgba(35, 35, 58, 0.94);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  min-height: 280px;
}
.media-panel .media-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.media-panel .media-item {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: var(--color-muted);
  border: 1px solid var(--color-border);
  display: block;
  position: relative;
}
.media-panel .media-item img,
.media-panel .media-item video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  background: #0a0a14;
  cursor: zoom-in;
}
.media-panel .media-item video { cursor: default; }
.media-panel .media-empty {
  flex: 1;
  min-height: 240px;
  border-radius: 12px;
  border: 1px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted-foreground);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}
.media-panel .admin-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

/* ── Description card (right — top) ─────────────────────────────────── */
.desc-card {
  background: rgba(28, 28, 42, 0.78);
  border: 1px solid rgba(255,255,255,0.09);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
[data-theme="light"] .desc-card {
  background: rgba(15,23,42,0.025);
  border-color: rgba(15,23,42,0.08);
}
.desc-card .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-family: ui-monospace, Menlo, monospace;
  color: var(--color-muted-foreground);
}
.desc-card .meta .dot {
  width: 6px; height: 6px; border-radius: 9999px;
  background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.7);
}
.desc-card h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--color-foreground);
}
.desc-card .desc {
  margin: 0;
  color: var(--color-muted-foreground);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.desc-card .admin-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
}

/* ── Comments panel (right, transparent) ────────────────────────────── */
.comments-panel {
  background: rgba(28, 28, 42, 0.78);
  border: 1px solid rgba(255,255,255,0.09);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
[data-theme="light"] .comments-panel {
  background: rgba(15,23,42,0.025);
  border-color: rgba(15,23,42,0.08);
}

/* ── Vote bar ───────────────────────────────────────────────────────── */
.vote-bar {
  display: flex;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-separator);
}
.vote-btn {
  flex: 1;
  appearance: none;
  cursor: pointer;
  background: var(--color-overlay-subtle);
  border: 1px solid var(--color-separator);
  border-radius: 10px;
  padding: 7px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--color-muted-foreground);
  transition: all 140ms ease;
}
.vote-btn:hover {
  background: var(--color-overlay-light);
  color: var(--color-foreground);
}
.vote-btn .num {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.vote-btn svg { display: block; }
.vote-btn[data-active="true"][data-kind="up"] {
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.40);
  color: #34d399;
}
.vote-btn[data-active="true"][data-kind="down"] {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.40);
  color: #f87171;
}
.vote-btn[data-active="true"][data-kind="neutral"] {
  background: rgba(148,163,184,0.14);
  border-color: rgba(148,163,184,0.40);
  color: var(--color-foreground);
}

/* ── Comments list ──────────────────────────────────────────────────── */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.comment {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
}
.comment .av {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.comment[data-role="admin"] .av {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}
.comment .body {
  min-width: 0;
}
.comment .top-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.comment .top-line .name { font-weight: 600; color: var(--color-foreground); }
.comment .top-line .role {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-muted-foreground);
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--color-overlay-light);
}
.comment .top-line .ts {
  color: var(--color-muted-foreground);
  font-size: 11px;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.comment .text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--color-foreground);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.comment .text .expand-btn {
  display: inline;
  background: none;
  border: none;
  color: var(--color-link-text);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  margin-left: 4px;
}
.comment .text .expand-btn:hover { text-decoration: underline; }
.comment .attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.comment .attachments img {
  width: 90px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  cursor: zoom-in;
}
.comment .audio-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-overlay-light);
  border: 1px solid var(--color-glass-border);
  border-radius: 9999px;
  padding: 3px 10px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-muted-foreground);
  margin-top: 6px;
}

/* ── Composer ───────────────────────────────────────────────────────── */
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--color-separator);
}
.composer textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-overlay-subtle);
  border: 1px solid var(--color-separator);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--color-foreground);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 64px;
  outline: none;
  transition: border-color 140ms;
}
.composer textarea:focus { border-color: var(--color-primary-50); }
.composer .pending-attach {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.composer .pending-attach .att {
  position: relative;
  width: 64px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.composer .pending-attach .att img { width: 100%; height: 100%; object-fit: cover; }
.composer .pending-attach .att .x {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 9999px;
  background: rgba(0,0,0,0.6);
  color: white;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.composer-toolbar .tool-btn {
  appearance: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--color-overlay-subtle);
  color: var(--color-muted-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms, background 120ms, border-color 120ms;
}
.composer-toolbar .tool-btn:hover {
  color: var(--color-foreground);
  background: var(--color-overlay-light);
  border-color: var(--color-glass-border);
}
.composer-toolbar .tool-btn[data-listening="true"] {
  color: white;
  background: #ef4444;
  border-color: #b91c1c;
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.composer-toolbar .spacer { flex: 1; }

/* ── Empty state ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  background: rgba(28, 28, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px dashed var(--color-border);
  border-radius: 18px;
  color: var(--color-muted-foreground);
}
.empty-state h3 {
  color: var(--color-foreground);
  font-weight: 600;
  margin: 0 0 8px;
  font-size: 18px;
}

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.modal label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted-foreground);
  margin: 14px 0 6px;
}
.modal input[type="text"],
.modal textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--color-foreground);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.modal textarea { min-height: 90px; resize: vertical; }
.modal input:focus, .modal textarea:focus { border-color: var(--color-primary-50); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.image-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.image-thumb-grid .thumb {
  position: relative;
  width: 90px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.image-thumb-grid .thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-thumb-grid .thumb .x {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 9999px;
  background: rgba(0,0,0,0.6);
  color: white;
  cursor: pointer;
  font-size: 11px;
}

/* ── Drawing canvas modal ───────────────────────────────────────────── */
.draw-modal { max-width: 760px; }
.draw-canvas-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: #f8fafc;
  margin-top: 8px;
}
.draw-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}
.draw-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.swatch {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch[data-active="true"] { border-color: var(--color-foreground); transform: scale(1.1); }

/* ── Lightbox ───────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 95;
  cursor: zoom-out;
  padding: 32px;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}


/* ── Tab switcher — clean: tabs left · actions right ─────────────────── */
.tab-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 22px;
  padding: 8px 10px;
  background: rgba(28, 28, 42, 0.74);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  position: relative;
  z-index: 2;
}
.tab-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.tab-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tab-pill {
  appearance: none;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted-foreground);
  font-family: inherit;
  white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.tab-pill:hover {
  background: var(--color-overlay-light);
  color: var(--color-foreground);
}
.tab-pill .tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.tab-pill .tab-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.tab-pill[data-tab="poll"] .tab-dot        { background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.55); }
.tab-pill[data-tab="suggestions"] .tab-dot { background: #4ade80; box-shadow: 0 0 8px rgba(74,222,128,0.55); }
.tab-pill[data-tab="poll"][data-active="true"] {
  background: rgba(239,68,68,0.10);
  border-color: rgba(239,68,68,0.35);
  color: #fca5a5;
}
.tab-pill[data-tab="suggestions"][data-active="true"] {
  background: rgba(74,222,128,0.10);
  border-color: rgba(74,222,128,0.35);
  color: #86efac;
}
.tab-pill[data-active="true"] .tab-label { color: var(--color-foreground); }

/* Action buttons (create / rush) */
.btn-create {
  appearance: none;
  cursor: pointer;
  border: 1px solid;
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: #ffffff;
  transition: transform 160ms cubic-bezier(.4,0,.2,1), box-shadow 160ms;
}
.btn-create:hover     { transform: translateY(-1px); }
.btn-create:active    { transform: translateY(0) scale(0.98); }
.btn-create:disabled  { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-create-feature {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: rgba(239,68,68,0.55);
  box-shadow: 0 4px 14px rgba(239,68,68,0.22);
}
.btn-create-suggestion {
  background: linear-gradient(135deg, #4ade80, #16a34a);
  border-color: rgba(74,222,128,0.55);
  box-shadow: 0 4px 14px rgba(74,222,128,0.22);
}
@media (max-width: 640px) {
  .tab-switcher  { flex-direction: column; align-items: stretch; }
  .tab-group     { justify-content: space-between; }
  .tab-actions   { justify-content: flex-end; flex-wrap: wrap; }
  .tab-pill      { flex: 1; justify-content: center; }
}

/* ── Suggestions tab: light-green theme override ────────────────────── */
body[data-tab="suggestions"] {
  /* Token swap: red → light green for this tab */
  --color-primary:        #4ade80;
  --color-accent:         #4ade80;
  --color-link-text:      #86efac;
  --color-code-text:      #bbf7d0;
  --color-primary-5:      rgba(74, 222, 128, 0.05);
  --color-primary-10:     rgba(74, 222, 128, 0.10);
  --color-primary-15:     rgba(74, 222, 128, 0.15);
  --color-primary-20:     rgba(74, 222, 128, 0.20);
  --color-primary-30:     rgba(74, 222, 128, 0.30);
  --color-primary-50:     rgba(74, 222, 128, 0.50);
  --shadow-glow:          0 0 12px rgba(74, 222, 128, 0.30);
  /* Lighter page wash */
  --color-background:     #1c2024;
  --color-card:           #262b30;
  --color-border:         #3a4148;
  background-image:
    radial-gradient(ellipse 1100px 600px at 15% 0%,  rgba(74,222,128,0.10), transparent 60%),
    radial-gradient(ellipse 900px 500px at 85% 35%,  rgba(74,222,128,0.06), transparent 60%),
    radial-gradient(ellipse 800px 700px at 50% 100%, rgba(74,222,128,0.05), transparent 60%);
}
/* Hardcoded literals scoped to suggestions tab */
body[data-tab="suggestions"] .btn-primary {
  background: linear-gradient(135deg, #4ade80, #16a34a);
  box-shadow: 0 4px 14px rgba(74,222,128,0.28);
}
body[data-tab="suggestions"] .feature-panel .meta .dot,
body[data-tab="suggestions"] .desc-card .meta .dot {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74,222,128,0.7);
}
body[data-tab="suggestions"] .canvas-head h1 em {
  color: #4ade80;
  text-shadow: 0 0 24px rgba(74,222,128,0.40);
}
body[data-tab="suggestions"] .anim-polio {
  color: #4ade80;
  text-shadow: 0 0 24px rgba(74,222,128,0.40);
}
body[data-tab="suggestions"] .user-pill .avatar,
body[data-tab="suggestions"] .user-pill[data-role="user"] .avatar {
  background: linear-gradient(135deg, #4ade80, #16a34a);
}
body[data-tab="suggestions"] .user-pill[data-role="admin"] .avatar {
  background: linear-gradient(135deg, #86efac, #15803d);
}
body[data-tab="suggestions"] .comment .av,
body[data-tab="suggestions"] .comment[data-role="user"] .av {
  background: linear-gradient(135deg, #86efac, #15803d);
}
body[data-tab="suggestions"] .comment[data-role="admin"] .av {
  background: linear-gradient(135deg, #4ade80, #16a34a);
}
body[data-tab="suggestions"] .wm .rd {
  color: #4ade80;
  text-shadow: 0 0 14px rgba(74,222,128,0.45);
}
body[data-tab="suggestions"] .topnav {
  border-bottom-color: rgba(74,222,128,0.18);
}
body[data-tab="suggestions"] .login-card .hints code {
  color: #86efac;
  background: rgba(74,222,128,0.08);
}
body[data-tab="suggestions"] .desc-card,
body[data-tab="suggestions"] .comments-panel,
body[data-tab="suggestions"] .tab-switcher {
  background: rgba(30, 36, 40, 0.74);
}
body[data-tab="suggestions"] .media-panel {
  background: rgba(38, 43, 48, 0.92);
}

/* ── Diagonal wallpaper: marco (red) + poliio (white) layered ──────── */
body { position: relative; }
body::before,
body::after {
  content: '';
  position: fixed;
  top: -35%;
  left: -35%;
  width: 170%;
  height: 170%;
  background-repeat: repeat;
  transform-origin: center center;
  pointer-events: none;
  z-index: 0;
}
/* Layer 1 — marco (red on poll, green on suggestions) — diagonal ↘ */
body::before {
  background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='340'%20height='110'%20viewBox='0%200%20340%20110'%3E%3Ctext%20x='0'%20y='86'%20font-size='92'%20font-weight='800'%20font-style='italic'%20fill='%23ef4444'%20fill-opacity='0.04'%20font-family='-apple-system,BlinkMacSystemFont,Segoe%20UI,Roboto,sans-serif'%20letter-spacing='-4'%3Emarco%3C/text%3E%3C/svg%3E");
  background-position: 0 0;
  transform: rotate(-22deg);
}
body[data-tab="suggestions"]::before {
  background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='340'%20height='110'%20viewBox='0%200%20340%20110'%3E%3Ctext%20x='0'%20y='86'%20font-size='92'%20font-weight='800'%20font-style='italic'%20fill='%2386efac'%20fill-opacity='0.05'%20font-family='-apple-system,BlinkMacSystemFont,Segoe%20UI,Roboto,sans-serif'%20letter-spacing='-4'%3Emarco%3C/text%3E%3C/svg%3E");
}
/* Layer 2 — poliio (white) — SAME diagonal as marco, offset half-tile so its rows sit
   between marco rows (one above, one below — never on top of marco). */
body::after {
  background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='340'%20height='110'%20viewBox='0%200%20340%20110'%3E%3Ctext%20x='0'%20y='86'%20font-size='92'%20font-weight='800'%20font-style='italic'%20fill='%23ffffff'%20fill-opacity='0.028'%20font-family='-apple-system,BlinkMacSystemFont,Segoe%20UI,Roboto,sans-serif'%20letter-spacing='-4'%3Epoliio%3C/text%3E%3C/svg%3E");
  background-position: 170px 55px;
  transform: rotate(-22deg);
}
/* Lift content above the wallpaper */
.topnav        { z-index: 50; }
.canvas        { position: relative; z-index: 1; }
.login-screen  { position: relative; z-index: 1; }


/* ── Sign-up: face picker ───────────────────────────────────────────── */
.face-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.face-option {
  appearance: none;
  cursor: pointer;
  background: var(--color-overlay-subtle);
  border: 2px solid var(--color-separator);
  border-radius: 14px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--color-muted-foreground);
  transition: all 140ms ease;
}
.face-option:hover {
  background: var(--color-overlay-light);
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-1px);
}
.face-option[data-active="true"] {
  background: var(--color-primary-15);
  border-color: var(--color-primary-50);
  color: var(--color-foreground);
  box-shadow: 0 0 0 3px var(--color-primary-10);
}
.face-option .face-name {
  font-size: 10px;
  font-family: ui-monospace, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
@media (max-width: 480px) {
  .face-picker { grid-template-columns: repeat(2, 1fr); }
}

/* ── Avatar override when face icon is present ──────────────────────── */
.user-pill .avatar.avatar-face,
.comment .av.av-face {
  background: transparent !important;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.user-pill .avatar.avatar-face svg,
.comment .av.av-face svg {
  border-radius: 9999px;
  display: block;
}

/* Topnav sign-up link */
.btn-signup-link {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid var(--color-glass-border);
  padding: 6px 10px;
}

/* Suggestions tab: green-shift the face picker active state */
body[data-tab="suggestions"] .face-option[data-active="true"] {
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.55);
  box-shadow: 0 0 0 3px rgba(74,222,128,0.12);
}


/* ── Composer: gate-only locked state ───────────────────────────────── */
.composer.composer-locked {
  background: var(--color-overlay-subtle);
  border: 1px dashed var(--color-separator);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.composer.composer-locked .locked-msg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted-foreground);
  font-size: 12.5px;
  line-height: 1.5;
}
.composer.composer-locked .locked-msg svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* ── Comment hover actions (edit / delete) ──────────────────────────── */
.comment .top-line .comment-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 140ms ease;
}
.comment:hover .top-line .comment-actions,
.comment:focus-within .top-line .comment-actions {
  opacity: 1;
}
.comment .top-line .ts .edited {
  font-style: italic;
  opacity: 0.75;
}
.comment-action {
  appearance: none;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--color-overlay-subtle);
  color: var(--color-muted-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.comment-action:hover {
  background: var(--color-overlay-light);
  color: var(--color-foreground);
  border-color: var(--color-glass-border);
}
.comment-action.comment-action-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.45);
}

/* Inline comment edit textarea */
.comment-edit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}
.comment-edit textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-overlay-subtle);
  border: 1px solid var(--color-primary-30);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--color-foreground);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  outline: none;
}
.comment-edit textarea:focus {
  border-color: var(--color-primary-50);
}
.comment-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.comment-edit-actions .btn { padding: 5px 10px; font-size: 12px; }

/* ── Lightbox: annotate action ──────────────────────────────────────── */
.lightbox { flex-direction: column; gap: 16px; }
.lightbox-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

/* ── Annotate modal ─────────────────────────────────────────────────── */
.annotate-modal { max-width: 880px; }
.annotate-canvas-wrap {
  position: relative;
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: #0a0a14;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.annotate-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  cursor: crosshair;
  touch-action: none;
}
.annotate-tools {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.annotate-tools .tool-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.annotate-tools .tool-row-label {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-muted-foreground);
  min-width: 44px;
}
.tool-chip {
  appearance: none;
  cursor: pointer;
  background: var(--color-overlay-subtle);
  border: 1px solid var(--color-separator);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted-foreground);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 120ms ease;
}
.tool-chip:hover {
  background: var(--color-overlay-light);
  color: var(--color-foreground);
  border-color: var(--color-glass-border);
}
.tool-chip[data-active="true"] {
  background: var(--color-primary-15);
  border-color: var(--color-primary-50);
  color: var(--color-foreground);
}
.annotate-tools .swatch {
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}
.annotate-tools .swatch[data-active="true"] {
  border-color: var(--color-foreground);
  transform: scale(1.1);
}
.annotate-tools input[type="range"] {
  flex: 0 0 140px;
  accent-color: var(--color-primary);
}

@media (max-width: 720px) {
  .annotate-tools .tool-row { gap: 4px; }
  .annotate-tools .tool-row-label { min-width: auto; }
}


/* ─────────────────────────────────────────────────────────────────────
   MOBILE PASS — breakpoints + touch-friendly tweaks
   ───────────────────────────────────────────────────────────────────── */

/* Touch devices: comment edit/delete must be reachable (no hover) */
@media (hover: none) {
  .comment .top-line .comment-actions { opacity: 1; }
  .comment-action { width: 26px; height: 26px; }
}

/* ── ≤ 720px: tablet & narrow desktop tweaks ──────────────────────── */
@media (max-width: 720px) {
  .canvas { padding: 22px 16px 100px; }
  .poll-track { height: clamp(56px, 11vw, 80px); }
  .anim-word  { font-size: clamp(26px, 6vw, 42px); }
  .feature-row { gap: 12px; }
  .media-panel { padding: 10px; }
  .desc-card,
  .comments-panel { padding: 12px 14px; }
  .desc-card h2 { font-size: 16px; }
  .feature-panel .meta,
  .desc-card .meta { font-size: 9.5px; letter-spacing: 0.14em; }
  .empty-state { padding: 56px 18px; }
}

/* ── ≤ 640px: phones ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Topnav: compress aggressively */
  .topnav {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    height: 54px;
    gap: 6px;
  }
  .topnav-left  { display: none; }     /* empty spacer; reclaim the room */
  .topnav-right { gap: 6px; }
  .wordmark-stack { min-width: auto; height: 24px; }
  .wm { font-size: 18px; }

  /* User pill: avatar + role chip only on phones, drop the long name */
  .user-pill {
    padding: 4px 8px 4px 4px;
    gap: 6px;
    font-size: 12px;
  }
  .user-pill > span:not(.avatar):not(.role-tag) {
    display: none;
  }
  .user-pill .role-tag { font-size: 9px; letter-spacing: 0.12em; }

  /* Sign-up link compacts */
  .btn-signup-link { padding: 5px 9px; font-size: 11px; }

  /* Canvas + hero */
  .canvas { padding: 18px 12px 80px; }
  .poll-track { height: clamp(52px, 14vw, 72px); margin-bottom: 4px; }
  .anim-word  { font-size: clamp(24px, 7vw, 38px); }

  /* Tabs / actions stack and full-width on phones */
  .tab-switcher {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px;
  }
  .tab-group   { justify-content: stretch; gap: 6px; }
  .tab-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
  .tab-pill {
    flex: 1;
    justify-content: center;
    padding: 9px 10px;
  }
  .tab-pill .tab-label { font-size: 12.5px; }
  .btn-create  { padding: 7px 10px; font-size: 12px; flex: 1; justify-content: center; }

  /* Feature row stack (already collapses at 920) */
  .stack { gap: 20px; }

  /* Vote bar: keep readable but tighten */
  .vote-bar { gap: 4px; padding-bottom: 8px; }
  .vote-btn { padding: 6px 4px; border-radius: 9px; }
  .vote-btn svg { width: 16px; height: 16px; }
  .vote-btn .num { font-size: 12px; }

  /* Composer */
  .composer textarea { font-size: 14px; min-height: 56px; }
  .composer-toolbar { gap: 4px; flex-wrap: wrap; }
  .composer-toolbar .tool-btn { width: 38px; height: 38px; }
  .composer-toolbar .btn-primary { padding: 8px 12px; font-size: 12.5px; }

  /* Comments list — give a touch more room */
  .comments-list { max-height: 360px; }
  .comment { grid-template-columns: 24px 1fr; gap: 8px; }
  .comment .av { width: 24px; height: 24px; font-size: 10px; }
  .comment .av.av-face svg { width: 24px; height: 24px; }
  .comment .text { font-size: 13px; }
  .comment .top-line { gap: 6px; flex-wrap: wrap; }
  .comment .top-line .ts { margin-left: 0; }

  /* Modals — edge-to-edge with breathing room */
  .modal-backdrop { padding: 12px; }
  .modal { padding: 18px; max-height: calc(100vh - 24px); }
  .modal-head h3 { font-size: 16px; }
  .modal input[type="text"],
  .modal textarea,
  .modal input[type="password"] { font-size: 15px; /* prevent iOS zoom-on-focus */ }
  .login-card  { padding: 24px; }
  .login-card input { font-size: 15px; }

  /* Sign-up face picker */
  .face-picker { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .face-option { padding: 8px 4px 6px; }
  .face-option svg { width: 46px; height: 46px; }
  .face-option .face-name { font-size: 9px; }

  /* Annotate modal — tighter tool rows */
  .annotate-modal { max-width: 100%; }
  .annotate-canvas-wrap { max-height: 50vh; }
  .annotate-canvas-wrap canvas { max-height: 50vh; }
  .annotate-tools .tool-row { gap: 4px; }
  .tool-chip { padding: 5px 8px; font-size: 11.5px; }
  .annotate-tools input[type="range"] { flex-basis: 100px; }

  /* Lightbox: tighter padding */
  .lightbox { padding: 16px; gap: 10px; }
  .lightbox-actions .btn { padding: 8px 12px; font-size: 12.5px; }
}

/* ── ≤ 420px: tiny phones / iPhone SE-class ─────────────────────── */
@media (max-width: 420px) {
  .wm { font-size: 16px; }
  .anim-word { font-size: clamp(20px, 7.5vw, 32px); }
  .face-picker { grid-template-columns: repeat(2, 1fr); }
  .login-card .hints { font-size: 10px; line-height: 1.6; }
  .topnav .btn-signup-link { display: none; } /* polldev: nav to signup from inside the app instead */
  .modal { padding: 14px; }
  .modal-actions { flex-wrap: wrap; }
}

/* ── Image attachments tap targets ───────────────────────────────── */
@media (max-width: 640px) {
  .comment .attachments img { width: 76px; height: 56px; }
  .composer .pending-attach .att { width: 56px; height: 42px; }
  .pending-attach .att .x { width: 16px; height: 16px; font-size: 10px; }
  .image-thumb-grid .thumb { width: 76px; height: 56px; }
}

/* ── Prevent body horizontal scroll from off-screen wallpaper ────── */
html, body { overflow-x: hidden; }

/* ── Slice 5c: vertical FeatureRow (media+desc up top, thread below) ── */
/* Override the older 2-col grid; .feature-row is now a flex column,
   .feature-top holds the side-by-side media + meta, and .comment-thread
   spans full width directly below it. */
.feature-row {
  display: flex !important;
  flex-direction: column;
  gap: 0;
}
.feature-top {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}
.feature-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
@media (max-width: 920px) {
  .feature-top { grid-template-columns: 1fr; }
}

/* ── Comment thread (full-width below the feature) ───────────────── */
.comment-thread {
  margin-top: 14px;
  background: rgba(25, 25, 40, 0.78);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comment-thread .comments-list {
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 0 6px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}
.comment-thread .thread-empty {
  font-size: 12px;
  color: var(--color-muted-foreground);
  padding: 14px 4px 16px;
  text-align: center;
  font-style: italic;
}

/* ── Stackable emoji reactions ───────────────────────────────────── */
.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 0 2px;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1;
  color: var(--color-foreground);
  cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 100ms;
}
.reaction-chip:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-1px); }
.reaction-chip[data-mine="true"] {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}
body[data-tab="suggestions"] .reaction-chip[data-mine="true"] {
  background: rgba(74, 222, 128, 0.16);
  border-color: rgba(74, 222, 128, 0.55);
  color: #86efac;
}
.reaction-chip .emoji { font-size: 14px; }
.reaction-chip .count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.reaction-add { position: relative; display: inline-flex; }
.reaction-add-btn { font-size: 11px; opacity: 0.7; padding: 4px 8px; }
.reaction-add-btn:hover { opacity: 1; }
.reaction-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  background: rgba(25, 25, 40, 0.96);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 4px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.reaction-picker-emoji {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.reaction-picker-emoji:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--color-border);
}
.reaction-picker-empty {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--color-muted-foreground);
  padding: 6px 8px;
  text-align: center;
}

/* ── Face picker: 5 columns of image-faces (was 4 cols of SVG) ──── */
.face-picker { grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 640px) { .face-picker { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 420px) { .face-picker { grid-template-columns: repeat(3, 1fr); } }
.face-option { padding: 6px; }
.face-option .face-img { display: block; }

/* ─────────────────────────────────────────────────────────────────────
   SLICE 6 — universal mobile hardening (overrides earlier partial rules)
   ───────────────────────────────────────────────────────────────────── */

/* Box-sizing safety net — prevents padding-driven overflow in any obscure
   primitive that forgot. */
*, *::before, *::after { box-sizing: border-box; }

@media (max-width: 640px) {
  /* ── Topnav: flex layout so the wordmark doesn't get clipped by a
        position:absolute element overflowing a squeezed 1fr grid track.
        Three slots, all naturally sized, with a hidden left spacer that
        used to balance the grid. */
  .topnav {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 54px;
  }
  .topnav-left  { display: none; }
  .topnav-right { gap: 6px; flex-shrink: 0; }

  /* Wordmark stack — width is now bounded so the absolutely-positioned
     .wm elements fade in/out within a known box instead of overflowing. */
  .wordmark-stack {
    flex: 0 1 auto;
    min-width: 0;
    width: 140px;
    height: 24px;
    overflow: hidden;
  }
  .wm { font-size: 16px; }

  /* User pill — avatar + role chip only; name hidden to save horizontal
     room (was already in place but reasserted as !important so any later
     desktop rule can't override). */
  .user-pill { padding: 4px 8px 4px 4px !important; gap: 6px !important; }
  .user-pill > span:not(.avatar):not(.role-tag) { display: none !important; }
  .user-pill .role-tag { font-size: 9px !important; }
}

/* ── ≤ 420px: tiny phones (iPhone SE-class) ──────────────────────────── */
@media (max-width: 420px) {
  .topnav { padding: 0 8px; height: 50px; }
  .wordmark-stack { width: 110px; }
  .wm { font-size: 14px; }
  .canvas { padding: 14px 10px 60px; }

  /* Tabs: two-tab row stays side-by-side, but smaller pills */
  .tab-pill { padding: 8px 8px; }
  .tab-pill .tab-label { font-size: 11.5px; }
  .btn-create { padding: 7px 9px; font-size: 11.5px; }

  /* Feature row internals — already 1fr at 920, but tighten more */
  .desc-card, .comment-thread { padding: 10px 12px; }
  .desc-card h2 { font-size: 15px; }
  .desc-card .desc { font-size: 13px; }

  /* Comments / reactions stay readable but shrink slightly */
  .reaction-chip { padding: 3px 8px; font-size: 12px; }
  .reaction-chip .count { font-size: 10px; }
  .composer-toolbar .tool-btn { width: 34px; height: 34px; }
}

/* ── Universal: prevent every modal/popover from overflowing viewport ── */
.modal { max-width: min(560px, calc(100vw - 24px)); }
.login-card { max-width: min(440px, calc(100vw - 24px)); }
.reaction-picker { max-width: calc(100vw - 24px); }
