/* ============================================================
   SnitzModern — 2026 design system
   Dark-first, card-based, mobile-first. Works with Tailwind CDN
   (colors are mapped to the CSS variables below).
   ============================================================ */

:root {
  --bg: #f4f5fb;
  --bg-2: #e9ebf5;
  --card: #ffffff;
  --card-2: #f6f7fc;
  --line: #e3e6f0;
  --fg: #171a26;
  --muted: #5b6178;
  --faint: #9aa0b8;
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --accent: #06b6d4;
  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 1px 2px rgba(23, 26, 38, .05), 0 8px 24px -12px rgba(23, 26, 38, .12);
  --shadow-lg: 0 12px 40px -12px rgba(23, 26, 38, .22);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0e1a;
  --bg-2: #0f1322;
  --card: #141829;
  --card-2: #1a1f36;
  --line: #242a45;
  --fg: #e8eaf6;
  --muted: #a4abc9;
  --faint: #666e90;
  --brand: #818cf8;
  --brand-2: #a78bfa;
  --accent: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

html { scroll-behavior: smooth; }
body { min-height: 100vh; background:
  radial-gradient(1100px 480px at 85% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 60%),
  radial-gradient(900px 420px at -10% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 55%),
  var(--bg);
  background-attachment: fixed;
}

::selection { background: color-mix(in srgb, var(--brand) 30%, transparent); }

/* ---------- scrollbar ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout helpers ---------- */
.container-app { max-width: 1180px; margin: 0 auto; padding: 0 1rem; }

.card {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.card-hover { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font-weight: 600; font-size: .875rem; line-height: 1;
  padding: .62rem 1.05rem; border-radius: .7rem;
  border: 1px solid transparent; cursor: pointer; user-select: none;
  transition: all .16s ease; white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 6px 18px -8px var(--brand); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--fg); border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.btn-soft { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.btn-soft:hover { background: color-mix(in srgb, var(--brand) 20%, transparent); }
.btn-danger { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 20%, transparent); }
.btn-sm { padding: .42rem .7rem; font-size: .78rem; border-radius: .55rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; border-radius: .6rem;
  color: var(--muted); border: 1px solid transparent; background: transparent;
  cursor: pointer; transition: all .15s ease; font-size: 1rem;
}
.icon-btn:hover { color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.icon-btn.danger:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }

/* ---------- forms ---------- */
.input, .select, .textarea {
  width: 100%; background: var(--card-2); color: var(--fg);
  border: 1px solid var(--line); border-radius: .7rem;
  padding: .62rem .85rem; font-size: .9rem; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.field { margin-bottom: 1rem; }

/* ---------- badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  padding: .22rem .55rem; border-radius: 999px; line-height: 1;
  text-transform: uppercase;
}
.badge-brand { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.badge-good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.badge-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge-bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.badge-muted { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); }
.badge-accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

.dot-new { width: .55rem; height: .55rem; border-radius: 999px; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); display: inline-block; }

/* ---------- header ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.navlink {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .8rem; border-radius: .6rem;
  font-size: .86rem; font-weight: 600; color: var(--muted);
  transition: all .15s ease; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.navlink:hover { color: var(--fg); background: color-mix(in srgb, var(--brand) 9%, transparent); }
.navlink.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }

/* ---------- posts ---------- */
.post-body { font-size: .95rem; line-height: 1.75; overflow-wrap: anywhere; }
.post-body p { margin: 0 0 .9em; }
.post-body p:last-child { margin-bottom: 0; }
.post-body img { max-width: 100%; border-radius: .6rem; }
.post-body a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.post-body blockquote {
  border-left: 3px solid var(--brand); margin: 1em 0; padding: .7rem 1rem;
  background: color-mix(in srgb, var(--brand) 7%, transparent); border-radius: 0 .6rem .6rem 0;
  color: var(--muted); font-size: .92em;
}
.post-body pre, .post-body code {
  font-family: 'JetBrains Mono', monospace; font-size: .85em;
  background: var(--card-2); border: 1px solid var(--line); border-radius: .5rem;
}
.post-body code { padding: .1rem .35rem; }
.post-body pre { padding: .9rem 1rem; overflow-x: auto; margin: 1em 0; }
.post-body pre code { background: none; border: none; padding: 0; }
.post-body ul, .post-body ol { padding-left: 1.4rem; margin: .6em 0; }
.post-body h1, .post-body h2, .post-body h3 { font-weight: 700; margin: 1em 0 .4em; }
.post-body hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.post-body table { border-collapse: collapse; width: 100%; }
.post-body td, .post-body th { border: 1px solid var(--line); padding: .4rem .6rem; }

.avatar {
  width: 3rem; height: 3rem; border-radius: .9rem; object-fit: cover;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1.1rem; flex-shrink: 0;
  border: 1px solid var(--line);
}
.avatar-lg { width: 6rem; height: 6rem; border-radius: 1.4rem; font-size: 2.4rem; }

.stars { letter-spacing: .1em; font-size: .8rem; }
.star-gold { color: #f59e0b; } .star-silver { color: #94a3b8; } .star-bronze { color: #b45309; }
.star-orange { color: #f97316; } .star-red { color: #ef4444; } .star-purple { color: #a855f7; }
.star-blue { color: #3b82f6; } .star-cyan { color: #06b6d4; } .star-green { color: #22c55e; }

/* ---------- topic rows ---------- */
.topic-row { transition: background .14s ease, border-color .14s ease; }
.topic-row:hover { background: color-mix(in srgb, var(--brand) 5%, transparent); }

.folder-icon { font-size: 1.35rem; line-height: 1; }
.folder-new { color: var(--accent); }
.folder-old { color: var(--faint); }
.folder-lock { color: var(--warn); }

/* ---------- breadcrumbs ---------- */
.crumb { color: var(--faint); font-size: .82rem; font-weight: 500; text-decoration: none; }
.crumb:hover { color: var(--brand); }
.crumb-sep { color: var(--faint); margin: 0 .35rem; font-size: .75rem; }

/* ---------- pagination ---------- */
.page-btn {
  min-width: 2.1rem; height: 2.1rem; padding: 0 .55rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: .55rem; font-size: .82rem; font-weight: 600;
  color: var(--muted); border: 1px solid var(--line); background: var(--card);
  cursor: pointer; transition: all .14s ease;
}
.page-btn:hover { border-color: var(--brand); color: var(--brand); }
.page-btn.current { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line); }
.text-gradient { background: linear-gradient(120deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--faint); }
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: .8rem; opacity: .5; }

.spinner {
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, var(--card-2) 25%, var(--line) 50%, var(--card-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: .6rem; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toast {
  position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 100;
  display: flex; flex-direction: column; gap: .5rem; max-width: 22rem;
}
.toast-item {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: .8rem; padding: .8rem 1rem; box-shadow: var(--shadow-lg);
  font-size: .87rem; font-weight: 500; animation: slidein .25s ease;
}
.toast-item.err { border-left-color: var(--bad); }
.toast-item.ok { border-left-color: var(--good); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.fade-in { animation: fadein .28s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(5, 8, 20, .55);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fadein .18s ease;
}
.modal-card { width: 100%; max-width: 30rem; max-height: 88vh; overflow-y: auto; animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* poll */
.poll-bar { height: .55rem; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.poll-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .5s ease; }

/* highlight for search terms */
mark.hl { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: .2rem; padding: 0 .1rem; }

/* ---------- TinyMCE theme bridge ---------- */
.tox-tinymce { border-radius: .8rem !important; border-color: var(--line) !important; }
.tox .tox-edit-area__iframe { background: var(--card-2) !important; }

/* ---------- print (printer-friendly view) ---------- */
@media print {
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .card { border: none; box-shadow: none; }
}

@media (max-width: 768px) {
  .post-author-aside { flex-direction: row !important; align-items: center; gap: .8rem; }
  .post-author-aside .avatar { width: 2.4rem; height: 2.4rem; border-radius: .6rem; }
}
