* { box-sizing: border-box; }

:root {
  --book-rows: 14;
  --chapter-rows: 15;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  background: #0a0f1e;
  color: #fff;
  font-family: Arial, sans-serif;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: clamp(16px, 4vh, 48px);
  padding: 20px;
}

#track-title {
  font-size: clamp(22px, 4vw, 48px);
  color: #c5a059;
  text-align: center;
  margin: 0;
}

#controls {
  display: flex;
  gap: clamp(12px, 3vw, 40px);
  flex-wrap: wrap;
  justify-content: center;
}

.control {
  width: clamp(52px, 8vw, 100px);
  height: clamp(52px, 8vw, 100px);
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: clamp(18px, 3vw, 36px);
  cursor: pointer;
}

.control.focused {
  background: #c5a059;
  color: #000;
  outline: 4px solid #fff;
}

.control.active {
  color: #c5a059;
}

.control.active.focused {
  color: #000;
}

#progress-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  width: min(90vw, 900px);
  font-size: clamp(16px, 2.2vw, 28px);
}

#progress-bar {
  flex: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: #c5a059;
}

.hidden {
  display: none !important;
}

#library-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0f1e;
  padding: clamp(20px, 4vh, 40px) clamp(20px, 6vw, 80px);
  overflow: auto;
  z-index: 10;
}

#library-view h2 {
  color: #c5a059;
  font-size: clamp(24px, 3.5vw, 36px);
  margin: 0 0 20px 0;
}

#book-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--book-rows), auto);
  column-gap: clamp(14px, 2vw, 30px);
  row-gap: 4px;
  justify-content: start;
}

#book-list.chapters {
  grid-template-rows: repeat(var(--chapter-rows), auto);
}

#book-list li {
  font-size: clamp(16px, 1.6vw, 24px);
  padding: 8px 14px;
  border-radius: 6px;
  white-space: nowrap;
}

#book-list.chapters li {
  text-align: center;
}

#book-list li.focused {
  background: #c5a059;
  color: #000;
  font-weight: bold;
}

/* Тесни екрани (телефон/таблет): по-малко колони - повече редове на колона,
   вместо да се разпънат прекалено много тесни колони встрани. */
@media (max-width: 900px) {
  :root {
    --book-rows: 30;
    --chapter-rows: 34;
  }
}

/* ---------- История: календар ---------- */

#history-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 40px);
  margin-bottom: 20px;
}

#history-month-label {
  font-size: clamp(18px, 2vw, 26px);
  color: #c5a059;
  min-width: 180px;
  text-align: center;
}

.cal-nav {
  width: clamp(36px, 5vw, 52px);
  height: clamp(36px, 5vw, 52px);
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: clamp(18px, 2.4vw, 28px);
  cursor: pointer;
}

.cal-nav.focused {
  background: #c5a059;
  color: #000;
  outline: 4px solid #fff;
}

#history-weekdays,
#history-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(6px, 1vw, 14px);
  max-width: 560px;
  margin: 0 auto;
}

#history-weekdays {
  color: #c5a059;
  font-size: clamp(13px, 1.4vw, 18px);
  text-align: center;
  margin-bottom: 10px;
}

.cal-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: clamp(14px, 1.6vw, 20px);
  position: relative;
}

.cal-day {
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.cal-day.has-history::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c5a059;
}

.cal-day.focused {
  background: #c5a059;
  color: #000;
  font-weight: bold;
  outline: 3px solid #fff;
}

.cal-blank {
  background: transparent;
  cursor: default;
}

/* ---------- Будилник: редове с ‹/› за час/минута ---------- */

#book-list li.alarm-row {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 20px);
}

.field-btn {
  width: clamp(28px, 4vw, 40px);
  height: clamp(28px, 4vw, 40px);
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: clamp(14px, 2vw, 20px);
  cursor: pointer;
}

#book-list li.alarm-row.focused .field-btn {
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
}
