:root {
  --bg: #f7f4ef;
  --paper: #fffdf9;
  --ink: #1c2430;
  --muted: #68717f;
  --line: #ddd7cc;
  --teal: #137f78;
  --teal-dark: #0b5f59;
  --amber: #d89122;
  --coral: #d95f50;
  --good: #1f8f4d;
  --shadow: 0 4px 16px rgba(28, 36, 48, 0.08), 0 1px 3px rgba(28, 36, 48, 0.06);
  --shadow-lg: 0 12px 36px rgba(28, 36, 48, 0.12), 0 2px 8px rgba(28, 36, 48, 0.06);
  --radius: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 12px clamp(16px, 4vw, 44px);
  background: rgba(255, 253, 249, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  transition: opacity 0.15s;
}

.brand:hover {
  opacity: 0.8;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav,
.authbox {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a,
.authbox a,
.link-button {
  padding: 7px 11px;
  color: var(--muted);
  border-radius: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.14s, color 0.14s;
}

.nav a:hover,
.authbox a:hover,
.link-button:hover {
  color: var(--ink);
  background: #ece7de;
}

.nav a:active,
.authbox a:active {
  background: #e3ddd3;
}

/* ── Main container ── */
main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

/* ── Typography ── */
.eyebrow {
  margin: 0;
  color: var(--teal) !important;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem !important;
  letter-spacing: 0.06em;
}

h2,
h3 {
  margin: 0;
}

/* ── Actions ── */
.hero-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Buttons ── */
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.14s var(--ease), border-color 0.14s, box-shadow 0.14s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.button:active,
button:active {
  transform: scale(0.97);
}

.button.primary,
button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
  box-shadow: 0 2px 8px rgba(19, 127, 120, 0.25);
}

.button.primary:hover,
button.primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  box-shadow: 0 4px 12px rgba(19, 127, 120, 0.32);
}

button:disabled,
button:disabled:hover {
  cursor: default;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.button.ghost {
  background: transparent;
}

/* ── Panels & Cards ── */
.toolbar,
.panel,
.question-card,
.answer-card,
.side-panel,
.form-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 260px);
  gap: 12px;
  padding: 14px;
  margin: 12px 0 24px;
}

/* ── Form elements ── */
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 127, 120, 0.14);
}

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

textarea {
  min-height: 160px;
  resize: vertical;
}

/* ── Layout grids ── */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

/* ── Icon buttons ── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  padding: 4px 7px;
  cursor: pointer;
  color: var(--teal);
  transition: background 0.14s, color 0.14s, transform 0.1s;
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--line); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }
.icon-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Question & Answer cards ── */
.question-list {
  display: grid;
  gap: 12px;
}

.question-card,
.answer-card,
.side-panel,
.form-panel,
.panel {
  padding: 18px;
}

.question-card {
  display: grid;
  gap: 12px;
  background: var(--post-bg, var(--paper));
  border-color: var(--post-border, var(--line));
  animation: var(--post-animation, none);
  transition: box-shadow 0.2s var(--ease), border-color 0.2s;
}

.question-card:hover {
  box-shadow: var(--shadow);
}

.pinned-card {
  border-color: rgba(85, 60, 154, 0.45);
  box-shadow: 0 0 0 3px rgba(85, 60, 154, 0.08);
}

.pill.pin-pill {
  background: #e9d8fd;
  color: #553c9a;
  font-weight: 700;
}

.boosted-card {
  border-color: rgba(19, 127, 120, 0.5);
  box-shadow: 0 0 0 3px rgba(19, 127, 120, 0.08);
}

.premium-post-card {
  border-color: #d4af37;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.16), 0 14px 34px rgba(151, 104, 12, 0.08);
}

.question-card h3 {
  font-size: 1.15rem;
}

/* ── Body text ── */
.body-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #334052;
  line-height: 1.75;
}

/* ── Media ── */
.post-photo {
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #f1ece3;
}

.post-photo img,
.post-photo video {
  display: block;
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  background: white;
}

/* ── Meta & User info ── */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.user-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  vertical-align: middle;
  color: inherit;
  text-decoration: none;
}

.user-link:hover {
  color: var(--teal-dark);
}

.user-name > span:not(.user-icon, .subscriber-count) {
  overflow-wrap: anywhere;
}

.subscriber-count {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff0ed;
  color: var(--coral);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
}

.token-box .subscriber-count {
  background: #fff0ed;
  color: var(--coral);
}

.official-check {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #2563eb;
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.premium-check {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #d4af37;
  color: white;
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.18);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.user-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  overflow: hidden;
  border-radius: 999px;
  background: #d7d1c7;
  border: 1px solid rgba(28, 36, 48, 0.12);
}

.user-icon.online {
  border-color: var(--online-color, var(--good));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--online-color, var(--good)) 24%, transparent);
  animation: var(--online-animation, none);
}

.user-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ── Pills & chips ── */
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e8f4f2;
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 0.82rem;
}

.pill.alt {
  background: #fff3d8;
  color: #8b560b;
}

.pill.boost-pill {
  background: #e8f4f2;
  color: var(--teal-dark);
  border: 1px solid rgba(19, 127, 120, 0.28);
}

.countdown-chip {
  display: inline-flex;
  align-items: center;
  min-width: 70px;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(19, 127, 120, 0.12);
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  background: #f1ece3;
  color: var(--muted);
  font-weight: 700;
}

/* ── DM header link ── */
.dm-header-link {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  max-width: 360px;
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 8px;
  background: #f1ece3;
  color: var(--ink);
  font-weight: 800;
  transition: background 0.14s;
}

.dm-header-link:hover {
  background: #eee8dd;
}

.dm-header-label,
.dm-header-preview {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.dm-header-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #dc2626;
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

/* ── Reaction buttons ── */
.like-button.liked {
  border-color: var(--coral);
  color: var(--coral);
  background: #fff0ed;
}

.boost-button {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: #e8f4f2;
}

.boost-button:hover {
  background: var(--teal);
  color: white;
}

.subscribe-button {
  border-color: var(--amber);
  color: #7b4a08;
  background: #fff7e6;
}

.subscribe-button:hover {
  border-color: var(--teal);
  background: #e8f4f2;
  color: var(--teal-dark);
}

.subscribe-button.subscribed,
.subscribe-button.subscribed:hover {
  border-color: var(--coral);
  background: #fff0ed;
  color: var(--coral);
}

.tip-button {
  border-color: #d4af37;
  color: #7a4f00;
  background: #fff6d7;
}

.tip-button:hover {
  background: #d4af37;
  color: white;
}

.card-action-stack {
  margin-left: auto;
  display: grid;
  gap: 8px;
  justify-items: stretch;
}

.card-action-stack button {
  width: 100%;
}

.danger-button {
  border-color: var(--coral);
  color: var(--coral);
  background: #fff0ed;
}

.danger-button:hover {
  background: var(--coral);
  color: white;
}

/* ── Side panel ── */
.side-panel {
  display: grid;
  gap: 12px;
}

/* ── Token box ── */
.token-box {
  display: grid;
  justify-items: start;
  gap: 10px;
  margin: 30px 0 22px;
  padding: 30px 34px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #f6a214 0%, #d77a11 100%);
  color: white;
  text-align: left;
  box-shadow: 0 16px 38px rgba(154, 83, 0, 0.2);
}

.token-box h3 {
  margin: 0;
  color: white;
  font-size: clamp(2rem, 5vw, 3.8rem);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  text-shadow: 0 3px 12px rgba(92, 50, 0, 0.2);
}

.token-box p,
.token-box span {
  margin: 0;
  color: white;
}

.token-box-subtitle {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  opacity: 0.96;
}

.token-box-amount {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: white;
  font-size: clamp(3rem, 8vw, 4.8rem);
  line-height: 0.9;
  text-shadow: 0 3px 12px rgba(92, 50, 0, 0.24);
}

.token-box-amount span {
  font-size: 1.3rem;
  font-weight: 900;
  text-transform: uppercase;
}

.token-box-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  font-weight: 900;
}

.token-box-next {
  padding-top: 4px;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.token-box-time {
  font-size: clamp(2rem, 6vw, 3.8rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 3px 12px rgba(92, 50, 0, 0.24);
}

.token-box-winner {
  width: 100%;
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(122, 67, 0, 0.28);
  color: white;
  font-size: 1rem;
  font-weight: 900;
}

/* ── Rank / Notice / Admin rows ── */
.rank-row,
.notice-row,
.admin-row {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.rank-row:last-child,
.notice-row:last-child,
.admin-row:last-child {
  border-bottom: 0;
}

/* ── Form panel ── */
.form-panel {
  width: min(760px, 100%);
  margin: 24px auto 0;
  display: grid;
  gap: 16px;
}

.inline-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

/* ── Page head ── */
.page-head {
  margin: 8px 0 18px;
}

.page-head p {
  color: var(--muted);
  line-height: 1.7;
}

/* ── Login intro ── */
.login-intro {
  width: min(760px, 100%);
  margin: 18px auto 22px;
}

.language-select {
  width: fit-content;
  margin-bottom: 20px;
}

.language-select select {
  min-width: 150px;
}

.login-intro h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
}

.login-intro p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.8;
  font-size: 1.05rem;
}

/* ── Question detail ── */
.question-detail {
  display: grid;
  gap: 18px;
}

.answer-list {
  display: grid;
  gap: 12px;
}

.best {
  border-color: rgba(31, 143, 77, 0.5);
  box-shadow: 0 0 0 3px rgba(31, 143, 77, 0.08);
  order: -1;
}

.best-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--good);
  font-weight: 900;
}

.crown-mark {
  font-size: 1.1rem;
  line-height: 1;
}

/* ── Timeout overlay ── */
.timeout-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(28, 36, 48, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.timeout-box {
  width: min(760px, 100%);
  padding: clamp(34px, 7vw, 72px);
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.timeout-box h1 {
  margin: 8px 0 14px;
  font-size: clamp(3rem, 11vw, 7rem);
  line-height: 0.95;
}

.timeout-box p {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 800;
}

.timeout-box strong {
  display: block;
  margin-bottom: 22px;
  color: var(--coral);
  font-size: clamp(1.4rem, 4vw, 2.8rem);
}

/* ── Admin ── */
.admin-command {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.admin-command-grid form {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.56);
}

.admin-user-list {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

/* ── Overlays ── */
.site-message-overlay,
.control-a-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(28, 36, 48, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-message-overlay {
  z-index: 50;
}

.control-a-overlay {
  z-index: 90;
}

.site-message-box,
.control-a-box {
  width: min(860px, 100%);
  padding: clamp(28px, 6vw, 64px);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.site-message-box h1,
.control-a-box h1 {
  margin: 12px 0 24px;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.control-a-box {
  display: grid;
  gap: 16px;
  text-align: left;
  width: min(620px, 100%);
}

.control-a-box .eyebrow,
.control-a-box h1 {
  text-align: center;
}

/* ── Choices ── */
.choice-fields,
.choice-options,
.choice-input-list,
.choice-buttons,
.choice-results {
  display: grid;
  gap: 12px;
}

.choice-buttons {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.choice-button {
  justify-content: flex-start;
  min-height: 52px;
  text-align: left;
  background: white;
}

.choice-button:hover {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 127, 120, 0.1);
}

.choice-option {
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.choice-option input {
  width: auto;
}

.choice-result {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.choice-result.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 127, 120, 0.1);
}

.choice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Meter ── */
.meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee8dd;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

/* ── Grid helpers ── */
.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* ── DM layout ── */
.dm-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.dm-sidebar,
.dm-chat {
  display: grid;
  gap: 14px;
}

.dm-thread-list,
.dm-messages {
  display: grid;
  gap: 10px;
}

.user-search-picker {
  display: grid;
  gap: 8px;
}

.user-search-options {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.user-search-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  text-align: left;
  border-radius: 7px;
  transition: background 0.12s, border-color 0.12s;
}

.user-search-option:hover,
.user-search-option.selected {
  border-color: var(--teal);
  background: #e8f4f2;
}

.user-search-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-search-chip {
  min-height: 30px;
  padding: 5px 9px;
  border-color: var(--amber);
  background: #fff7e6;
  color: #7b4a08;
}

/* ── DM thread & messages ── */
.dm-thread {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.58);
  transition: background 0.12s, border-color 0.12s;
  cursor: pointer;
}

.dm-thread:hover {
  background: rgba(255, 255, 255, 0.86);
}

.dm-thread.active {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
  background: #f0faf9;
}

.dm-message {
  width: min(78%, 560px);
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 1px 4px rgba(28, 36, 48, 0.06);
}

.dm-message.mine {
  justify-self: end;
  border-color: rgba(19, 127, 120, 0.3);
  background: #e8f4f2;
}

.group-admin-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(216, 145, 34, 0.32);
  border-radius: var(--radius);
  background: #fff7e6;
}

.dm-send-form textarea {
  min-height: 100px;
}

/* ── Token chip ── */
.token-chip {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff7e6;
  color: #7b4a08;
}

/* ── Shop ── */
.shop-section {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.premium-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 20px;
  border-color: rgba(212, 175, 55, 0.5);
  background: #fffaf0;
}

.premium-actions {
  display: grid;
  gap: 8px;
  min-width: min(100%, 320px);
}

.premium-boost-left {
  display: inline-grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(212, 175, 55, 0.34);
  border-radius: 8px;
  background: rgba(255, 248, 223, 0.76);
}

.premium-boost-left span {
  color: #7c5a08;
  font-size: 0.86rem;
  font-weight: 800;
}

.premium-boost-left strong {
  color: #4b3703;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.shop-group {
  display: grid;
  gap: 10px;
}

.shop-group-title {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 900;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.shop-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color 0.14s, box-shadow 0.14s;
}

.shop-card:hover {
  border-color: rgba(19, 127, 120, 0.35);
  box-shadow: var(--shadow);
}

.shop-card.equipped {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.shop-preview {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 4px solid var(--shop-color, var(--good));
  background: white;
  animation: var(--shop-animation, none);
}

.shop-preview.post-preview {
  border-radius: 8px;
  border-color: var(--shop-border, var(--line));
  background: var(--shop-bg, var(--paper));
  animation: var(--shop-animation, none);
}

.shop-copy {
  min-width: 0;
}

.shop-card button {
  grid-column: 1 / -1;
  width: 100%;
}

/* ── Settings ── */
.settings-panel {
  max-width: 680px;
}

.profile-settings {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.toggle-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.toggle-row input {
  width: auto;
}

.profile-preview {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1ece3;
  font-weight: 800;
}

.profile-preview .user-icon {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

/* ── Color options ── */
.color-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.color-options legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.color-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.color-option input {
  width: auto;
}

.color-option:has(input:checked) {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.color-swatch {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--line);
}

.color-teal { background: #137f78; }
.color-blue { background: #2563eb; }
.color-rose { background: #be3455; }
.color-green { background: #21845a; }

/* ── Toast ── */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100% - 36px));
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 30;
  font-weight: 600;
  animation: toast-in 0.28s var(--ease);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Empty state ── */
.empty {
  color: var(--muted);
  padding: 28px 22px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 249, 0.7);
  text-align: center;
  line-height: 1.6;
}

/* ── Hidden ── */
.hidden {
  display: none !important;
}

/* ── Online animations ── */
@keyframes qanda-online-cyan-magenta {
  0%   { border-color: #0891b2; box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.22); }
  50%  { border-color: #d946ef; box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.22); }
  100% { border-color: #0891b2; box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.22); }
}

@keyframes qanda-online-turquoise-sunset {
  0%   { border-color: #12b8c8; box-shadow: 0 0 0 3px rgba(18, 184, 200, 0.22); }
  50%  { border-color: #fb6f3b; box-shadow: 0 0 0 3px rgba(251, 111, 59, 0.22); }
  100% { border-color: #12b8c8; box-shadow: 0 0 0 3px rgba(18, 184, 200, 0.22); }
}

@keyframes qanda-online-lavender-lemon {
  0%   { border-color: #a78bfa; box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.22); }
  50%  { border-color: #facc15; box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.24); }
  100% { border-color: #a78bfa; box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.22); }
}

@keyframes qanda-online-mint-salmon {
  0%   { border-color: #62d6a4; box-shadow: 0 0 0 3px rgba(98, 214, 164, 0.22); }
  50%  { border-color: #fb8b7f; box-shadow: 0 0 0 3px rgba(251, 139, 127, 0.22); }
  100% { border-color: #62d6a4; box-shadow: 0 0 0 3px rgba(98, 214, 164, 0.22); }
}

/* ════════════════════════════════════════
   TABLET  641px – 860px
   ════════════════════════════════════════ */
@media (max-width: 860px) {
  .layout,
  .grid-two,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .dm-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 14px;
  }

  .side-panel {
    order: -1;
  }

  .form-panel {
    width: 100%;
  }

  .premium-panel {
    grid-template-columns: 1fr;
  }

  .premium-actions {
    width: 100%;
  }

  .token-box {
    margin: 20px 0;
    padding: 26px 28px;
  }
}

@media (max-width: 760px) {
  .dm-layout {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════
   MOBILE  ≤ 640px
   ════════════════════════════════════════ */
@media (max-width: 640px) {

  /* ── Topbar: only brand + auth row.
     IMPORTANT: remove backdrop-filter so that position:fixed children
     (the bottom nav) can escape to the viewport.
     backdrop-filter on an ancestor traps fixed descendants. ── */
  .topbar {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
    grid-template-areas: "brand auth";
    gap: 0;
    padding: 0;
    background: rgba(255, 253, 249, 0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    grid-area: brand;
    padding: 9px 14px;
    font-size: 0.95rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  /* ── Authbox: compact — icon + tokens + logout only ── */
  .authbox {
    grid-area: auth;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    padding: 6px 10px 6px 4px;
  }

  /* Hide the DM shortcut link in the header — it's in the bottom nav */
  .authbox .dm-header-link {
    display: none;
  }

  /* Hide username text & badges in the authbox stat — keep only avatar icon */
  .authbox .user-name > span:not(.user-icon) {
    display: none;
  }
  .authbox .official-check,
  .authbox .premium-check,
  .authbox .subscriber-count {
    display: none;
  }

  .authbox .stat {
    padding: 4px 8px;
    font-size: 0.82rem;
    gap: 4px;
  }

  .authbox a,
  .authbox .link-button {
    white-space: nowrap;
    min-height: 34px;
    padding: 5px 9px;
    font-size: 0.82rem;
  }

  /* ── Bottom navigation bar ── */
  .nav {
    /* Fixed at viewport bottom — works because topbar has no backdrop-filter */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 2px;
    padding: 4px 6px env(safe-area-inset-bottom, 4px);
    border-top: 1px solid var(--line);
    /* backdrop-filter here on nav itself is safe — it has no fixed children */
    background: rgba(255, 253, 249, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 -1px 12px rgba(28, 36, 48, 0.08);
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    flex: 1 1 auto;
    min-width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
    min-height: 50px;
    border-radius: 8px;
    color: var(--muted);
    letter-spacing: 0;
  }

  .nav a:hover,
  .nav a:active {
    background: #ece7de;
    color: var(--ink);
  }

  /* ── Main content: padding-bottom for bottom nav ── */
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
    padding-bottom: 80px;
  }

  /* ── Cards & panels ── */
  .question-card,
  .answer-card,
  .side-panel,
  .form-panel,
  .panel {
    padding: 14px 16px;
    border-radius: 12px;
  }

  .question-card h3 {
    font-size: 1.05rem;
  }

  /* ── Token box ── */
  .token-box {
    padding: 20px 22px;
    border-radius: 12px;
    margin: 14px 0;
  }

  .token-box-stats {
    display: grid;
    gap: 8px;
  }

  /* ── Form inputs: larger touch targets ── */
  input,
  textarea,
  select {
    padding: 13px 12px;
    font-size: 1rem;
  }

  textarea {
    min-height: 140px;
  }

  /* ── Sections & actions ── */
  .section-title {
    display: grid;
    align-items: start;
    justify-content: stretch;
    gap: 8px;
  }

  .choice-row {
    flex-direction: column;
    align-items: stretch;
  }

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

  .actions > *,
  .actions button,
  .actions .button {
    flex: 1 1 auto;
    min-width: 120px;
    justify-content: center;
  }

  .card-action-stack {
    width: 100%;
    margin-left: 0;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions button,
  .hero-actions .button {
    justify-content: center;
  }

  /* ── Typography ── */
  .login-intro h1 {
    font-size: clamp(1.7rem, 7vw, 2.6rem);
  }

  /* ── User name wrapping (in posts, not authbox) ── */
  .question-card .user-name,
  .answer-card .user-name {
    max-width: 100%;
    flex-wrap: wrap;
  }

  /* ── DM ── */
  .dm-layout {
    grid-template-columns: 1fr;
  }

  .dm-message {
    width: 90%;
  }

  /* ── DM header-label hidden (was for topbar DM shortcut) ── */
  .dm-header-label {
    display: none;
  }

  /* ── Media ── */
  .post-photo img,
  .post-photo video {
    max-height: 280px;
  }

  /* ── Choices & colors ── */
  .choice-buttons,
  .color-options {
    grid-template-columns: 1fr;
  }

  /* ── Overlays: bottom-sheet style ── */
  .site-message-overlay,
  .control-a-overlay,
  .timeout-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .site-message-box,
  .control-a-box,
  .timeout-box {
    padding: 24px 20px;
    border-radius: 16px;
    width: 100%;
  }

  /* ── Admin ── */
  .admin-command-grid {
    grid-template-columns: 1fr;
  }

  /* ── Toast: near top so keyboard doesn't cover it ── */
  .toast {
    top: 60px;
    right: 10px;
    bottom: auto;
    max-width: calc(100% - 20px);
    font-size: 0.9rem;
  }

  /* ── Shop grid ── */
  .shop-grid {
    grid-template-columns: 1fr;
  }

  /* ── Empty state ── */
  .empty {
    padding: 24px 16px;
    font-size: 0.95rem;
  }
}

/* ── Extra small: very narrow phones (≤ 380px) ── */
@media (max-width: 380px) {
  .nav a {
    min-width: 40px;
    font-size: 0.62rem;
    padding: 5px 3px;
  }

  .brand span:last-child {
    display: none;
  }
}
