:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --border: #e7e3d9;
  --ink: #1d1b17;
  --ink-soft: #6f6a60;
  --accent: #c23d2c;
  --radius: 10px;
  --shadow: 0 8px 20px rgba(29, 27, 23, 0.06);

  --c-jokes: #c4831f;
  --c-shayari: #a8375c;
  --c-quotes: #227a67;
  --c-stories: #3d4f9e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141310;
    --surface: #1c1a16;
    --border: #322e26;
    --ink: #ece7dc;
    --ink-soft: #9c9689;
    --accent: #e2664f;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.35);

    --c-jokes: #dda03f;
    --c-shayari: #cc6f8e;
    --c-quotes: #4fab93;
    --c-stories: #7c8ad6;
  }
}

:root[data-theme="dark"] {
  --bg: #141310;
  --surface: #1c1a16;
  --border: #322e26;
  --ink: #ece7dc;
  --ink-soft: #9c9689;
  --accent: #e2664f;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.35);

  --c-jokes: #dda03f;
  --c-shayari: #cc6f8e;
  --c-quotes: #4fab93;
  --c-stories: #7c8ad6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Karla', sans-serif;
}

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

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 18px 60px;
}

/* ---------- Top bar ---------- */
header.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.top-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.wordmark em {
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
}

.tagline {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.head-right {
  flex: 1;
  min-width: 140px;
  max-width: 260px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.search { width: 100%; }

/* Social handles — search ke neeche (feed) / header ke daayein (article page) */
.socials { display: flex; gap: 8px; margin-left: auto; }
.socials a {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--surface);
}
.socials a:hover { color: var(--accent); border-color: var(--accent); }
.socials svg { width: 15px; height: 15px; display: block; }

.search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  font-family: 'Karla', sans-serif;
  font-size: 14px;
  color: var(--ink);
}

.search input::placeholder { color: var(--ink-soft); }
.search input:focus { outline: none; border-color: var(--accent); }

.filters {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-top: 12px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.filter {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 0 0 10px;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  font-family: 'Karla', sans-serif;
}

.filter .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--ink-soft));
}

.filter.active {
  color: var(--ink);
  border-bottom-color: var(--dot, var(--accent));
}

/* ---------- Layout: feed + ad rail ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 28px;
  margin-top: 24px;
  align-items: start;
}

.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  /* har card apni oonchai ka — warna ek lamba card (article) apni line ke baaki cards ko bhi kheench deta tha */
  align-items: start;
}

.rail {
  position: sticky;
  top: calc(88px + env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Ad containers stay hidden until real ad content actually fills them —
   never ship an empty placeholder box to visitors. */
.ad-slot[hidden] { display: none; }

.ad-slot {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.ad-slot.med { aspect-ratio: 300 / 250; }
.ad-slot.big { aspect-ratio: 300 / 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px 8px;
  font-size: 12px;
}

.card-meta .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
  flex: none;
}

.card-meta .cat {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--dot);
}

.card-meta .date {
  margin-left: auto;
  color: var(--ink-soft);
}

.card img.art {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.caption {
  margin: 10px 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
  /* lamba caption 3 line pe ruk jaaye — sab image cards lagbhag barabar rahein */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Story card ---------- */
.card.story {
  grid-column: span 2;
  padding: 18px 20px 20px;
}

.card.story .card-meta { padding: 0 0 10px; }

.story-head {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 21px;
  margin: 0 0 8px;
}

.story-body {
  font-size: 15px;
  line-height: 1.7;
  max-width: 62ch;
  white-space: pre-line;
}

.story-body strong {
  display: inline-block;
  margin-top: 6px;
  font-family: 'Fraunces', serif;
  font-size: 17px;
}

/* Lamba article feed mein chhota dikhta hai; "Poora padho" pe poori chaudai mein khulta hai */
.card.story.long:not(.open) .story-body {
  max-height: calc(1.7em * 9);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}

.card.story.open { grid-column: 1 / -1; }
.card.story.open .story-body { max-width: 68ch; }

.read-more {
  align-self: flex-start;
  margin-top: 12px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: 700 13px 'Karla', sans-serif;
  cursor: pointer;
}

.read-more:hover { border-color: var(--accent); }

@media (max-width: 560px) {
  .card.story { grid-column: 1 / -1; }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}

.empty-state h3 {
  font-family: 'Fraunces', serif;
  color: var(--ink);
  font-size: 20px;
  margin-bottom: 6px;
}

footer.site-footer {
  margin-top: 40px;
  font-size: 13px;
  color: var(--ink-soft);
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .rail { display: none; }
}

@media (max-width: 480px) {
  .feed { grid-template-columns: repeat(2, 1fr); }
  .card.story { grid-column: span 2; }
  .wordmark { font-size: 22px; }
  .tagline { display: none; }
}

/* ---------- Admin ---------- */
.admin-wrap {
  max-width: 440px;
  margin: 60px auto;
  padding: 0 20px;
}

.admin-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 28px;
}

.admin-card h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 18px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: 'Karla', sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--ink);
}

.field textarea { resize: vertical; min-height: 110px; }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.file-drop {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  color: var(--ink-soft);
  cursor: pointer;
  background: var(--bg);
}

.file-drop.has-file { border-color: var(--c-quotes); color: var(--c-quotes); font-weight: 600; }

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff8ee;
  font-family: 'Karla', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}

.btn:hover { filter: brightness(0.92); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.status-msg {
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
}
.status-msg.success { color: var(--c-quotes); }
.status-msg.error { color: var(--accent); }

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 440px;
  margin: 20px auto 0;
  padding: 0 20px;
}

.logout-link {
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
}

.recent-list {
  max-width: 440px;
  margin: 20px auto 60px;
  padding: 0 20px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}

.recent-item img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--border);
}

.recent-item .cat {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 700;
}

.recent-item .del {
  margin-left: auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Story actions + article page (har article ka apna link: /a/<slug>/) ---------- */
.story-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.story-head a:hover { color: var(--accent); }
a.read-more { display: inline-block; text-decoration: none; }

.article-page { max-width: 68ch; margin: 34px auto 0; }
.article-date { font-size: 13px; color: var(--ink-soft); }
.article-page h1 { font-family: 'Fraunces', serif; font-size: 34px; line-height: 1.3; margin: 8px 0 22px; }
.article-page h2 { font-family: 'Fraunces', serif; font-size: 22px; line-height: 1.4; margin: 34px 0 10px; }
.article-body p { font-size: 17px; line-height: 1.8; margin: 0 0 16px; }
.article-share { display: flex; flex-wrap: wrap; gap: 8px; margin: 30px 0 18px; padding-top: 22px; border-top: 1px solid var(--border); }
.article-back { font-size: 14px; color: var(--accent); font-weight: 700; }

@media (max-width: 560px) {
  .article-page h1 { font-size: 26px; }
  .article-body p { font-size: 16px; }
}

footer.site-footer a { color: var(--accent); }
