:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1d232b;
  --muted: #5b6573;
  --line: #e4e0d8;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --accent-soft: #e8eff6;
  --tag: #8a5a12;
  --tag-bg: #f6ecd9;
  --radius: 12px;
  --font: "Vazirmatn", Tahoma, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --surface: #1a2027;
    --ink: #e7e9ec;
    --muted: #9aa4b1;
    --line: #2a323c;
    --accent: #8fb8e6;
    --accent-ink: #10202f;
    --accent-soft: #1f2b38;
    --tag: #e7c48a;
    --tag-bg: #3a2f1c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.9;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.en { font-family: var(--font); }
h1 .en, h2 .en { color: var(--muted); font-weight: inherit; font-size: inherit; margin-inline-start: .3em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Header: portrait + name on the right (RTL start), compact search, bold nav */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; gap: 18px; padding-top: 10px; padding-bottom: 10px; }
.brand-col { display: flex; flex-direction: column; gap: 8px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-fa, .brand-en { font-weight: 800; font-size: 1.15rem; }
.brand-en { color: var(--muted); }
.nav { display: flex; gap: 20px; margin-inline-start: auto; flex-wrap: wrap; }
.nav a { color: var(--ink); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.nav a .en { font-weight: 700; color: var(--muted); font-size: inherit; margin-inline-start: 4px; }

.search { display: flex; gap: 6px; }
.search-mini { width: 280px; }
.search-mini { position: relative; display: block; }
.search-mini input {
  padding: 9px 16px; padding-inline-end: 46px; font-size: .95rem;
  border: 1.5px solid var(--line); border-radius: 999px; -webkit-appearance: none; appearance: none;
}
.search-mini input:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.search-mini input::-webkit-search-cancel-button { display: none; }
.search-icon {
  position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: #1a73e8;
}
.search-icon:hover { background: rgba(26,115,232,.1); }
input, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; width: 100%; min-width: 0;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .page-btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); padding: 10px 18px; white-space: nowrap;
}
button .en { font-weight: inherit; margin-inline-start: 4px; }
button:disabled { opacity: .6; cursor: progress; }

h1, h2 { line-height: 1.45; }
h1 { font-size: 2rem; font-weight: 800; margin: 0 0 .3em; }
h2 { font-size: 1.4rem; font-weight: 800; margin: 0 0 .5em; }

.hero { padding: 22px 0 6px; text-align: center; }
.hero h1 { font-size: 1.75rem; margin-bottom: .1em; }
.lede { margin: .2em 0; color: var(--muted); font-size: 1.1rem; }


/* Ask: the main feature, so it gets room */
.ask {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px 28px; margin: 12px 0 36px; box-shadow: 0 1px 0 var(--line);
}
.ask h2 { font-size: 1.8rem; }
.hint { margin: 0; color: var(--muted); }
.hint.en { margin-bottom: 18px; }
#ask-form { display: flex; flex-direction: column; gap: 12px; }
#ask-input { font-size: 1.1rem; min-height: 110px; resize: vertical; }
#ask-btn { align-self: flex-start; font-size: 1.1rem; padding: 12px 30px; }
.answer { margin-top: 20px; padding: 18px 20px; background: var(--accent-soft); border-radius: 12px; white-space: pre-wrap; font-size: 1.05rem; }
.answer.error { background: var(--tag-bg); }
.sources { margin-top: 10px; font-size: .92rem; color: var(--muted); }
.sources a { margin-inline-end: 12px; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); }
.card:hover { text-decoration: none; border-color: var(--accent); }
.thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--line); }
.card-body { padding: 12px 14px 16px; }
.meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.tag { background: var(--tag-bg); color: var(--tag); border-radius: 999px; padding: 0 9px; font-size: .78rem; }
.card-title { font-weight: 700; line-height: 1.6; margin-top: 4px; }
.card-title-en { font-size: 1em; font-weight: 700; color: var(--muted); line-height: 1.6; margin-top: 2px; }
.snippet { font-size: .88rem; color: var(--muted); margin: 8px 0 0; line-height: 1.7; }

.pages { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 48px; }
.page-btn { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.page-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.page-btn:hover { text-decoration: none; filter: brightness(1.05); }
.page-btn .en { margin-inline-start: 4px; }
.page-count { color: var(--muted); font-size: .9rem; }

.page-head { padding: 32px 0 16px; }
.count, .empty { color: var(--muted); }

.episode, .article { max-width: 820px; margin: 0 auto; padding: 28px 0 48px; }
.episode-head h1, .article h1 { margin-top: .2em; }
.title-en { color: var(--muted); font-size: 2rem; font-weight: 800; line-height: 1.45; margin: 0 0 18px; }
.player { position: sticky; top: 124px; z-index: 4; background: var(--bg); padding-bottom: 8px; }
.player > div, .player iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: var(--radius); display: block; background: #000; }
.transcript { margin-top: 24px; }
.note { font-size: .88rem; color: var(--muted); }
.para { margin: 0 0 1em; }
.ts { display: inline-block; font-size: .78rem; background: var(--accent-soft); border-radius: 6px; padding: 0 7px; margin-inline-end: 6px; vertical-align: 2px; }
.external-note { margin-top: 24px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); }
.article-body { font-size: 1.08rem; line-height: 2.05; }
.article-body img { height: auto; border-radius: 8px; }
.article-body blockquote { margin: 1em 0; padding: .2em 1em; border-inline-start: 3px solid var(--line); color: var(--muted); }
.source-link { font-size: .9rem; color: var(--muted); }

.prose { max-width: 760px; margin: 0 auto; padding: 32px 0 48px; }
.about-photo { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; float: left; margin: 0 0 12px 20px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; clear: both; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; padding: 22px 0 36px; }
.site-footer p { margin: .3em 0; }

/* Tablet: search drops under the brand row */
@media (max-width: 960px) {
  .header-row { flex-wrap: wrap; row-gap: 10px; }
  .nav { margin-inline-start: auto; }
}
/* Phone */
@media (max-width: 600px) {
  body { font-size: 16px; }
  h1, .title-en { font-size: 1.5rem; }
  .header-row { gap: 10px; }
  .brand-col { width: 100%; }
  .search-mini { width: 100%; }
  .avatar { width: 40px; height: 40px; }
  .brand-fa, .brand-en { font-size: 1rem; }
  .nav { order: 4; width: 100%; justify-content: space-between; gap: 6px; margin: 0; }
  .nav a { font-size: .95rem; }
  .nav a .en { display: block; font-size: inherit; line-height: 1.2; margin: 0; }
  .hero { padding: 24px 0 8px; }
  .ask { padding: 20px 16px; border-radius: 14px; }
  .ask h2 { font-size: 1.5rem; }
  #ask-btn { align-self: stretch; }
  .grid { grid-template-columns: 1fr; }
  .pages { flex-wrap: wrap; }
  .page-count { order: -1; width: 100%; text-align: center; }
  .player { position: static; }
  .about-photo { float: none; display: block; margin: 0 auto 16px; }
}

/* Articles list */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tabs a { padding: 4px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: .95rem; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; }
.list { list-style: none; padding: 0; margin: 0 0 24px; }
.list-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
.list-title { display: block; font-weight: 700; font-size: 1.08rem; color: var(--ink); margin-top: 2px; }
.ext { color: var(--muted); font-size: .85em; }

/* Social links */
.social { display: flex; gap: 6px; align-items: center; }
.social a { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); border: 1px solid var(--line); }
.social a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.social-footer { margin-bottom: 10px; }

/* Translation toggle */
.translation { margin: 28px 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.translation summary { cursor: pointer; padding: 12px 18px; font-weight: 700; color: var(--accent); list-style: none; }
.translation summary::-webkit-details-marker { display: none; }
.translation summary::before { content: "▸ "; }
.translation[open] summary::before { content: "▾ "; }
.translation > .note, .translation > .article-body { padding: 0 18px; }
.translation > .article-body { padding-bottom: 12px; text-align: left; }
/* Phones: keep the header to 3 short rows and get Ask on screen without scrolling */
@media (max-width: 600px) {
  .site-header .social { display: none; }
  .site-header { position: static; }
  .header-row { padding-top: 6px; padding-bottom: 6px; row-gap: 6px; }
  .brand-col { gap: 6px; }
  .hero { padding: 10px 0 0; }
  .hero h1 { font-size: 1.15rem; }
  .hero .lede { display: none; }
  .ask { padding: 14px 14px 16px; margin: 8px 0 24px; }
  .ask h2 { font-size: 1.3rem; margin-bottom: .2em; }
  .ask .hint { font-size: .85rem; line-height: 1.6; }
  .ask .hint.en { display: none; }
  #ask-input { min-height: 78px; font-size: 1rem; }
  #ask-form { gap: 8px; }
  #ask-btn { padding: 10px 18px; }
}

/* Article list: Persian title on the right, English title on the left */
.title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.list-title-en { font-weight: 700; font-size: 1.08rem; color: var(--accent); text-align: left; margin-right: auto; }  /* physical side: the link is dir=ltr inside an RTL row */
.en-link { margin: -4px 0 18px; }
.en-link a { font-weight: 700; }
