@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --teal: #2e86de;
  --accent: #2e86de;
  --accent-ink: #14509c;
  --accent-soft: #dbeafc;
  --dim: #c6d2e2;
  --bg: #eaf2fb;
  --surface: #ffffff;
  --surface-2: #f3f8fe;
  --ink: #1b2b42;
  --ink-2: #566a85;
  --ink-3: #8497b0;
  --line: #d8e5f4;
  --line-strong: #bdd2ea;
  --grid: rgba(46, 134, 222, 0.14);
  --lane-alt: rgba(46, 134, 222, 0.05);
  --appbar: #2a76d2;
  --appbar-2: #164a9e;
  --danger: #e74c5a;
  --shadow: 0 6px 22px rgba(10, 60, 70, 0.16);
  --art: url(../img/persepolis-light.svg);
  --appbar-h: 54px;
  --tab-h: 60px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #5aaeff;
  --accent-ink: #a5d2ff;
  --accent-soft: #15325c;
  --dim: #34475e;
  --bg: #0b1626;
  --surface: #12233a;
  --surface-2: #182c48;
  --ink: #e4eefc;
  --ink-2: #a6bbd8;
  --ink-3: #7189ab;
  --line: #213a5c;
  --line-strong: #2f5079;
  --grid: rgba(90, 174, 255, 0.14);
  --lane-alt: rgba(255, 255, 255, 0.03);
  --art: url(../img/persepolis-dark.svg);
  --appbar: #12356b;
  --appbar-2: #0c2650;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: "Vazirmatn", "Noto Sans Arabic", Tahoma, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* —— نوار بالا —— */
#appbar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  height: calc(var(--appbar-h) + var(--safe-t));
  padding: var(--safe-t) 14px 0;
  background: linear-gradient(135deg, var(--appbar), var(--appbar-2));
  color: #fff;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
#appbar .logo { width: 34px; height: 34px; flex: none; }
#appbar .titles { flex: 1; min-width: 0; line-height: 1.25; }
#appbar h1 { margin: 0; font-size: 1.12rem; font-weight: 800; letter-spacing: -0.2px; }
#appbar .sub { font-size: 0.72rem; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#appbar .icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, 0.16);
}
#appbar .icon-btn:active { background: rgba(255, 255, 255, 0.3); }

/* —— صحنه —— */
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--bg) var(--art) center bottom / cover no-repeat; }
#tl { position: absolute; inset: 0; display: block; touch-action: none; cursor: grab; outline: none; }
#tl:active { cursor: grabbing; }

#yearPill {
  position: absolute; top: 38px; left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--accent-ink);
  border: 1px solid var(--line-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 0.74rem; font-weight: 700; white-space: nowrap;
  pointer-events: none; backdrop-filter: blur(6px);
  direction: rtl;
}

#modeBar { position: absolute; top: 72px; left: 0; right: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.mode-chip { pointer-events: auto; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.78rem; font-weight: 700; box-shadow: var(--shadow); }
.mode-chip span { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-chip button { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.25); color: #fff; }
.mode-chip svg { width: 15px; height: 15px; }
#fabs { position: absolute; left: 12px; bottom: calc(14px + var(--card-px, 0px)); transition: bottom 0.32s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.2s; display: flex; flex-direction: column; gap: 10px; z-index: 5; }
.fab {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--accent-ink);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  transition: transform 0.12s ease;
}
.fab:active { transform: scale(0.92); }
@media (pointer: coarse) { .fab.desk { display: none; } }

#toast {
  position: absolute; left: 50%; bottom: 74px; transform: translate(-50%, 12px);
  max-width: min(86vw, 420px); padding: 10px 16px; border-radius: 14px;
  background: rgba(24, 38, 44, 0.94); color: #fff; font-size: 0.82rem; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 30;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* —— نوار پایین —— */
#tabbar {
  flex: none; display: flex;
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 0 4px var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 40; position: relative;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); font-size: 0.68rem; font-weight: 600; border-radius: 14px; margin: 5px 2px;
  transition: color 0.15s, background 0.15s;
}
.tab svg { width: 26px; height: 26px; }
.tab.on { color: var(--accent-ink); background: var(--accent-soft); }
.tab:active { background: var(--surface-2); }

/* —— Bottom sheet —— */
#scrim { position: fixed; inset: 0 0 calc(var(--tab-h) + var(--safe-b)) 0; background: rgba(8, 20, 24, 0.38); opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 50; }
#scrim.open { opacity: 1; pointer-events: auto; }
#sheet {
  position: fixed; z-index: 60;
  left: 50%; width: min(100%, 680px);
  bottom: calc(var(--tab-h) + var(--safe-b));
  max-height: min(56dvh, calc(100dvh - var(--appbar-h) - var(--safe-t) - var(--tab-h) - var(--safe-b) - 24px));
  display: flex; flex-direction: column;
  background: var(--surface) var(--art) center bottom / 100% auto no-repeat; color: var(--ink);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, calc(100% + 80px));
  transition: transform 0.32s cubic-bezier(0.2, 0.85, 0.25, 1);
  visibility: hidden;
}
#sheet.tall { max-height: min(76dvh, calc(100dvh - var(--appbar-h) - var(--safe-t) - var(--tab-h) - var(--safe-b) - 24px)); }
#sheet.open { transform: translate(-50%, 0); visibility: visible; }
#sheet:not(.open) { transition: transform 0.28s ease, visibility 0s 0.28s; }
#sheetHead { flex: none; padding: 8px 12px 6px; touch-action: none; cursor: grab; }
#sheetHead .grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 8px; }
.sheet-bar { display: flex; align-items: center; gap: 8px; }
#sheetTitle { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheetHead button { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); background: var(--surface-2); }
#sheetBody { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 20px; -webkit-user-select: text; user-select: text; touch-action: pan-y; }

/* —— اجزای محتوا —— */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip {
  --c: var(--ink-3);
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line));
  font-size: 0.75rem; font-weight: 600;
}
.chips.tags .chip { --c: var(--ink-3); font-weight: 500; color: var(--ink-2); }
.btnchip { cursor: pointer; padding: 6px 14px; font-size: 0.82rem; }
.btnchip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.date-block { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.date-label { font-size: 0.7rem; color: var(--ink-3); font-weight: 600; }
.date-main { font-size: 1.05rem; font-weight: 800; color: var(--accent-ink); margin: 1px 0; }
.date-alt { display: flex; flex-direction: column; font-size: 0.7rem; color: var(--ink-2); }
.dates > .date-block:only-child { grid-column: 1 / -1; }

.approx-note { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 8px; padding: 9px 12px; border-radius: 12px; background: color-mix(in srgb, #e0a020 16%, var(--surface)); border: 1px solid color-mix(in srgb, #e0a020 55%, var(--line)); font-size: 0.8rem; line-height: 1.8; color: var(--ink); }
.approx-note b { font-weight: 800; color: #9a6400; }
:root[data-theme="dark"] .approx-note b { color: #f0c060; }
.li-year.approx { color: #9a6400; }
:root[data-theme="dark"] .li-year.approx { color: #f0c060; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 2px; border-bottom: 1px dashed var(--line); font-size: 0.86rem; }
.kv span { color: var(--ink-3); }
.kv b { font-weight: 600; text-align: left; }

.para { margin: 14px 0; }
.para h3, .sec { margin: 0 0 6px; font-size: 0.78rem; font-weight: 800; color: var(--accent-ink); letter-spacing: 0.2px; }
.sec { margin-top: 18px; }
.para p { margin: 0; line-height: 1.95; font-size: 0.92rem; color: var(--ink); text-align: justify; }
.rulers { margin: 0; padding: 0; list-style: none; }
.rulers li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.rulers em { color: var(--ink-2); font-style: normal; }
.rulers p { margin: 3px 0 0; color: var(--ink-2); line-height: 1.8; }

.place, .sources a { display: flex; align-items: center; gap: 8px; color: var(--accent-ink); text-decoration: none; font-size: 0.84rem; padding: 7px 0; }
.place svg, .sources svg { width: 18px; height: 18px; flex: none; }
.sources { list-style: none; margin: 0; padding: 0; }
.sources a { direction: ltr; text-align: left; unicode-bidi: plaintext; }
.sources a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 14px; font-size: 0.86rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:active { transform: scale(0.97); }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.list-item:active { background: var(--surface-2); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-main b { font-weight: 700; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-main small { color: var(--ink-3); font-size: 0.72rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.li-tag { display: inline-block; font-weight: 800; font-size: 0.68rem; line-height: 1.6; padding: 0 8px; border-radius: 999px; color: var(--ink); background: color-mix(in srgb, var(--c, var(--accent)) 28%, transparent); border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 55%, transparent); }
.li-year { color: var(--accent-ink); font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.more, .empty, .range-note, .hint { color: var(--ink-3); font-size: 0.8rem; text-align: center; padding: 14px 0; line-height: 1.8; }
.hint { text-align: right; padding: 6px 0 0; }
.range-note { padding: 2px 0 8px; text-align: right; }

.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 16px; padding: 0 12px; margin: 4px 0 8px; color: var(--ink-3); }
.search-input { flex: 1; border: 0; background: none; outline: none; height: 46px; font-size: 16px; color: var(--ink); -webkit-user-select: text; user-select: text; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; }
.seg-btn { flex: 1; padding: 9px 4px; border-radius: 11px; font-size: 0.84rem; font-weight: 700; color: var(--ink-2); }
.seg-btn.on { background: var(--accent); color: #fff; }

.lane-list { list-style: none; margin: 0; padding: 0; }
.lane-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lane-name { flex: 1; font-weight: 600; font-size: 0.9rem; display: flex; flex-direction: column; }
.lane-name small { color: var(--ink-3); font-weight: 400; font-size: 0.72rem; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background 0.2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(-18px); }
.help { margin: 0; padding: 0 18px 0 0; line-height: 2; font-size: 0.86rem; color: var(--ink-2); }

.rel-title { margin: 12px 0 2px; font-size: 0.8rem; font-weight: 700; color: var(--ink-2); }
.rel .list-item { padding: 8px 4px; }

/* —— صفحهٔ کاوش —— */
.home { padding-top: 10px; }
.search-box.big { height: 62px; padding: 0 18px; border-radius: 22px; margin: 8px 0 14px; }
.search-box.big .search-input { height: 60px; font-size: 18px; }
.search-box.big svg { width: 26px; height: 26px; }
.suggest { display: flex; flex-wrap: wrap; gap: 10px; }
.suggest .btn { flex: 1 1 calc(50% - 10px); min-width: 140px; padding: 14px 12px; border-radius: 16px; }
.journeys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.journey {
  --c: var(--accent);
  display: flex; flex-direction: column; gap: 2px; text-align: right; padding: 12px 12px 12px 10px;
  border-radius: 14px; background: color-mix(in srgb, var(--c) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); border-right: 4px solid var(--c);
}
.journey b { font-size: 0.9rem; font-weight: 800; }
.journey small { font-size: 0.72rem; color: var(--ink-2); line-height: 1.6; }
.journey:active { transform: scale(0.98); }

/* —— صفحه‌ی بارگذاری —— */
#boot {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: linear-gradient(160deg, #2a76d2, #0e3a80); color: #fff; text-align: center; transition: opacity 0.45s;
}
#boot.done { opacity: 0; pointer-events: none; }
#boot .spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; animation: spin 0.9s linear infinite; }
#boot h2 { margin: 0; font-size: 1.5rem; }
.boot-err { max-width: 280px; line-height: 1.9; }
@keyframes spin { to { transform: rotate(360deg); } }


/* —— کارت اشتراک (پیش‌نمایش استوری) —— */
.sc { position: fixed; inset: 0; z-index: 96; display: grid; place-items: center; padding: 16px; background: rgba(8, 6, 16, 0.86); backdrop-filter: blur(8px); opacity: 0; transition: opacity 0.25s; direction: rtl; overflow-y: auto; }
.sc.in { opacity: 1; }
.sc-body { width: min(100%, 380px); display: grid; gap: 12px; justify-items: center; }
.sc-img { width: min(100%, calc((100dvh - 230px) * 9 / 16)); aspect-ratio: 9 / 16; border-radius: 22px; overflow: hidden; background: #140c18; border: 1px solid rgba(246, 199, 100, 0.35); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6); }
.sc-img img { width: 100%; height: 100%; display: block; }
.sc-img.loading { background: linear-gradient(110deg, #140c18 30%, #2a1c32 50%, #140c18 70%) 0 0 / 200% 100%; animation: sc-sh 1.2s linear infinite; }
@keyframes sc-sh { to { background-position: -200% 0; } }
.sc-status { margin: 0; min-height: 1.2em; color: #f4e3c2; font-size: 0.85rem; text-align: center; }
.sc-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sc-actions .primary { grid-column: 1 / -1; }
.sc-actions .btn { height: 46px; }
.sc-x { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; width: 42px; height: 42px; border-radius: 50%; color: #fff; font-size: 1.05rem; background: rgba(255, 255, 255, 0.14); z-index: 2; }

@media (min-width: 900px) {
  #appbar { padding-inline: 24px; }
  #sheet { border-radius: 24px; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }

.year-jump { background: var(--accent-soft); border-radius: 12px; padding-inline: 10px; margin-bottom: 4px; }

/* حساب کاربری و علاقه‌مندی */
.tab[hidden] { display: none; }
.tab.logged { color: var(--accent-ink); }
.account .acct-form { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.field { height: 48px; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 14px; padding: 0 14px; font-size: 16px; color: var(--ink); outline: none; -webkit-user-select: text; user-select: text; }
.field:focus { border-color: var(--accent); }
.field[hidden] { display: none; }
.form-err { color: #c0392b; font-size: 0.9rem; min-height: 1.2em; margin: 0; }
.hint.note { background: var(--accent-soft); color: var(--accent-ink); padding: 10px 12px; border-radius: 12px; }
.acct-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.acct-head small { display: block; color: var(--ink-3); direction: ltr; text-align: right; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; }
.fav-btn.on { color: #d6336c; border-color: #d6336c; }
.fav-btn.on svg { fill: currentColor; }

#appbar .icon-btn[hidden] { display: none; }
#btnAccount.logged { position: relative; }
#btnAccount.logged::after { content: ''; position: absolute; top: 7px; inset-inline-end: 7px; width: 9px; height: 9px; border-radius: 50%; background: #7ee2a8; border: 2px solid var(--appbar-2); }

#appbar { position: relative; z-index: 60; }

/* ═══════ کارت جزئیات (Maps-style) ═══════ */
body.card-full #fabs { opacity: 0; pointer-events: none; }
#card {
  position: fixed; z-index: 55; left: 50%; width: min(100%, 600px);
  bottom: calc(var(--tab-h) + var(--safe-b));
  height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface) var(--art) center bottom / 100% auto no-repeat; color: var(--ink);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -12px 40px rgba(8, 20, 24, 0.24), 0 -1px 0 var(--line);
  transform: translate(-50%, 104%);
  transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.25, 1), height 0.34s cubic-bezier(0.2, 0.9, 0.25, 1);
  visibility: hidden; will-change: transform, height;
}
#card.open { transform: translate(-50%, 0); visibility: visible; }
#card:not(.open) { transition: transform 0.3s ease, visibility 0s 0.3s; }
#card.dragging { transition: none; }
#card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--item-c, var(--accent)); opacity: 0.9; }

.card-head { flex: none; touch-action: pan-x; cursor: grab; padding-top: 4px; background: var(--surface); }
.card-grab { display: block; width: 100%; height: 22px; padding: 0; }
.card-grab i { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 7px auto 0; }
.card-top { display: flex; align-items: flex-start; gap: 10px; padding: 0 16px; }
.card-titles { flex: 1; min-width: 0; }
.card-thumb, .card-tile { width: 62px; height: 62px; border-radius: 16px; object-fit: cover; flex: none; background: var(--surface-2); border: 1px solid var(--line); margin-top: 2px; }
.card-tile { display: grid; place-items: center; font-size: 1.6rem; font-weight: 900; color: #fff; background: var(--item-c, var(--accent)); border: 0; }
.card-tile[hidden] { display: none; }
.card-stats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; padding: 12px 16px 2px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 7px 6px; text-align: center; min-width: 0; }
.stat span { display: block; font-size: 0.68rem; color: var(--ink-3); font-weight: 700; }
.stat b { display: block; font-size: 0.98rem; font-weight: 800; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.posbar { margin: 0 0 14px; }
.pos-t { font-size: 0.72rem; color: var(--ink-3); font-weight: 700; margin-bottom: 6px; }
.pos-track { position: relative; height: 22px; border-radius: 11px; background: linear-gradient(270deg, #e8c9a0 0 22%, #c9d8a8 22% 48%, #a8cfd8 48% 71%, #d4b0c8 71% 100%); opacity: 0.95; }
.pos-mark { position: absolute; top: -3px; bottom: -3px; min-width: 7px; border-radius: 6px; background: var(--ink); border: 2px solid var(--surface); }
.pos-l { display: flex; justify-content: space-between; font-size: 0.66rem; color: var(--ink-3); margin-top: 4px; }
.card-kind { display: flex; align-items: center; gap: 7px; font-size: 0.74rem; font-weight: 700; color: var(--ink-3); margin-bottom: 3px; }
.card-kind i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.card-title { margin: 0; font-size: 1.32rem; font-weight: 800; line-height: 1.45; letter-spacing: -0.2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#card[data-state="full"] .card-title { -webkit-line-clamp: 4; }
.card-date { margin-top: 2px; font-size: 0.88rem; color: var(--accent-ink); font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.approx-badge { font-size: 0.68rem; font-weight: 800; color: #9a6400; background: color-mix(in srgb, #e0a020 18%, var(--surface)); border: 1px solid color-mix(in srgb, #e0a020 55%, var(--line)); padding: 1px 8px; border-radius: 999px; }
:root[data-theme="dark"] .approx-badge { color: #f0c060; }
.card-ctls { display: flex; gap: 6px; flex: none; }
.card-ctl { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.card-ctl[hidden] { display: none; }
.card-ctl svg { width: 20px; height: 20px; }

.card-actions { flex: none; display: flex; gap: 8px; align-items: center; padding: 10px 14px calc(10px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(8, 20, 24, 0.06); }
.act { display: flex; align-items: center; justify-content: center; gap: 8px; flex: none; font-size: 0.86rem; font-weight: 800; color: var(--accent-ink); text-decoration: none; }
.act i { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line)); transition: transform 0.12s; }
.act i svg { width: 21px; height: 21px; }
.act:active i { transform: scale(0.92); }
.act.primary { flex: 1; height: 42px; border-radius: 13px; background: var(--accent); color: #fff; }
.act.primary i { width: auto; height: auto; background: none; border: 0; }
.act.primary i svg { width: 20px; height: 20px; }
.act.fav.on i { background: #d6336c; border-color: #d6336c; color: #fff; }
.act.fav.on i svg { fill: currentColor; }

.card-tabs { display: flex; margin: 10px 16px 0; padding: 3px; background: var(--surface-2); border-radius: 999px; border: 1px solid var(--line); }
.ctab { flex: 1; position: relative; padding: 7px 4px; border-radius: 999px; font-size: 0.84rem; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; justify-content: center; gap: 6px; }
.ctab em { font-style: normal; font-size: 0.68rem; font-weight: 800; background: var(--surface-2); color: var(--ink-2); padding: 0 7px; border-radius: 999px; line-height: 1.7; }
.page-tabs { margin: -2px 0 14px; padding: 0; }
.ctab.on { color: var(--accent-ink); background: var(--surface); box-shadow: 0 1px 5px rgba(8, 20, 24, 0.16); }

.card-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px calc(24px + var(--safe-b)); -webkit-user-select: text; user-select: text; touch-action: pan-y; }
#card[data-state="peek"] .card-body { overflow: hidden; touch-action: pan-x; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }

.item-img { margin: 0 0 12px; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.item-img img { display: block; width: 100%; max-height: 260px; object-fit: cover; object-position: center 20%; }
.item-img figcaption { padding: 5px 10px; font-size: 0.68rem; line-height: 1.7; color: var(--ink-3); }
.item-img figcaption a { color: inherit; text-decoration: underline dotted; }
.story p.lead { font-weight: 700; color: var(--ink); }
.narr { margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--line); }
.narr h3 { margin: 10px 0 6px; font-size: 0.82rem; font-weight: 800; color: var(--item-c, var(--accent)); letter-spacing: 0.02em; }
.narr p { color: var(--ink); }
.exact-note { margin: 6px 2px 0; font-size: 0.74rem; line-height: 1.8; color: var(--ink-3); }
.story p { margin: 0 0 10px; line-height: 2; font-size: 0.97rem; text-align: justify; }
.card-body .sec { margin: 18px 0 8px; font-size: 0.76rem; letter-spacing: 0.2px; }
.card-body .sec.first { margin-top: 4px; }
.card-body .dates { margin-bottom: 8px; }
.card-body .date-block { padding: 7px 11px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; min-width: 0; }
.fact span { display: block; font-size: 0.7rem; color: var(--ink-3); font-weight: 600; }
.fact b { display: block; font-size: 0.88rem; font-weight: 700; overflow-wrap: anywhere; }
.no-src { text-align: center; padding: 22px 8px; color: var(--ink-2); }
.no-src p { font-size: 0.84rem; line-height: 1.9; color: var(--ink-3); margin: 6px 0 0; }

/* پاپ‌اور حساب کاربری */
#acctPop {
  position: fixed; z-index: 70; left: 10px; top: calc(var(--appbar-h) + var(--safe-t) + 10px);
  width: min(calc(100vw - 20px), 360px);
  max-height: calc(100dvh - var(--appbar-h) - var(--safe-t) - var(--tab-h) - var(--safe-b) - 30px); overflow-y: auto;
  background: var(--surface); color: var(--ink); border-radius: 20px; padding: 14px 16px 16px;
  box-shadow: 0 16px 44px rgba(8, 20, 24, 0.32), 0 0 0 1px var(--line);
  transform-origin: 90px -8px; animation: popIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
#acctPop[hidden] { display: none; }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px) scale(0.96); } }

/* دسکتاپ: کارت = پنل کناری */
@media (min-width: 900px) {
  #card { left: 16px; right: auto; width: 410px; top: calc(var(--appbar-h) + var(--safe-t) + 14px); bottom: calc(var(--tab-h) + var(--safe-b) + 14px); height: auto !important; border-radius: 22px; transform: translateX(-120%); }
  #card.open { transform: none; }
  #card::before { border-radius: 22px 22px 0 0; }
  .card-grab { display: none; }
  .card-head { cursor: default; padding-top: 14px; }
  #card[data-state="peek"] .card-body { overflow-y: auto; -webkit-mask-image: none; mask-image: none; touch-action: pan-y; }
  body.card-full #fabs { opacity: 1; pointer-events: auto; }
}
@media (min-width: 900px) { body.has-card #fabs { left: 442px; } #fabs { transition: left 0.3s; } }

.card-body .dates { gap: 6px; }
.card-body .date-block { padding: 6px 11px; border-radius: 12px; }
.card-body .date-main { font-size: 0.98rem; margin: 0; }
.card-body .date-alt { flex-direction: row; flex-wrap: wrap; gap: 4px 10px; }
.card-body .kv { padding: 6px 2px; }

/* ——— مقایسهٔ زمانی ——— */
.list li.has-cmp { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.list li.has-cmp .list-item { border-bottom: 0; flex: 1; min-width: 0; }
.cmp-btn { flex: none; width: 38px; height: 38px; margin-inline-start: 2px; border-radius: 12px; display: grid; place-items: center; color: var(--ink-3); border: 1px solid var(--line); background: var(--surface-2); }
.cmp-btn svg { width: 20px; height: 20px; }
.cmp-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.cmp-tray { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; margin: 0 0 8px; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--line-strong); font-size: 0.8rem; }
.cmp-tray[hidden] { display: none; }
.cmp-title { font-weight: 800; color: var(--accent-ink); }
.cmp-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--surface); border: 2px solid #e8590c; max-width: 100%; }
.cmp-chip.c1 { border-color: #1c7ed6; }
.cmp-chip b { font-size: 0.7rem; color: #fff; background: #e8590c; border-radius: 999px; padding: 0 7px; line-height: 1.6; }
.cmp-chip.c1 b { background: #1c7ed6; }
.cmp-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; font-weight: 700; }
.cmp-chip button { width: 22px; height: 22px; display: grid; place-items: center; color: var(--ink-3); }
.cmp-chip button svg { width: 14px; height: 14px; }
.cmp-next { color: var(--ink-2); }
.cmp-hint svg { width: 16px; height: 16px; vertical-align: -3px; }

.mode-chip .chip-x.on { background: #fff; color: var(--accent-ink); }

/* ——— صفحهٔ مقایسه ——— */
.cmpx-heads { display: grid; grid-template-columns: 1fr 30px 1fr; align-items: center; gap: 4px; margin-bottom: 10px; }
.cmpx-vs { text-align: center; font-weight: 900; font-size: 0.8rem; color: var(--ink-3); }
.cmpx-av { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; font-weight: 900; color: #fff; background: #e8590c; margin: 0 auto 6px; }
.cmpx-who.c1 .cmpx-av { background: #1c7ed6; }
.cmpx-who em { font-style: normal; font-size: 0.74rem; color: var(--ink-2); font-weight: 700; }
.cmpx-table.vs th { width: 26%; }
.cmpx-table.vs td { text-align: center; font-weight: 700; }
.cmpx-table.vs td.c0 { color: #c2410c; }
.cmpx-table.vs td.c1 { color: #1864ab; }
.cmpx-table.vs tr.wide td { background: var(--surface-2); border-radius: 8px; }
.cmpx-who { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; text-align: center; border-radius: 18px; background: color-mix(in srgb, #e8590c 11%, var(--surface)); border: 1px solid color-mix(in srgb, #e8590c 30%, var(--line)); min-width: 0; }
.cmpx-who.c1 { background: color-mix(in srgb, #1c7ed6 11%, var(--surface)); border-color: color-mix(in srgb, #1c7ed6 30%, var(--line)); }
.cmpx-who b { font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
.cmpx-who small { color: var(--ink-3); font-size: 0.72rem; }
.cmpx-badge { position: absolute; top: -9px; right: 10px; min-width: 22px; padding: 0 7px; line-height: 20px; text-align: center; border-radius: 999px; color: #fff; font-weight: 800; font-size: 0.75rem; background: #e8590c; }
.cmpx-who.c1 .cmpx-badge { background: #1c7ed6; }
.cmpx-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 50%; margin: 0 auto 6px; }
.cmpx-rel { padding: 10px 12px; border-radius: 12px; font-weight: 700; font-size: 0.88rem; line-height: 1.8; background: var(--accent-soft); color: var(--accent-ink); }
.cmpx-rel.gap { background: var(--surface-2); color: var(--ink-2); border: 1px dashed var(--line-strong); }
.cmpx-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.cmpx-stat { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; }
.cmpx-stat b { font-size: 0.95rem; color: var(--accent-ink); }
.cmpx-stat span { font-size: 0.7rem; color: var(--ink-3); }
.cmpx-note { color: var(--ink-3); font-size: 0.78rem; line-height: 1.8; margin: 6px 0; }
.cmpx-svg { width: 100%; height: auto; display: block; }
.cmpx-svg .cmpx-t { font: 600 9.5px 'Vazirmatn', Tahoma, sans-serif; fill: var(--ink-2); }
.cmpx-svg .cmpx-t.b { font-weight: 800; fill: var(--ink); font-size: 10.5px; }
.cmpx-svg .cmpx-t.w { fill: #fff; font-weight: 800; font-size: 11px; }
.cmpx-svg .cmpx-t.sm { font-size: 8px; fill: var(--ink-3); }
.cmpx-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; table-layout: fixed; }
.cmpx-table th, .cmpx-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; overflow-wrap: anywhere; line-height: 1.7; }
.cmpx-table th { color: var(--ink-3); font-weight: 700; width: 22%; }
.cmpx-table thead th { text-align: center; color: #fff; }
.cmpx-table thead th.c0 { background: #e8590c; border-radius: 10px 10px 0 0; }
.cmpx-table thead th.c1 { background: #1c7ed6; border-radius: 10px 10px 0 0; }
.cmpx-list { margin: 0; padding: 0 18px 0 0; line-height: 1.9; font-size: 0.85rem; }
.cmpx-link { display: inline-block; margin-top: 4px; color: var(--accent-ink); font-weight: 700; font-size: 0.82rem; }

/* امروز در تاریخ */
.tih { margin-top: 18px; }
.tih-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.tih-row { width: 100%; display: flex; align-items: center; gap: 8px; text-align: start; padding: 10px 12px; border-radius: 12px; background: var(--card, rgba(127,127,127,.1)); }
.tih-row b { flex: 1; font-size: .95rem; }
.tih-row small { opacity: .65; white-space: nowrap; }
.tih-t { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: rgba(26,171,184,.18); color: #138a95; }
.tih-t.death { background: rgba(120,120,120,.2); color: inherit; }
.tih-t.event { background: rgba(201,162,39,.22); color: #8a6d12; }

.tih-dates { margin: -6px 0 10px; font-size: .82rem; opacity: .7; }
.tih-occ { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.tih-occ li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: rgba(127,127,127,.08); }
.tih-occ li.hol { background: rgba(192,57,43,.12); }
.tih-occ b { flex: 1; font-size: .92rem; }
.tih-occ small { opacity: .7; white-space: nowrap; font-size: .75rem; }
.tih-c { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: rgba(127,127,127,.2); white-space: nowrap; }
.tih-c.sh { background: rgba(26,171,184,.2); } .tih-c.fa { background: rgba(201,162,39,.25); } .tih-c.ah { background: rgba(45,138,90,.22); }
.tih-c.ce { background: rgba(127,79,158,.2); } .tih-c.zh { background: rgba(192,57,43,.2); } .tih-c.he { background: rgba(52,100,190,.2); }

/* ——— جستجو: پالت شناور ——— */
#scrim.dark { background: rgba(6, 26, 32, 0.62); backdrop-filter: blur(3px); }
#sheet.palette { top: calc(var(--appbar-h) + var(--safe-t) + 12px); bottom: auto; width: min(calc(100% - 24px), 560px); max-height: calc(100dvh - var(--appbar-h) - var(--safe-t) - var(--tab-h) - var(--safe-b) - 36px); border-radius: 22px; background-image: none; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); transform: translate(-50%, -14px) scale(0.98); opacity: 0; transition: transform 0.22s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.18s; overflow: hidden; }
#sheet.palette.open { transform: translate(-50%, 0) scale(1); opacity: 1; }
#sheet.palette:not(.open) { transition: transform 0.2s, opacity 0.15s, visibility 0s 0.2s; }
#sheet.palette #sheetHead { display: none; }
#sheet.palette #sheetBody { padding: 0; display: flex; flex-direction: column; }
.pal { display: flex; flex-direction: column; min-height: 0; }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--accent); flex: none; }
.pal-input svg { width: 22px; height: 22px; flex: none; }
.pal-input .search-input { height: 56px; font-size: 17px; font-weight: 700; flex: 1; border: 0; background: none; outline: none; color: var(--ink); }
.pal-x { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); flex: none; }
.pal-x svg { width: 16px; height: 16px; }
.pal .cmp-tray { margin: 8px 10px 0; flex: none; }
.pal-results { overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 16px; min-height: 0; }
.pal-h { font-size: 0.72rem; font-weight: 800; color: var(--ink-3); padding: 12px 8px 4px; }
.pal-best .list { background: var(--accent-soft); border-radius: 14px; padding: 2px 4px; }
.pal-best .list li { border-bottom: 0; }
.pal-recent { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 8px; }
.pal-recent .chip { background: var(--surface-2); color: var(--ink-2); border: 0; font-size: 0.8rem; padding: 5px 12px; }
.pal-input input::-webkit-search-cancel-button { display: none; }

/* مرز و سایهٔ مودال‌ها: از پس‌زمینهٔ سفید جدا بمانند */
#sheet, #card { border: 1px solid var(--line-strong); border-bottom: 0; box-shadow: 0 -12px 40px rgba(10, 36, 84, 0.34), 0 0 0 1px rgba(10, 36, 84, 0.06); }
#sheet.palette { border-bottom: 1px solid var(--line-strong); box-shadow: 0 24px 60px rgba(8, 24, 60, 0.5), 0 0 0 1px rgba(10, 36, 84, 0.1); }
#scrim { background: rgba(8, 22, 52, 0.5); }
#acctPop { border: 1px solid var(--line-strong); }

/* ——— مود: نقشه | تایم‌لاین | نمودارها ——— */
#appbar .sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
#modeSwitch { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); flex: none; }
.mode-btn { font-size: 0.72rem; font-weight: 700; padding: 6px 9px; border-radius: 999px; color: inherit; white-space: nowrap; }
.mode-btn.on { background: #fff; color: #0e3b5a; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }
#tabbar .tab[hidden] { display: none; }
:root[data-skin="tile"] #modeSwitch { background: var(--accent-soft); }
:root[data-skin="tile"] .mode-btn.on { background: var(--accent); color: #fff; }
:root[data-skin="astro"] #modeSwitch { background: rgba(127, 178, 255, 0.16); border: 1px solid rgba(127, 178, 255, 0.3); }
:root[data-skin="astro"] .mode-btn.on { background: #f0d68a; color: #0a1a38; }
select.field.sel { width: 100%; }
@media (max-width: 380px) { .mode-btn { padding: 6px 6px; font-size: 0.68rem; } }
