:root,
[data-theme="blizzard"] {
  --bg: #e8f0fe;
  --panel: #ffffff;
  --ink: #1a1a2e;
  --muted: #4a5a6e;
  --accent: #4fc3f7;
  --accent-hover: #29b6f6;
  --line: #b0d4f1;
  --like: #e74c7b;
  --ok: #1f9d55;
  --bad: #c0392b;
  --shadow: 0 8px 24px rgba(79, 195, 247, 0.18);
  --radius: 12px;
  --font: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  --topbar-from: #4fc3f7;
  --topbar-mid: #29b6f6;
  --topbar-to: #81d4fa;
  --topbar-ink: #0a2540;
  --logo-bg: #fff;
  --logo-ink: #29b6f6;
  --input-bg: #f5faff;
  --btn-ink: #0a2540;
  --secondary-bg: #e3f2fd;
  --wallet-bg: rgba(255, 255, 255, 0.35);
  --reward-bg: #e1f5fe;
  --reward-ink: #0277bd;
  --bg-glow-1: rgba(79, 195, 247, 0.35);
  --bg-glow-2: rgba(176, 212, 241, 0.45);
  --focus-ring: #81d4fa;
  --theme-menu-bg: #ffffff;
  --theme-menu-shadow: 0 12px 32px rgba(26, 35, 50, 0.15);
}

[data-theme="ambre"] {
  --bg: #1a1a2e;
  --panel: #22223a;
  --ink: #f5f0e6;
  --muted: #a89b7c;
  --accent: #e6a817;
  --accent-hover: #f0b93a;
  --line: #4a3f28;
  --like: #e6a817;
  --ok: #c9a227;
  --bad: #d35400;
  --shadow: 0 8px 28px rgba(230, 168, 23, 0.12);
  --topbar-from: #2a2210;
  --topbar-mid: #3d2e12;
  --topbar-to: #2a2210;
  --topbar-ink: #f5f0e6;
  --logo-bg: #e6a817;
  --logo-ink: #1a1a2e;
  --input-bg: #1e1e32;
  --btn-ink: #1a1a2e;
  --secondary-bg: #2a2a42;
  --wallet-bg: rgba(230, 168, 23, 0.12);
  --reward-bg: #3d2e12;
  --reward-ink: #e6a817;
  --bg-glow-1: rgba(230, 168, 23, 0.12);
  --bg-glow-2: rgba(74, 63, 40, 0.25);
  --focus-ring: #e6a817;
  --theme-menu-bg: #22223a;
  --theme-menu-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

[data-theme="ocean"] {
  --bg: #0b1a2e;
  --panel: #12263d;
  --ink: #ffffff;
  --muted: #7a9bb5;
  --accent: #00b4d8;
  --accent-hover: #48cae4;
  --line: #1a3a5c;
  --like: #00b4d8;
  --ok: #00c9a7;
  --bad: #e63946;
  --shadow: 0 8px 28px rgba(0, 180, 216, 0.14);
  --topbar-from: #0a2540;
  --topbar-mid: #0d3a5c;
  --topbar-to: #0a2540;
  --topbar-ink: #ffffff;
  --logo-bg: #00b4d8;
  --logo-ink: #0b1a2e;
  --input-bg: #0e2035;
  --btn-ink: #0b1a2e;
  --secondary-bg: #16324d;
  --wallet-bg: rgba(0, 180, 216, 0.12);
  --reward-bg: #0d3a5c;
  --reward-ink: #48cae4;
  --bg-glow-1: rgba(0, 180, 216, 0.18);
  --bg-glow-2: rgba(0, 80, 120, 0.3);
  --focus-ring: #00b4d8;
  --theme-menu-bg: #12263d;
  --theme-menu-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="foret"] {
  --bg: #0d1f0d;
  --panel: #142814;
  --ink: #e0e0e0;
  --muted: #7a9a7a;
  --accent: #2ecc71;
  --accent-hover: #58d68d;
  --line: #1e3d1e;
  --like: #2ecc71;
  --ok: #27ae60;
  --bad: #c0392b;
  --shadow: 0 8px 28px rgba(46, 204, 113, 0.12);
  --topbar-from: #0f2a0f;
  --topbar-mid: #163816;
  --topbar-to: #0f2a0f;
  --topbar-ink: #e0e0e0;
  --logo-bg: #2ecc71;
  --logo-ink: #0d1f0d;
  --input-bg: #101f10;
  --btn-ink: #0d1f0d;
  --secondary-bg: #1a321a;
  --wallet-bg: rgba(46, 204, 113, 0.12);
  --reward-bg: #163816;
  --reward-ink: #2ecc71;
  --bg-glow-1: rgba(46, 204, 113, 0.12);
  --bg-glow-2: rgba(20, 60, 20, 0.35);
  --focus-ring: #2ecc71;
  --theme-menu-bg: #142814;
  --theme-menu-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="magenta"] {
  --bg: #1a0a2e;
  --panel: #25123f;
  --ink: #ffffff;
  --muted: #b08cc8;
  --accent: #ff2d95;
  --accent-hover: #ff5aad;
  --line: #4a2a6e;
  --like: #ff2d95;
  --ok: #39ff14;
  --bad: #ff6b6b;
  --shadow: 0 8px 28px rgba(255, 45, 149, 0.2);
  --topbar-from: #2a1050;
  --topbar-mid: #3d1870;
  --topbar-to: #2a1050;
  --topbar-ink: #ffffff;
  --logo-bg: #ff2d95;
  --logo-ink: #1a0a2e;
  --input-bg: #1e0e35;
  --btn-ink: #1a0a2e;
  --secondary-bg: #2e1848;
  --wallet-bg: rgba(255, 45, 149, 0.15);
  --reward-bg: #3d1870;
  --reward-ink: #ff2d95;
  --bg-glow-1: rgba(255, 45, 149, 0.2);
  --bg-glow-2: rgba(120, 40, 200, 0.25);
  --focus-ring: #ff2d95;
  --theme-menu-bg: #25123f;
  --theme-menu-shadow: 0 12px 32px rgba(255, 45, 149, 0.25);
}

[data-theme="rouge"] {
  --bg: #1e0a0a;
  --panel: #2a1212;
  --ink: #f5f0e6;
  --muted: #a88888;
  --accent: #e74c3c;
  --accent-hover: #ff6b5a;
  --line: #5c2020;
  --like: #e74c3c;
  --ok: #c0392b;
  --bad: #ff4757;
  --shadow: 0 8px 28px rgba(231, 76, 60, 0.18);
  --topbar-from: #2a0e0e;
  --topbar-mid: #4a1515;
  --topbar-to: #2a0e0e;
  --topbar-ink: #f5f0e6;
  --logo-bg: #e74c3c;
  --logo-ink: #1e0a0a;
  --input-bg: #220e0e;
  --btn-ink: #1e0a0a;
  --secondary-bg: #351818;
  --wallet-bg: rgba(231, 76, 60, 0.15);
  --reward-bg: #4a1515;
  --reward-ink: #e74c3c;
  --bg-glow-1: rgba(231, 76, 60, 0.15);
  --bg-glow-2: rgba(80, 20, 20, 0.35);
  --focus-ring: #e74c3c;
  --theme-menu-bg: #2a1212;
  --theme-menu-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

[data-theme="gris"] {
  --bg: #1e1e1e;
  --panel: #2a2a2a;
  --ink: #e0e0e0;
  --muted: #888888;
  --accent: #b0b0b0;
  --accent-hover: #d0d0d0;
  --line: #444444;
  --like: #b0b0b0;
  --ok: #8bc34a;
  --bad: #e57373;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --topbar-from: #2a2a2a;
  --topbar-mid: #333333;
  --topbar-to: #2a2a2a;
  --topbar-ink: #e0e0e0;
  --logo-bg: #b0b0b0;
  --logo-ink: #1e1e1e;
  --input-bg: #242424;
  --btn-ink: #1e1e1e;
  --secondary-bg: #333333;
  --wallet-bg: rgba(176, 176, 176, 0.1);
  --reward-bg: #3a3a3a;
  --reward-ink: #d0d0d0;
  --bg-glow-1: rgba(176, 176, 176, 0.06);
  --bg-glow-2: rgba(80, 80, 80, 0.15);
  --focus-ring: #888888;
  --theme-menu-bg: #2a2a2a;
  --theme-menu-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }


/* Wire theme tokens into current BobBook chrome */
html[data-theme] .top {
  background: linear-gradient(90deg, var(--topbar-from, var(--accent)), var(--topbar-to, var(--accent-hover)));
  color: var(--topbar-ink, var(--ink));
}
html[data-theme] .btn { background: var(--accent); color: var(--btn-ink, #fff); }
html[data-theme] .btn:hover { background: var(--accent-hover, var(--accent)); }
html[data-theme] .btn-discord { background: #5865f2; color: #fff; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 400px at 10% -10%, rgba(88,101,242,.2), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(79,195,247,.35), transparent 50%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); }
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem;
  padding: .9rem 1.25rem;
  background: linear-gradient(90deg, #4fc3f7, #5865f2);
  color: #0a2540;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: .7rem; flex: 1; }
.logo {
  width: 2.4rem; height: 2.4rem; border-radius: 8px;
  display: grid; place-items: center;
  background: #fff; color: #5865f2; font-weight: 800;
}
.logo-img {
  width: 2.6rem; height: 1.4rem; object-fit: contain;
  background: rgba(255,255,255,.9); border-radius: 8px; padding: .2rem .15rem;
  box-shadow: 0 2px 8px rgba(10,37,64,.15);
}
.top h1 { margin: 0; font-size: 1.4rem; }
.tag { margin: .1rem 0 0; opacity: .9; font-size: .88rem; }
.auth-box { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; max-width: 28rem; justify-content: flex-end; }
.code-auth { width: 100%; }
.code-auth .hint { margin: 0 0 .35rem; font-size: .82rem; opacity: .9; }
.code-row { display: flex; gap: .4rem; align-items: center; }
.code-row input {
  width: 7.5rem;
  padding: .45rem .55rem;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.15);
  font-size: 1.05rem;
  letter-spacing: .12em;
  font-weight: 700;
  text-align: center;
}
.btn-oauth-fallback { font-size: .78rem; padding: .35rem .65rem; opacity: .85; }
.user-chip {
  display: flex; align-items: center; gap: .55rem;
  background: rgba(255,255,255,.35);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 999px;
  padding: .25rem .45rem .25rem .25rem;
}
.user-chip img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: .9rem; }
.user-meta .muted { font-size: .78rem; }
.btn {
  border: 0; border-radius: 8px; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; padding: .45rem .85rem; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn-discord { background: #5865f2; }
.btn-ghost {
  background: transparent; color: inherit;
  border: 1px solid rgba(0,0,0,.15); padding: .3rem .55rem; font-size: .82rem;
}
.btn-ghost:hover { background: rgba(255,255,255,.35); color: inherit; }
.layout {
  max-width: 980px; margin: 1.2rem auto; padding: 0 1rem 2.5rem;
  display: grid; grid-template-columns: 280px 1fr; gap: 1rem;
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .9rem; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
label { display: block; font-size: .82rem; margin: .45rem 0 .2rem; color: var(--muted); }
textarea, input[type="text"], input[type="number"] {
  width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 8px;
  padding: .55rem .65rem; background: var(--input-bg); color: var(--ink);
}
.row, .sort-row, .post-actions, .tip-row {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
}
.row { margin-top: .65rem; }
.composer.is-locked { opacity: .5; pointer-events: none; }
.composer.is-locked::before {
  content: "connecte-toi avec Discord pour poster";
  display: block; font-size: .85rem; color: var(--muted); margin-bottom: .45rem;
}
.feed-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.feed-header h2 { margin: 0; }
.sort-btn.is-active { outline: 2px solid var(--accent); }
.feed { display: flex; flex-direction: column; gap: .85rem; }
.post {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .95rem 1rem; box-shadow: var(--shadow);
}
.post-head { display: flex; justify-content: space-between; gap: .75rem; margin-bottom: .45rem; }
.post-author-wrap { display: flex; align-items: center; gap: .55rem; }
.post-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #dbe7f5; }
.post-author { font-weight: 700; }
.post-meta { color: var(--muted); font-size: .82rem; }
.post-stats { display: flex; gap: .65rem; color: var(--muted); font-size: .82rem; margin-bottom: .35rem; }
.post-body { white-space: pre-wrap; line-height: 1.45; margin: .35rem 0 .75rem; }
.post-actions { border-top: 1px solid var(--line); padding-top: .65rem; }
.tip-row input { width: 4.5rem; }
.reward-pill {
  display: inline-block; font-size: .78rem; font-weight: 700;
  color: #0277bd; background: #e1f5fe; border-radius: 999px;
  padding: .15rem .5rem; border: 1px solid var(--line); margin-left: .35rem;
}
.side ol { margin: 0; padding-left: 1.15rem; color: var(--muted); }
footer { text-align: center; color: var(--muted); padding: 0 1rem 2rem; font-size: .88rem; }
code { background: rgba(0,0,0,.06); padding: .1rem .3rem; border-radius: 4px; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .auth-box { width: 100%; }
  .user-chip { width: 100%; justify-content: space-between; }
}

.tip-amt { width: 4.5rem; }
.btn-like, .btn-tip { cursor: pointer; }
.tip-status { font-size: .85rem; }


/* ===== Theme bar (boutons en bas) ===== */
.theme-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  box-shadow: 0 -6px 20px rgba(0,0,0,.08);
}
.theme-bar button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.theme-bar button .swatch {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.2);
  flex-shrink: 0;
}
.theme-bar button.is-active {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}
.theme-bar button:hover { filter: brightness(1.05); }
body { padding-bottom: 4.2rem; }
@media (max-width: 720px) {
  .theme-bar { gap: 0.3rem; padding-left: 0.4rem; padding-right: 0.4rem; }
  .theme-bar button { font-size: 0.7rem; padding: 0.3rem 0.5rem; }
  .theme-bar button .label { display: none; }
}

.auth-msg {
  width: 100%;
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
}
.auth-msg.ok { color: var(--ok); }
.auth-msg.bad { color: var(--bad); }
.auth-msg { width:100%; margin:.35rem 0 0; font-size:.85rem; font-weight:600; }
.auth-msg.ok { color: var(--ok, #2ecc71); }
.auth-msg.bad { color: var(--bad, #e74c3c); }
