:root {
  --ink: #241f2e;
  --parchment: #f7f0e4;
  --parchment-deep: #efe4d0;
  --indigo: #2b2760;
  --indigo-deep: #1c1840;
  --terracotta: #c76a3c;
  --saffron: #d99a2b;
  --gold: #b98a3a;
  --card: #fffaf0;
  --muted: #6b6070;
  --line: #dccdb4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(217,154,43,0.10), transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(199,106,60,0.10), transparent 42%),
    var(--parchment);
  color: var(--ink);
  line-height: 2;
  min-height: 100vh;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }

/* ---------- Header ---------- */
.app-header {
  margin: 16px -16px 24px;
  padding: 28px 24px 30px;
  background:
    linear-gradient(135deg, var(--indigo-deep), var(--indigo) 55%, #3a2f66);
  color: #f8f2e6;
  border-radius: 0 0 26px 26px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(28,24,64,0.35);
}
.app-header::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(217,154,43,0.06) 0 2px, transparent 2px 16px),
    repeating-linear-gradient(-45deg, rgba(217,154,43,0.06) 0 2px, transparent 2px 16px);
  pointer-events: none;
}
.header-topbar {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  font-size: 0.8rem; position: relative; z-index: 1;
}
.date-chip, .streak-chip {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(217,154,43,0.4);
  padding: 4px 12px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.app-title {
  font-size: clamp(1.6rem, 5vw, 2.7rem);
  font-weight: 900;
  text-align: center;
  margin-top: 18px;
  letter-spacing: -0.5px;
  color: #fdf6e8;
  position: relative; z-index: 1;
  animation: fadeUp 0.7s ease both;
}
.app-subtitle {
  text-align: center;
  color: var(--saffron);
  font-weight: 300;
  font-size: clamp(0.9rem, 2.5vw, 1.15rem);
  margin-top: 4px;
  position: relative; z-index: 1;
  animation: fadeUp 0.7s ease 0.1s both;
}
.quote-banner {
  margin: 18px auto 0;
  max-width: 680px;
  text-align: center;
  font-size: 0.95rem;
  font-style: italic;
  color: #ece0cd;
  background: rgba(0,0,0,0.15);
  border-radius: 14px;
  padding: 10px 20px;
  position: relative; z-index: 1;
  border-inline-start: 3px solid var(--saffron);
  animation: fadeUp 0.7s ease 0.2s both;
}
.quote-mark { color: var(--saffron); font-size: 1.4rem; font-weight: 900; margin-inline-end: 6px; }

/* ---------- Select head ---------- */
.select-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 18px;
}
.section-heading {
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 800; color: var(--indigo);
  position: relative; padding-inline-start: 16px;
}
.section-heading::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 70%;
  background: linear-gradient(var(--terracotta), var(--saffron));
  border-radius: 4px;
}
.random-btn {
  background: linear-gradient(135deg, var(--terracotta), var(--saffron));
  color: #fff; border: none; cursor: pointer;
  padding: 10px 18px; border-radius: 12px;
  font-family: inherit; font-weight: 700; font-size: 0.95rem;
  box-shadow: 0 6px 18px rgba(199,106,60,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.random-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(199,106,60,0.45); }
.random-btn:active { transform: translateY(0); }

/* ---------- Topic grid ---------- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 34px;
}
.topic-card {
  display: flex; flex-direction: column; gap: 4px;
  text-align: start;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 16px;
  cursor: pointer;
  font-family: inherit;
  position: relative;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  box-shadow: 0 3px 10px rgba(36,31,46,0.05);
  animation: fadeUp 0.5s ease both;
}
.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 26px rgba(36,31,46,0.14);
  border-color: var(--saffron);
}
.topic-card.selected {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(199,106,60,0.25), 0 12px 26px rgba(199,106,60,0.22);
  background: linear-gradient(180deg, #fff, #fdf1e2);
}
.topic-num {
  font-size: 1.7rem; font-weight: 900; color: var(--terracotta);
  line-height: 1;
}
.topic-emoji { font-size: 1.3rem; }
.topic-disc { font-size: 0.72rem; color: var(--saffron); font-weight: 700; }
.topic-title { font-size: 0.9rem; font-weight: 700; color: var(--ink); }

/* ---------- Welcome ---------- */
.welcome {
  text-align: center; padding: 44px 20px; color: var(--muted);
  background: var(--card); border: 2px dashed var(--line);
  border-radius: 20px;
}
.welcome-icon { font-size: 3rem; margin-bottom: 12px; }
.welcome p { max-width: 460px; margin: 0 auto; font-size: 1.05rem; }

/* ---------- Loader ---------- */
.loader-wrap { text-align: center; padding: 50px 20px; }
.astrolabe { position: relative; width: 90px; height: 90px; margin: 0 auto 18px; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.r1 { border-top-color: var(--terracotta); animation: spin 1.4s linear infinite; }
.r2 { inset: 12px; border-right-color: var(--saffron); animation: spin 1.9s linear infinite reverse; }
.r3 { inset: 24px; border-bottom-color: var(--indigo); animation: spin 2.4s linear infinite; }
.astrolabe-core {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--gold);
  animation: pulse 1.6s ease-in-out infinite;
}
.loader-text { color: var(--indigo); font-weight: 700; }

/* ---------- Error ---------- */
.error-note {
  background: #fff3e6; border: 1px solid var(--terracotta);
  color: #8a4020; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px;
  font-size: 0.9rem;
}

/* ---------- Dashboard ---------- */
.dashboard {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(36,31,46,0.10);
  animation: fadeUp 0.5s ease both;
}
.dash-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 20px 22px;
  background: linear-gradient(135deg, var(--indigo), #3a2f66);
  color: #fdf6e8;
}
.dash-emoji { font-size: 2.4rem; }
.dash-disc { font-size: 0.8rem; color: var(--saffron); font-weight: 700; }
.dash-title { font-size: clamp(1.2rem, 4vw, 1.7rem); font-weight: 900; }
.copy-btn {
  margin-inline-start: auto;
  background: rgba(255,255,255,0.14); color: #fdf6e8;
  border: 1px solid rgba(217,154,43,0.5);
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 0.85rem;
  transition: background 0.15s;
}
.copy-btn:hover { background: rgba(255,255,255,0.24); }

.tabs {
  display: flex; gap: 6px; padding: 14px 16px 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line);
}
.tab {
  white-space: nowrap;
  background: transparent; border: none; cursor: pointer;
  padding: 9px 14px; border-radius: 12px 12px 0 0;
  font-family: inherit; font-weight: 700; font-size: 0.88rem;
  color: var(--muted); transition: all 0.15s;
}
.tab:hover { color: var(--terracotta); background: var(--parchment-deep); }
.tab.active { color: #fff; background: linear-gradient(135deg, var(--terracotta), var(--saffron)); }

.tab-body { padding: 26px 24px 30px; animation: fadeIn 0.4s ease both; min-height: 160px; }
.prose { font-size: 1.08rem; line-height: 2.2; color: var(--ink); text-align: justify; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-inline-start: 26px; }
.timeline::before {
  content: ''; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px;
  width: 2px; background: linear-gradient(var(--terracotta), var(--saffron));
}
.timeline-item { position: relative; margin-bottom: 22px; }
.timeline-dot {
  position: absolute; inset-inline-start: -26px; top: 6px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--terracotta); border: 3px solid var(--card);
  box-shadow: 0 0 0 2px var(--saffron);
}
.timeline-year { font-weight: 900; color: var(--indigo); font-size: 1rem; }
.timeline-text { color: var(--ink); font-size: 0.98rem; line-height: 1.9; }

/* ---------- Media ---------- */
.media-heading { color: var(--indigo); font-weight: 800; margin: 8px 0 12px; font-size: 1.1rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 22px; }
.media-card {
  background: var(--parchment); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
  border-inline-start: 4px solid var(--saffron);
}
.media-card.film { border-inline-start-color: var(--indigo); }
.media-title { font-weight: 800; color: var(--ink); font-size: 1rem; }
.media-meta { font-size: 0.82rem; color: var(--terracotta); font-weight: 700; margin: 2px 0 6px; }
.media-why { font-size: 0.88rem; color: var(--muted); line-height: 1.8; }

/* ---------- Footer ---------- */
.app-footer {
  text-align: center; margin-top: 40px; padding: 24px;
  color: var(--muted);
}
.app-footer p { margin: 2px 0; }
.footer-copy { font-size: 0.8rem; }
.remix-link {
  display: inline-block; margin-top: 8px;
  color: var(--terracotta); font-weight: 700; text-decoration: none;
  border-bottom: 2px dotted var(--terracotta);
}
.remix-link:hover { color: var(--indigo); border-color: var(--indigo); }

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.6; } }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .quote-banner { font-size: 0.85rem; }
}
@media (max-width: 400px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .topic-num { font-size: 1.4rem; }
}