:root {
  --bg: #07111f;
  --panel: #0f172a;
  --panel-2: #101c31;
  --line: rgba(148, 163, 184, 0.22);
  --text: #e8edf5;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-text: #93c5fd;
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.16);
}

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

html, body {
  min-height: 100%;
  background:
    radial-gradient(ellipse at 85% -5%, rgba(251, 191, 36, 0.07) 0%, transparent 42%),
    radial-gradient(ellipse at 50% 0%, #15233a 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Vazirmatn", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; min-height: 100dvh; }
body.t-reading { overflow: hidden; }

.t-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body.t-reading .t-wrap {
  height: 100vh;
  height: 100dvh;
  padding-bottom: 10px;
}

/* ---- سرصفحه ---- */
.t-mast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.t-mast h1 { font-size: clamp(1.25rem, 5vw, 1.6rem); font-weight: 800; }
.t-mast p { color: var(--muted); font-size: 0.76rem; margin-top: 3px; line-height: 1.8; }
.t-moon {
  font-size: 1.9rem;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.55);
  line-height: 1;
}
.t-moon--sm { font-size: 1.3rem; }

/* ---- فیلتر ---- */
.t-filters { display: flex; gap: 6px; }
.t-filters button {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.t-filters button:hover { color: var(--text); border-color: var(--accent); }
.t-filters button.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- کارت قصه‌ها ---- */
.t-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
@media (max-width: 560px) { .t-grid { grid-template-columns: 1fr; } }

.t-card {
  display: flex;
  gap: 10px;
  align-items: stretch;
  text-align: right;
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.t-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.t-card--fa:hover { border-color: var(--gold); }
.t-card[hidden] { display: none; }

.t-glyph {
  flex: 0 0 44px;
  align-self: stretch;
  min-height: 52px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(150deg, #1d4ed8, #172554);
}
.t-card--fa .t-glyph { background: linear-gradient(150deg, #b45309, #1c1917); }
.t-card:nth-child(3n) .t-glyph { background: linear-gradient(150deg, #155e75, #083344); }
.t-card:nth-child(3n + 1) .t-glyph { background: linear-gradient(150deg, #5b21b6, #2e1065); }

.t-card-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.t-card-title { font-size: 0.95rem; font-weight: 800; }
.t-card-tag { color: var(--muted); font-size: 0.68rem; }
.t-card-meta {
  margin-top: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.t-chip {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent-text);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 99px;
  padding: 1px 9px;
}
.t-chip--gold { color: var(--gold); background: var(--gold-soft); border-color: rgba(251, 191, 36, 0.35); }
.t-chip--resume { color: #34d399; background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.35); }

.t-lib-note {
  background: rgba(251, 113, 133, 0.1);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #fda4af;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.78rem;
  line-height: 1.9;
}
.t-lib-foot { color: var(--muted); font-size: 0.7rem; line-height: 2; text-align: center; padding-top: 4px; }

/* ---- پخش‌کننده ---- */
.t-player {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  flex: 1;
}
body.t-reading .t-player { min-height: 0; }

.t-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.t-head-mid { flex: 1; min-width: 0; }
.t-head h2 {
  font-size: 1.08rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-tag { color: var(--muted); font-size: 0.7rem; }

.t-back, .t-btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.t-back:hover, .t-btn:hover { color: var(--text); border-color: var(--accent); }
.t-btn--main {
  min-width: 64px;
  font-size: 1.15rem;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  padding: 9px 18px;
}
.t-btn--main:hover { color: #fff; filter: brightness(1.12); }
.t-btn--ghost { font-size: 0.74rem; padding: 6px 11px; }

/* ---- قفسهٔ خواندن ---- */
.t-reader {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.4));
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  line-height: 2.15;
  font-size: 1.02rem;
  scroll-behavior: smooth;
}
.t-reader[dir="ltr"] { text-align: left; font-size: 1.05rem; }
.t-reader .t-para { transition: opacity 0.2s; }
.t-reader .t-para.dim { opacity: 0.5; }
.t-reader .t-sent { border-radius: 6px; padding: 1px 3px; transition: background 0.2s; }
.t-reader .t-sent.now {
  background: var(--gold-soft);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35);
  color: #fde68a;
}
.t-reader .t-sent:hover { background: rgba(59, 130, 246, 0.14); cursor: pointer; }

/* ---- هشدار صدا ---- */
.t-note {
  background: rgba(251, 191, 36, 0.09);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--gold);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.75rem;
  line-height: 1.9;
}

/* ---- پنل کنترل ---- */
.t-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px 12px;
}

.t-bar {
  height: 7px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.15);
  overflow: hidden;
}
.t-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), #f59e0b);
  transition: width 0.25s;
}
.t-progress-text {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 5px;
}

.t-transport { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }

.t-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}
@media (max-width: 560px) { .t-settings { grid-template-columns: 1fr; } }
.t-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.72rem; color: var(--muted); }
.t-field span { display: flex; justify-content: space-between; align-items: center; }
.t-field b { color: var(--accent-text); font-weight: 800; }
.t-field select {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  max-width: 100%;
}
.t-field--range { justify-content: center; }
.t-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 22px;
}
.t-settings .t-btn--ghost { align-self: end; justify-self: start; }

.t-sleep {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}
.t-sleep-label { font-size: 0.72rem; color: var(--muted); font-weight: 700; margin-inline-end: 2px; }
.t-sleep button {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.t-sleep button:hover { color: var(--text); border-color: var(--gold); }
.t-sleep button.active { color: #1c1917; background: var(--gold); border-color: var(--gold); }
.t-sleep-val { font-size: 0.72rem; color: var(--gold); font-weight: 700; }

.t-hint { color: var(--muted); font-size: 0.66rem; text-align: center; line-height: 1.9; }
.t-status { color: var(--accent-text); font-size: 0.72rem; text-align: center; min-height: 1.2em; }
