/* =========================================================================
   Медитации — тёплая спокойная тема (рассветные тона, как «Симург»)
   ========================================================================= */

:root {
  --bg-top: #f6ecdf;      /* тёплый кремовый */
  --bg-bottom: #efd9c6;   /* песочно-персиковый */
  --ink: #3a2f28;         /* тёмно-кофейный текст */
  --ink-soft: #8a7663;    /* приглушённый */
  --card: rgba(255, 251, 246, 0.72);
  --card-active: #ffffff;
  --accent: #c8794f;      /* терракота */
  --accent-deep: #a85c38;
  --chip: rgba(255, 255, 255, 0.55);
  --chip-active-bg: #3a2f28;
  --chip-active-ink: #f6ecdf;
  --shadow: 0 8px 30px rgba(120, 80, 50, 0.14);
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% 0%, #fbf4ea 0%, var(--bg-top) 42%, var(--bg-bottom) 100%)
    fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 20px calc(104px + var(--safe-bottom));
}

/* Экраны */
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }

/* ── Шапка ─────────────────────────────────────────────────────────── */
#header { margin-bottom: 22px; }

#date-line {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

#greeting {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 40px;
  line-height: 1.05;
  margin: 0 0 6px;
}

#subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ── Категории (чипсы) ─────────────────────────────────────────────── */
#categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0 8px;
  margin: 0 0 14px;
}

.chip {
  flex: 0 0 auto;
  border: none;
  background: var(--chip);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
  backdrop-filter: blur(6px);
}
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--chip-active-bg);
  color: var(--chip-active-ink);
}

/* ── Список треков ─────────────────────────────────────────────────── */
#track-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  margin: 18px 4px 2px;
  color: var(--ink);
}
.section-title:first-child { margin-top: 4px; }

.track-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
  backdrop-filter: blur(8px);
}
.track-card:active { transform: scale(0.985); background: var(--card-active); }
.track-card.playing { background: var(--card-active); }

.track-thumb {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(140deg, #f0c9a8, var(--accent));
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35), 0 2px 8px rgba(120,80,50,0.15);
  display: grid;
  place-items: center;
}
.thumb-eq {
  color: #fff;
  font-size: 15px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
}

/* Ряд авторов — outline-чипсы, отличаются от категорий */
#authors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.author-chip {
  background: transparent;
  border: 1px solid rgba(168, 92, 56, 0.35);
}
.author-chip.active {
  background: var(--accent-deep);
  color: #fff;
  border-color: var(--accent-deep);
}

/* Панель сортировки / счётчик */
#sortbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 4px 12px;
}
#track-count { font-size: 12.5px; color: var(--ink-soft); }
#sort-btn {
  border: none;
  background: var(--chip);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
#sort-btn:active { transform: scale(0.96); }

.empty-hint { color: var(--ink-soft); text-align: center; padding: 40px 0; }

.track-info { flex: 1 1 auto; min-width: 0; }
.track-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-sub {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.fav-toggle {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--accent);
  padding: 6px;
  line-height: 1;
  transition: transform .15s ease;
}
.fav-toggle:active { transform: scale(1.2); }
.fav-toggle.on { color: var(--accent-deep); }

#app-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
  margin-top: 34px;
  letter-spacing: 0.03em;
}

/* ── Мини-плеер ────────────────────────────────────────────────────── */
#mini-player {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(74px + var(--safe-bottom));   /* над нижним меню */
  max-width: 616px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(58, 47, 40, 0.94);
  color: #f6ecdf;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(80, 50, 30, 0.4);
  backdrop-filter: blur(12px);
  z-index: 40;
  animation: rise .25s ease;
}

@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.mini-play {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: #f6ecdf;
  color: #3a2f28;
  font-size: 15px;
  cursor: pointer;
}
.mini-meta { flex: 1 1 auto; min-width: 0; }
#mini-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mini-progress {
  height: 3px;
  background: rgba(246, 236, 223, 0.25);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
#mini-progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: #f0c9a8;
  border-radius: 3px;
}
#mini-expand {
  flex: 0 0 auto;
  border: none; background: transparent;
  color: #f6ecdf; font-size: 20px; cursor: pointer;
  padding: 4px 6px;
}

/* ── Полный плеер ──────────────────────────────────────────────────── */
#player {
  position: fixed;
  inset: 0;
  z-index: 60;
  background:
    radial-gradient(120% 70% at 50% 0%, #fbf4ea 0%, var(--bg-top) 45%, var(--bg-bottom) 100%);
  display: flex;
  align-items: flex-end;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.player-inner {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 26px calc(40px + var(--safe-bottom));
  padding-top: calc(24px + var(--safe-top));
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#player-close {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: var(--chip);
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 18px;
  backdrop-filter: blur(6px);
}
#player-close:active { transform: scale(0.96); }

#player-art {
  width: 230px; height: 230px;
  border-radius: 32px;
  background: linear-gradient(150deg, #f4d6b6, var(--accent) 70%, var(--accent-deep));
  background-size: cover;
  background-position: center;
  box-shadow: 0 20px 50px rgba(150, 90, 50, 0.3);
  margin: 20px 0 30px;
}

#player-category {
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 8px;
}

#player-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 29px;
  line-height: 1.15;
  margin: 0 0 30px;
  max-width: 420px;
}

#player-seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 420px;
  height: 4px;
  border-radius: 4px;
  background: rgba(168, 92, 56, 0.22);
  outline: none;
  cursor: pointer;
}
#player-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-deep);
  box-shadow: 0 2px 6px rgba(150,90,50,0.4);
}
#player-seek::-moz-range-thumb {
  width: 16px; height: 16px; border: none;
  border-radius: 50%;
  background: var(--accent-deep);
}

#player-time {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 8px 0 34px;
  font-variant-numeric: tabular-nums;
}

#player-controls {
  display: flex;
  align-items: center;
  gap: 34px;
  margin-bottom: 30px;
}

.ctl-secondary {
  position: relative;
  width: 54px; height: 54px;
  border: none; background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: 50%;
  font-size: 11px; font-weight: 600;
  display: grid; place-items: center;
}
.ctl-secondary::before {
  content: "↺";
  position: absolute;
  font-size: 40px;
  font-weight: 300;
  color: var(--ink);
  opacity: 0.8;
}
#fwd15::before { content: "↻"; }
.ctl-num {
  position: relative;
  z-index: 1;
  font-size: 10px;
  transform: translateY(1px);
}

.ctl-main {
  width: 78px; height: 78px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(168, 92, 56, 0.4);
  transition: transform .12s ease;
}
.ctl-main:active { transform: scale(0.94); }

.fav-big {
  border: 1.5px solid rgba(168, 92, 56, 0.4);
  background: transparent;
  color: var(--accent-deep);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 26px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.fav-big.active {
  background: var(--accent-deep);
  color: #fff;
  border-color: var(--accent-deep);
}

.hidden { display: none !important; }

/* ── Нижнее меню (tabbar) ──────────────────────────────────────────── */
#tabbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(250, 244, 236, 0.86);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(168, 92, 56, 0.12);
}

.tab {
  flex: 1 1 0;
  max-width: 160px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  transition: color .2s ease;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent-deep); }
.tab:active { transform: scale(0.95); }

/* ── Экран статистики ──────────────────────────────────────────────── */
.stats-hero { margin-bottom: 22px; }
.stats-hero h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 34px;
  margin: 0 0 4px;
}
.stats-hero p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 18px 8px 14px;
  text-align: center;
}
.stat-num {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 34px;
  line-height: 1;
  color: var(--accent-deep);
}
.stat-label {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.25;
}

.stats-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 20px 18px 22px;
}
.stats-panel h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 23px;
  font-weight: 600;
  margin: 0 0 6px;
}
.stats-sub {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.45;
}

#calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
#calendar-head button {
  border: none; background: transparent;
  font-size: 22px; color: var(--accent-deep);
  cursor: pointer; padding: 2px 10px; line-height: 1;
}
#cal-month {
  font-size: 14px; font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

#calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px 4px;
}
.cal-dow {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  padding-bottom: 4px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-radius: 50%;
  position: relative;
}
.cal-cell.blank { visibility: hidden; }
.cal-cell.practiced {
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(168, 92, 56, 0.3);
}
.cal-cell.today {
  box-shadow: inset 0 0 0 1.5px var(--accent-deep);
  color: var(--accent-deep);
  font-weight: 600;
}
.cal-cell.today.practiced { color: #fff; }
.cal-cell.future { opacity: 0.4; }

.cal-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  margin: 16px 0 0;
}

.cal-cell[data-day] { cursor: pointer; }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--accent-deep); }
.cal-cell.selected.practiced { box-shadow: inset 0 0 0 2px #fff; }

#day-detail {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(168, 92, 56, 0.07);
  border-radius: 14px;
  font-size: 13.5px;
  color: var(--ink);
  text-align: center;
}
#day-detail b { color: var(--accent-deep); }

/* Фильтр по длительности — пунктирные чипсы */
#durations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}
.dur-chip { background: transparent; border: 1px dashed rgba(168, 92, 56, 0.45); }
.dur-chip.active {
  background: var(--accent-deep);
  color: #fff;
  border-color: var(--accent-deep);
  border-style: solid;
}

/* ── Экран «Тишина» ────────────────────────────────────────────────── */
#silence-stage { display: flex; justify-content: center; margin: 12px 0 28px; }
#silence-ring-wrap { position: relative; width: 260px; height: 260px; }
#silence-ring-svg { width: 260px; height: 260px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(168, 92, 56, 0.14); stroke-width: 7; }
.ring-fg {
  fill: none;
  stroke: var(--accent-deep);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
#silence-time {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600; font-size: 54px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
#silence-presets {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px; margin-bottom: 22px;
}
.dur-preset {
  border: 1px solid rgba(168, 92, 56, 0.35);
  background: transparent; color: var(--ink);
  font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  transition: transform .12s ease;
}
.dur-preset:active { transform: scale(0.95); }
.dur-preset.active { background: var(--accent-deep); color: #fff; border-color: var(--accent-deep); }
#silence-start {
  display: block; width: 100%; max-width: 320px; margin: 0 auto;
  border: none; border-radius: 18px; padding: 16px;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep)); color: #fff;
  font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 12px 30px rgba(168, 92, 56, 0.35);
  transition: transform .12s ease;
}
#silence-start:active { transform: scale(0.98); }
#silence-hint { text-align: center; color: var(--ink-soft); font-size: 12.5px; margin-top: 16px; }

/* Тёмная тема — новые элементы */
@media (prefers-color-scheme: dark) {
  #tabbar {
    background: rgba(30, 24, 21, 0.9);
    border-top-color: rgba(224, 160, 116, 0.14);
  }
}

/* Тёмная тема Telegram — мягко приглушаем, не выжигаем глаза ночью */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-top: #26201c;
    --bg-bottom: #1c1815;
    --ink: #efe3d6;
    --ink-soft: #b09a86;
    --card: rgba(58, 48, 41, 0.6);
    --card-active: rgba(72, 60, 51, 0.85);
    --chip: rgba(255, 255, 255, 0.08);
    --chip-active-bg: #efe3d6;
    --chip-active-ink: #26201c;
    --accent: #d68a5f;
    --accent-deep: #e0a074;
  }
  body {
    background:
      radial-gradient(120% 80% at 50% 0%, #2e2622 0%, var(--bg-top) 45%, var(--bg-bottom) 100%)
      fixed;
  }
  #player {
    background: radial-gradient(120% 70% at 50% 0%, #2e2622 0%, var(--bg-top) 50%, var(--bg-bottom));
  }
}
