:root {
  --bg: #f2efe9;
  --card: #ffffff;
  --ink: #232323;
  --muted: #7b7b75;
  --line: #e7e1d6;
  --acc: #ff4e00;
  --acc-deep: #d93f00;
  --ok: #2f8f57;
  --err: #c0392b;
  --shadow: 0 6px 20px rgba(70, 40, 10, .1);
  --radius: 18px;
  --hero: #140f0b;
  --pattern: repeating-linear-gradient(120deg, rgba(255, 78, 0, .045) 0 2px, transparent 2px 24px);
  --hero-pattern: repeating-linear-gradient(120deg, rgba(255, 140, 60, .07) 0 2px, transparent 2px 26px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130e;
    --card: #1f1a13;
    --ink: #ece5d8;
    --muted: #97907f;
    --line: #2d271c;
    --acc: #ff6a1f;
    --acc-deep: #ff8c4a;
    --shadow: 0 8px 26px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-pattern {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--pattern);
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; flex: none; }
.logo {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--acc), #ff9d00);
  color: #fff; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(255, 78, 0, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 18px; letter-spacing: .2px; }
.brand-text small { color: var(--muted); }
.main-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--muted);
  font-weight: 600; transition: color .15s ease, background .15s ease;
}
.nav-link:hover { color: var(--acc); background: color-mix(in srgb, var(--acc) 10%, transparent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease, color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-outline { border-color: var(--acc); color: var(--acc); background: transparent; }
.btn-outline:hover { background: var(--acc); color: #fff; }
.btn-primary { background: var(--acc); color: #fff; border-color: var(--acc); box-shadow: 0 6px 16px rgba(255, 78, 0, .3); }
.btn-primary:hover { background: var(--acc-deep); }
.chat-btn { flex: none; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--hero);
  background-image:
    radial-gradient(60% 120% at 12% 0%, rgba(255, 78, 0, .32) 0%, transparent 55%),
    radial-gradient(50% 100% at 95% 100%, rgba(255, 157, 0, .22) 0%, transparent 55%);
  color: #fff;
}
.hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: var(--hero-pattern); }
.hero-inner {
  position: relative; display: grid; grid-template-columns: 1.45fr 1fr; gap: 48px;
  align-items: center; padding: 64px 20px 72px;
}
.hero-copy h1 {
  margin: 0 0 14px; font-size: clamp(30px, 5.4vw, 52px); font-weight: 800; line-height: 1.08;
  letter-spacing: -.5px;
}
.hero-subtitle { margin: 0 0 22px; color: rgba(255, 255, 255, .72); font-size: 18px; max-width: 480px; }
.search-form { max-width: 520px; }
.search-label {
  display: block; font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--acc); margin-bottom: 8px;
}
.search-row { display: flex; gap: 10px; }
.search-row input {
  flex: 1; min-width: 0; padding: 13px 18px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .08); color: #fff; font: inherit;
  outline: none; transition: border-color .15s ease, background .15s ease;
}
.search-row input::placeholder { color: rgba(255, 255, 255, .45); }
.search-row input:focus { border-color: var(--acc); background: rgba(255, 255, 255, .12); }
.hero-badge { margin: 16px 0 0; font-size: 13px; color: rgba(255, 255, 255, .5); }
.hero-card {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 22px; padding: 28px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
}
.hero-card h2 { margin: 0 0 10px; font-size: 24px; color: var(--acc); }
.hero-card p { margin: 0 0 16px; color: rgba(255, 255, 255, .72); font-size: 15px; }
.hero-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.hero-list li { color: rgba(255, 255, 255, .85); font-size: 15px; }
.hero-list li::before { content: "✔"; color: #ff9d00; font-weight: 800; margin-right: 8px; }

/* ---------- sections ---------- */
.section { padding: 52px 0 8px; }
.section-title {
  margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.3px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::before { content: ""; width: 12px; height: 26px; border-radius: 6px; background: linear-gradient(180deg, var(--acc), #ff9d00); flex: none; }
.section-lead { margin: 0 0 22px; color: var(--muted); }

/* ---------- featured ---------- */
.cards-grid { display: grid; gap: 16px; }
.cards-grid--exp { grid-template-columns: repeat(4, 1fr); }
.card--exp {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
}
.card--exp:hover { transform: translateY(-5px); box-shadow: 0 16px 34px rgba(50, 30, 5, .18); }
.media { position: relative; aspect-ratio: 4/3; overflow: hidden; background-size: cover; background-position: center; }
.media-emoji {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 46px; color: rgba(255, 255, 255, .85); filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .3));
}
.media-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .68), transparent 62%); }
.media-caption { position: absolute; left: 14px; right: 14px; bottom: 12px; color: #fff; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .94); color: #d43f00; font-size: 12px; font-weight: 800;
  letter-spacing: .4px; margin-bottom: 8px;
}
.media-caption h3 { margin: 0; font-size: 17px; line-height: 1.25; text-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.card--exp .card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-date { font-size: 13px; color: var(--acc-deep); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.card-desc { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.card-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save {
  cursor: pointer; background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; flex: none;
  transition: color .15s ease, border-color .15s ease;
}
.save:hover { color: var(--acc); border-color: var(--acc); }
.save.on { color: var(--acc); border-color: var(--acc); }

/* ---------- category cards ---------- */
.cards-grid--cats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.cat-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; color: var(--ink); font: inherit;
  box-shadow: var(--shadow); transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.cat-card:hover { transform: translateY(-3px); border-color: var(--acc); box-shadow: 0 12px 26px rgba(50, 30, 5, .14); }
.cat-emoji { font-size: 30px; margin-bottom: 8px; }
.cat-name { font-weight: 800; font-size: 16px; }
.cat-count { color: var(--muted); font-size: 13px; }
.cat-go { align-self: flex-end; color: var(--acc); font-weight: 800; font-size: 14px; margin-top: 4px; }
.cat-card.on { border-color: var(--acc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc) 30%, transparent); }

/* ---------- afisha toolbar + grid ---------- */
.toolbar {
  position: sticky; top: 72px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--bg); padding: 12px 0; margin: 8px 0 18px; border-bottom: 1px solid var(--line);
}
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.when, select, input, button { font: inherit; }
.when {
  cursor: pointer; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: transparent; transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.when:hover { color: var(--ink); border-color: var(--acc); }
.when.active { background: var(--acc); color: #fff; border-color: var(--acc); }
select {
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.meta { color: var(--muted); font-size: 14px; }
.meta.hidden { display: none; }
#refresh {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--acc); font-size: 20px; cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
#refresh:hover { border-color: var(--acc); }
#refresh:disabled { opacity: .5; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin: 14px 0 40px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .14s ease, box-shadow .14s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(50, 30, 5, .15); }
.card-img {
  position: relative; height: 140px; background-size: cover; background-position: center;
  display: grid; place-items: center; color: rgba(255, 255, 255, .9); font-size: 40px;
}
.card-img .poster, .media .poster {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-cat {
  align-self: flex-start; font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--acc-deep); border: 1px solid color-mix(in srgb, var(--acc-deep) 55%, transparent);
  border-radius: 999px; padding: 2px 10px;
}
.card-title { font-size: 17px; font-weight: 700; margin: 0; line-height: 1.3; }
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--acc); }
.card.undated .card-date { color: var(--muted); }

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

/* ---------- sources ---------- */
.section--sources { padding-bottom: 40px; }
.section--sources details summary { list-style: none; cursor: pointer; }
.section--sources details summary::-webkit-details-marker { display: none; }
.section--sources summary .section-title::after { content: " +"; color: var(--acc); }
.section--sources details[open] summary .section-title::after { content: " −"; color: var(--acc); }
.hint { color: var(--muted); font-size: 14px; max-width: 720px; margin: 12px 0; }
.source-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.source-list li { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--err); }
.src-name { flex: 1; }
.src-count { color: var(--muted); }
.src-err { color: var(--err); font-size: 12px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 6, 2, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card {
  position: relative; background: var(--card); border-radius: var(--radius); max-width: 560px; width: 100%;
  max-height: min(82vh, 720px); overflow: auto; padding: 26px; box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.modal-card h3 { margin: 4px 0 12px; font-size: 22px; }
.modal-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.modal-card img { width: 100%; border-radius: 12px; margin-bottom: 12px; }
.modal-desc { white-space: pre-wrap; }
.modal-desc .none { color: var(--muted); font-style: italic; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.btn.ghost { color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- footer ---------- */
.site-footer { margin-top: auto; background: #140f0b; color: rgba(255, 255, 255, .72); }
.footer-inner { display: grid; grid-template-columns: 1.3fr 2fr; gap: 32px; padding: 48px 20px 52px; }
.footer-brand { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.footer-brand p { margin: 0; max-width: 300px; font-size: 15px; }
.footer-columns { display: flex; gap: 44px; flex-wrap: wrap; }
.footer-columns > div { display: flex; flex-direction: column; gap: 8px; }
.footer-columns h4 { margin: 0 0 6px; color: var(--acc); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.footer-columns a { color: rgba(255, 255, 255, .62); text-decoration: none; font-size: 14px; }
.footer-columns a:hover { color: #fff; }
.footer-columns a.on { color: #ff9d00; }

/* ---------- animations ---------- */
.cards-grid .card--exp, .cards-grid .cat-card { animation: cardIn .4s ease backwards; animation-delay: calc(min(var(--i, 0), 11) * 45ms); }
.grid .card { animation: cardIn .4s ease backwards; animation-delay: calc(min(var(--i, 0), 11) * 45ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal { animation: fadeIn .18s ease-out; }
.modal-card { animation: popIn .22s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
#refresh.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; padding: 48px 20px 56px; }
  .cards-grid--exp { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .toolbar { position: static; }
  .main-nav { display: none; }
  .search-row { flex-direction: column; }
  .search-row .btn { width: 100%; }
  .hero-card { padding: 22px; }
  .cards-grid--exp { grid-template-columns: 1fr; }
  .cards-grid--cats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; padding: 36px 20px 40px; }
  .footer-columns { gap: 24px; }
  .brand-text small { display: none; }
}