/* ============================================================
   VARIABLES (LIGHT + DARK)
   ============================================================ */
:root{
  --bg:#ffffff;
  --top:#fffff9;
  --panel:#ffffff;
  --panel2:#fafafa;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e5e7eb;
  --chip:#f3f4f6;

  --accent:#CBC0D1;
  --r:2px;

  --postA:#ffffff;
  --postB:#fffff9;

  --font-logo: Georgia, "Times New Roman", Times, serif;
  --font-post: ui-serif, Georgia, "Times New Roman", Times, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --ui-size:16px;
  --ui-size-small:13px;
  --ui-size-big:18px;

  --search-logo: url("logo.png");
}

[data-theme="dark"]{
  --bg:#0b0f17;
  --top:rgba(11,15,23,.92);
  --panel:#0f1624;
  --panel2:#0b1220;

  --text:#e5e7eb;
  --muted:#a8b0bf;
  --line:rgba(255,255,255,.12);
  --chip:rgba(255,255,255,.08);

  --postA:#0f1624;
  --postB:#0b1220;

  --search-logo: url("logo.png");
}

/* ============================================================
   BASE
   ============================================================ */
*{box-sizing:border-box}
body{
  margin:0;
  font-family:var(--font-ui);
  font-size:var(--ui-size);
  background:var(--bg);
  color:var(--text);
}
a{color:inherit;text-decoration:none}
.wrap{max-width:1080px;margin:0 auto;padding:14px}
button, input, textarea, select{ font: inherit; }

/* ============================================================
   BUTTONS + THEME FAB
   ============================================================ */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:9px 11px;
  border-radius:var(--r);
  border:1px solid var(--line);
  background:var(--panel);
  color:var(--text);
  font-weight:700;
  cursor:pointer;
  user-select:none;
  font-family:var(--font-ui);
}
.btn:focus-visible{outline:3px solid rgba(225,29,72,.18);outline-offset:2px;}

.theme-fab{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:9999;
  padding:10px 12px;
  border-radius:999px;
}

[data-theme="dark"] .btn{
  background:rgba(255,255,255,.06);
  border:1px solid var(--line);
  color:var(--text);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar{
  position:sticky; top:0; z-index:20;
  background:var(--top);
  border-bottom:1px solid var(--line);
}
.topbar .row{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  padding:10px 14px;
  max-width:1080px;
  margin:0 auto;
  flex-wrap:wrap;
}

/* Brand */
.brand{
  display:flex;
  flex-direction:column;
  line-height:1.05;
  min-width:220px;
  padding-left:0;
}
.brand b{
  font-family:var(--font-logo);
  font-size:20px;
  font-weight:900;
  letter-spacing:-.4px;
}
.brand span{
  font-size:var(--ui-size-small);
  color:var(--muted);
  font-style:italic;
}
.brand span i{ opacity:.9; }

/* Search */
.search{
  flex:0 1 520px;
  display:flex;
  align-items:center;
  background:var(--panel2);
  border:1px solid var(--line);
  border-radius:var(--r);
  padding:0 10px 0 0;
  min-width:240px;
  min-height:44px;
  background-image: var(--search-logo);
  background-repeat:no-repeat;
  background-position:0 0;
  background-size:auto 100%;
}
.search input{
  width:100%;
  background:transparent;
  border:0;
  outline:0;
  color:var(--text);
  font-size:14px;
  font-family:var(--font-ui);
  padding:9px 10px 9px 60px;
  height:100%;
}

[data-theme="dark"] .search{ background-color: rgba(255,255,255,.05); }
[data-theme="dark"] .search input{ color:var(--text); }

/* ============================================================
   LAYOUT / CARDS
   ============================================================ */
.grid{
  display:grid;
  grid-template-columns: 1fr 360px;
  gap:12px;
  align-items:start;
  padding-top:12px;
}
.card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--r);
}

/* ============================================================
   FEED / TABS
   ============================================================ */
.feedHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 12px 9px;
  border-bottom:1px solid var(--line);
  gap:10px;
}
.tabs{display:flex; gap:8px; flex-wrap:wrap}
.tab{
  padding:7px 9px;
  background:var(--chip);
  border:1px solid var(--line);
  border-radius:var(--r);
  font-size:13px;
  color:var(--muted);
  font-family:var(--font-ui);
  font-weight:400;
}
.tab.active{
  background:var(--accent);
  color:#fff;
  border-color:var(--accent);
  font-weight:400;
}

/* Feed header tools (Sort + filter) */
.feedTools{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

/* Mini variants (optional tighter controls) */
.select.select--mini{
  min-height:34px;
  padding:6px 34px 6px 10px; /* keep room for the ▾ from .select-wrap::after */
  font-size:13px;
}
.btn.btn--mini{
  padding:7px 10px;
  font-size:13px;
}

/* ============================================================
   POSTS
   ============================================================ */
.feedList{
  display:flex;
  flex-direction:column;
  gap:9px;
  padding:12px;
}

.post{
  border:1px solid var(--line);
  border-radius:var(--r);
  padding:10px 10px 8px;
  background:var(--postA);
}
.feedList article.post:nth-of-type(odd){ background:var(--postA); }
.feedList article.post:nth-of-type(even){ background:var(--postB); }

.postTop{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
}
.meta{
  color:var(--muted);
  font-size:12px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  font-family:var(--font-ui);
}

.body{
  font-family:var(--font-post);
  color:#1f2937;
  line-height:1.6;
  font-size:16px;
  margin:8px 0 10px;
}
.body p{ margin:0 0 10px; }
.body p:last-child{ margin-bottom:0; }
.body strong{font-weight:900;color:var(--text);}
.body i{opacity:.95;}

.actions{display:flex; gap:8px; flex-wrap:wrap}
.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 9px;
  border-radius:var(--r);
  border:1px solid var(--line);
  background:var(--panel2);
  color:var(--muted);
  font-size:13px;
  cursor:pointer;
  font-family:var(--font-ui);
}
.chip.open{
  background:#fff;
  color:var(--text);
  border-color:rgba(203, 192, 209, 0.85);
}

[data-theme="dark"] .chip{
  background:rgba(255,255,255,.06);
  border:1px solid var(--line);
  color:var(--muted);
}
[data-theme="dark"] .chip.open{
  background:rgba(255,255,255,.10);
  border-color:rgba(203, 192, 209, 0.85);
  color:var(--text);
}
[data-theme="dark"] .chip.open:hover{
  background:rgba(255,255,255,.14);
}
[data-theme="dark"] .body{ color:#d6dbe6; }

/* Text ad under every 3rd post */
.textad{
  margin:8px 0 0;
  padding:8px 10px;
  border:1px dashed var(--line);
  background:rgba(203,192,209,.10);
  border-radius:var(--r);
  font-size:13px;
  color:var(--muted);
}
.textad a{
  text-decoration:underline;
}

/* ============================================================
   POST PAGE REPLIES
   ============================================================ */
.repliesWrap{
  margin-top:10px;
  padding-top:10px;
  border-top:1px solid var(--line);
}
.reply{
  border:1px solid var(--line);
  background:var(--panel2);
  border-radius:var(--r);
  padding:10px;
  margin:10px 0;
}
.replyTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}
.replyBody{ margin:0; }
.replyActions{ margin-top:8px; display:flex; gap:8px; flex-wrap:wrap; }
.children{ margin-top:10px; }

/* ============================================================
   COMPOSER
   ============================================================ */
.side .card{position:sticky; top:74px}
.card.composer{ background: var(--panel2); }
.composer{padding:12px}
.composer summary{
  list-style:none;
  cursor:pointer;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  font-family:var(--font-ui);
}
.composer summary::-webkit-details-marker{display:none}
.composer .hint{
  color:var(--muted);
  font-size:13px;
  margin:6px 0 0;
  font-family:var(--font-ui);
}

.toggleHint{
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.toggleHint .chev{ transition:transform .15s ease; }
.composer details[open] .toggleHint .chev{ transform:rotate(180deg); }
.composer details[open] .toggleHint .txt::before{ content:"Hide"; }
.composer details:not([open]) .toggleHint .txt::before{ content:"Show"; }
.toggleHint .txt{ font-size:0; }
.toggleHint .txt::before{ font-size:13px; }

.field{margin-top:10px}

textarea{
  width:100%;
  min-height:110px;
  resize:vertical;
  border-radius:var(--r);
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  padding:10px;
  outline:none;
  line-height:1.55;
  font-size:15px;
  font-family:var(--font-ui);
}
textarea:focus{
  border-color:rgba(225,29,72,.35);
  outline:3px solid rgba(225,29,72,.14);
  outline-offset:2px;
}
[data-theme="dark"] textarea{
  background-color:#191D25;
  border:1px solid var(--line);
  color:var(--text);
}

.row2{display:flex; gap:10px; align-items:center; justify-content:space-between; margin-top:10px}
.small{color:var(--muted); font-size:13px; font-family:var(--font-ui)}

.rules{
  margin-top:10px;
  padding-top:10px;
  border-top:1px solid var(--line);
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
  font-family:var(--font-ui);
}
.rules b{color:var(--text)}
.rules .accent{color:var(--accent); font-weight:800}

/* Category dropdown */
.label{
  display:block;
  margin:10px 0 6px;
  font-size:13px;
  color:var(--muted);
  font-family:var(--font-ui);
}
.select-wrap{ position:relative; }
.select{
  width:100%;
  min-height:42px;
  padding:9px 34px 9px 10px;
  border-radius:var(--r);
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  font-family:var(--font-ui);
  font-size:14px;
  outline:none;
  appearance:none;
  -webkit-appearance:none;
}
.select:focus{
  border-color:rgba(203,192,209,.65);
  outline:3px solid rgba(203,192,209,.22);
  outline-offset:2px;
}
.select-wrap::after{
  content:"▾";
  position:absolute;
  right:10px;
  top:50%;
  transform:translateY(-50%);
  color:var(--muted);
  pointer-events:none;
  font-size:14px;
}
[data-theme="dark"] .select{
  color-scheme: dark;
  background-color:#191D25;
  border: 1px solid var(--line);
  color:var(--text) !important;
}
[data-theme="dark"] .select-wrap::after{
  color:var(--text);
  opacity:.8;
}

/* Placeholder text */
textarea::placeholder,
input::placeholder {
  color: #94A3B8;
  opacity: 1;
}

[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] input::placeholder {
  color: #64748B;
  opacity: 1;
}

/* ============================================================
   AD SLOT
   ============================================================ */
.ad-slot{margin-top:12px; background:transparent; border:0; padding:0;}
.ad-placeholder{
  width:100%;
  min-height:120px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--panel2);
  border:0;
  border-radius:0;
  color:var(--muted);
  font-size:13px;
  font-family:var(--font-ui);
}

/*============================================================
REFERRERS
============================================================*/
.refcard {
  margin-top: 12px;
  background: var(--panel2);
}

.refhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--line);
}

.reflist {
  list-style: none;
  margin: 0;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.refitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
}

.refcount {
  min-width: 28px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--muted);
  font-weight: 800;
}

[data-theme="dark"] .refitem {
  background: rgba(255, 255, 255, .06);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 980px){
  .grid{
    display:flex;
    flex-direction:column;
    gap:12px;
    padding-top:12px;
    width:100%;
  }
  .grid > section,
  .grid > aside{
    width:100%;
    max-width:none;
  }
  .side{width:100%}
  .side .card{position:static; width:100%; max-width:none;}
}

@media (max-width: 560px){
  .wrap{max-width:none; padding:0}
  .topbar .row{padding:10px 12px}

  .search{
    flex:1 1 100%;
    order:10;
    min-width:0;
    width:auto;
    margin:0 0 10px;
    border:1px solid var(--line);
    border-radius:var(--r);
  }

  .card{
    border-left:0;
    border-right:0;
    border-radius:0;
  }

  .feedHead{padding:12px}
  .feedList{padding:0}

  .post{
    border-left:0;
    border-right:0;
    border-radius:0;
    border-top:0;
    border-bottom:1px solid var(--line);
    padding:12px;
    margin:0;
  }

  .composer{padding:12px}
  .ad-slot{padding:0 12px 12px}

  .theme-fab{ right:12px; bottom:12px; }
}

@media (min-width: 900px){
  body{ font-size: var(--ui-size-big); }
  .brand b{ font-size: 24px; }
  .brand span{ font-size: 14px; }
  .body{ font-size: 17px; }
  textarea{ font-size: 16px; }
  .chip{ font-size: 14px; }
  .tab{ font-size: 14px; }
}
