@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0e1512;
  --bg-soft: #13201b;
  --surface: #18261f;
  --surface-2: #20332b;
  --text: #e8f0ec;
  --muted: #8ba396;
  --line: rgba(212, 175, 55, 0.14);
  --primary: #2d6a4f;
  --primary-soft: rgba(45, 106, 79, 0.22);
  --accent: #d4af37;
  --accent-soft: rgba(212, 175, 55, 0.16);
  --danger: #c45c5c;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --radius: 22px;
  --tabbar: 72px;
  --topbar: 64px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-soft: #ece7dc;
  --surface: #ffffff;
  --surface-2: #f7f3ea;
  --text: #1c241f;
  --muted: #5f7268;
  --line: rgba(27, 67, 50, 0.1);
  --primary: #1b4332;
  --primary-soft: rgba(27, 67, 50, 0.1);
  --accent: #a57c12;
  --accent-soft: rgba(165, 124, 18, 0.12);
  --shadow: 0 12px 30px rgba(28, 36, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  background:
    radial-gradient(circle at 10% -10%, rgba(212, 175, 55, 0.08), transparent 32%),
    radial-gradient(circle at 100% 0%, rgba(45, 106, 79, 0.16), transparent 28%),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font-family: inherit;
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar) + 88px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  height: var(--topbar);
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.tg-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 168px;
  height: 36px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, #2AABEE 16%, var(--surface));
  border: 1px solid color-mix(in srgb, #2AABEE 38%, var(--line));
  color: #2AABEE;
  text-decoration: none;
  line-height: 1.15;
}

.tg-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tg-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 420px) {
  .tg-link {
    width: 36px;
    max-width: 36px;
    padding: 0;
    justify-content: center;
  }

  .tg-link span {
    display: none;
  }
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: contain;
  object-position: center;
  background: var(--surface);
  border: 1px solid var(--line);
}

.topbar-actions,
.hero-meta,
.section-head,
.time-row,
.player-toolbar,
.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  justify-content: flex-end;
  min-width: 0;
}

.search-slot {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 520px;
}

.top-search {
  position: relative;
  display: flex;
  align-items: center;
}

.top-search svg {
  position: absolute;
  right: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.top-search input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 0 38px 0 12px;
  outline: none;
}

.top-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 360px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 30;
  padding: 6px;
}

.search-suggest a,
.search-suggest .suggest-empty {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
}

.search-suggest a:hover,
.search-suggest a:focus {
  background: var(--surface-2);
}

.search-suggest small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.search-suggest .suggest-head {
  padding: 8px 12px 4px;
  color: var(--accent);
  font-size: 0.75rem;
}

.icon-btn,
.chip-btn,
.control-btn,
.search-form button {
  border: 0;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

html[data-theme="dark"] .icon-sun,
html[data-theme="light"] .icon-moon {
  display: none;
}

.page-content {
  padding: 8px 16px 24px;
}

.portrait-hero {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 8px 8px 22px;
  text-align: center;
}

.portrait {
  display: block;
  width: min(78vw, 280px);
  height: auto;
  background: transparent;
  object-fit: contain;
}

.portrait-name {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.7;
}

.lang-switch {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.lang-btn {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow);
}

.lang-btn:hover,
.lang-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--accent);
}

.hero,
.page-head,
.speech-card,
.category-card,
.continue-card,
.empty-state,
.speech-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero,
.page-head,
.empty-state,
.speech-body {
  padding: 22px;
}

.hero h1,
.page-head h1,
.player-heading h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  line-height: 1.4;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.82rem;
}

.lede,
.page-head p,
.empty-state p,
.speech-card p,
.muted {
  color: var(--muted);
}

.chip,
.chip-btn,
.search-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

#offline-chip.ready {
  background: var(--primary-soft);
  color: #95d5b2;
}

html[data-theme="light"] #offline-chip.ready {
  color: var(--primary);
}

.text-link {
  color: var(--accent);
  font-weight: 500;
}

.section {
  margin-top: 22px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.section-head a,
.result-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.category-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.category-row::-webkit-scrollbar {
  display: none;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.home-cats {
  grid-template-columns: 1fr;
}

.category-card {
  min-width: 0;
  overflow: hidden;
}

.category-card.compact {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 0;
}

.category-card.compact .cat-visual {
  height: 58px;
  width: 58px;
  margin: 8px;
  border-radius: 14px;
  overflow: hidden;
}

.category-card.compact img {
  object-fit: contain;
  filter: none;
  background: transparent;
}

.category-card.compact div {
  padding: 10px 12px 10px 0;
  min-width: 0;
}

.category-card.compact strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0 0 4px;
}

.category-card.compact span {
  color: var(--accent);
  font-weight: 600;
}

.category-card img,
.speech-card img,
.continue-card img,
.page-cover,
.player-cover {
  object-fit: cover;
  background: var(--surface-2);
}

.cat-visual {
  display: block;
  height: 104px;
  overflow: hidden;
  background: linear-gradient(160deg, #4fa37a, #245c45);
}

.category-card.large .cat-visual {
  height: 128px;
}

.category-card img {
  width: 100%;
  height: 100%;
  filter: brightness(1.18) saturate(1.08);
}

.category-card.tone-gold .cat-visual {
  background: linear-gradient(160deg, #d4af37, #3f6f4c);
}

.category-card.tone-sage .cat-visual {
  background: linear-gradient(160deg, #7eb89a, #2f5d4a);
}

.category-card.tone-bronze .cat-visual {
  background: linear-gradient(160deg, #d0b15a, #4a6b3f);
}

.speech-card.clip-result .speech-card-body h3 {
  color: var(--accent);
}

.speech-card-body {
  padding: 12px;
}

.cat-badge {
  display: inline-block;
  margin: 0 0 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 700;
}

.topic-stack {
  display: grid;
  gap: 10px;
}

.fold-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.fold-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: right;
}

.fold-plus {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.fold-toggle span {
  display: block;
  min-width: 0;
}

.fold-toggle strong,
.fold-toggle small {
  display: block;
}

.fold-toggle strong {
  font-size: 0.98rem;
}

.fold-toggle small {
  color: var(--muted);
  margin-top: 3px;
  font-size: 0.82rem;
}

.fold-body {
  display: none;
  padding: 0 10px 10px;
}

.fold-box.open .fold-body {
  display: block;
}

.speech-card.nested {
  box-shadow: none;
}

.group-head {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.group-head h2,
.group-head h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.group-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

.category-card span,
.speech-card span {
  color: var(--muted);
  font-size: 0.8rem;
}

.speech-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.speech-card,
.continue-card {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

.thumb .offline-badge {
  position: absolute;
  right: 4px;
  left: 4px;
  bottom: 4px;
  z-index: 1;
  display: block;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary, #1f6b4a) 92%, #000);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
  padding: 2px 4px;
  line-height: 1.35;
  letter-spacing: 0;
}

.thumb .offline-badge[hidden] {
  display: none !important;
}

.thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 16px;
  overflow: hidden;
  background: transparent;
  flex-shrink: 0;
}

.thumb img,
.queue-item .thumb img,
.continue-card .thumb img {
  width: 86%;
  height: 86%;
  margin: 7%;
  object-fit: contain;
  object-position: center;
  opacity: 1;
}

.queue-item .thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
}

.mini-player img {
  opacity: 1;
}

.speech-card-body h3,
.continue-card strong,
.category-card strong {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.play-inline {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
}

.play-inline svg {
  width: 18px;
  height: 18px;
}

.continue-card {
  padding: 12px;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
}

.search-form input,
.speed-field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 14px;
  min-height: 46px;
  padding: 0 12px;
}

.category-hero {
  display: grid;
  gap: 16px;
}

.page-cover {
  width: 100%;
  height: 170px;
  border-radius: 18px;
  filter: brightness(1.16) saturate(1.08);
}

.empty-state {
  text-align: center;
}

.tabbar {
  position: fixed;
  right: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
  width: min(760px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--tabbar);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.tabbar svg {
  width: 22px;
  height: 22px;
}

.tabbar a.active {
  color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + 96px);
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  z-index: 40;
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  .hero h1 {
    font-size: 2rem;
  }

  .category-grid,
  .home-cats {
    grid-template-columns: 1fr 1fr;
  }
}
