:root {
  color-scheme: light;
  --accent: #5f9ea0;
  --bg: #ffffff;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --badge-petits: #f2aa9b;
  --badge-grands: #87a2d7;
  --badge-essais: #7cbd8a;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior-y: contain;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.view {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view[hidden] {
  display: none;
}

/* --- Liste --- */

.search-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

#search-input {
  min-width: 0;
  flex: 1;
  padding: 10px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f5f5f5;
  color: var(--text);
}

#search-input:focus {
  outline: 2px solid var(--accent);
  background: var(--bg);
}

.install-button {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}

.radio-button {
  flex-shrink: 0;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.radio-button.playing {
  border-color: #c75b5b;
  background: #c75b5b;
  color: #fff;
}

.radio-button.playing:hover {
  background: #ad4949;
}

.radio-button:active {
  transform: translateY(1px);
}

.radio-button[hidden] {
  display: none;
}

.radio-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.radio-icon-stop,
.radio-button.playing .radio-icon-play {
  display: none;
}

.radio-button.playing .radio-icon-stop {
  display: block;
}

@media all and (display-mode: standalone), all and (display-mode: fullscreen), all and (display-mode: minimal-ui) {
  .install-button {
    display: none !important;
  }
}

.install-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  color: var(--text);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
}

@media (min-width: 480px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-card {
    border-radius: 16px;
  }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--muted);
}

.modal-card h2 {
  margin: 0 0 16px;
  padding-right: 30px;
  font-size: 18px;
}

.modal-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-steps li {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
}

.modal-step-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(95, 158, 160, 0.12);
  color: var(--accent);
}

.refresh-indicator {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(95, 158, 160, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.refresh-indicator[hidden] {
  display: none;
}

.sheet-filter {
  position: sticky;
  top: 62px;
  z-index: 4;
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.filter-button {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f7f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.filter-button[data-filter="petits"] {
  border-color: var(--badge-petits);
  color: #9b4d43;
}

.filter-button[data-filter="grands"] {
  border-color: var(--badge-grands);
  color: #42619d;
}

.filter-button[data-filter="essais"] {
  border-color: var(--badge-essais);
  color: #3f7a4b;
}

.filter-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.filter-button[data-filter="petits"].active {
  border-color: var(--badge-petits);
  background: var(--badge-petits);
}

.filter-button[data-filter="grands"].active {
  border-color: var(--badge-grands);
  background: var(--badge-grands);
}

.filter-button[data-filter="essais"].active {
  border-color: var(--badge-essais);
  background: var(--badge-essais);
}

.chant-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0 0 24px;
  list-style: none;
  -webkit-overflow-scrolling: touch;
}

.radio-active .chant-list {
  padding-bottom: 98px;
}

.radio-player {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 66px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(10px);
}

.radio-active .chant-view {
  padding-bottom: 88px;
}

.radio-player[hidden] {
  display: none;
}

.radio-control[hidden] {
  display: none;
}

.radio-control {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.radio-control svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.radio-stop {
  border-color: var(--border);
  background: #fff;
  color: var(--muted);
}

.radio-main {
  min-width: 0;
  flex: 1;
}

.radio-now {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 2px;
}

.radio-kicker,
.radio-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radio-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.radio-title {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 600;
}

.audio-progress {
  display: block;
  width: 100%;
  height: 18px;
  margin: 4px 0 0;
  accent-color: var(--accent);
}

.audio-progress:disabled {
  opacity: 0.45;
}

@media (max-width: 380px) {
  .radio-button span {
    display: none;
  }
}

.chant-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.chant-row .badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  height: 26px;
  font-size: 11px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 6px;
  color: #fff;
}

.badge.sheet-petits { background: var(--badge-petits); }
.badge.sheet-grands { background: var(--badge-grands); }
.badge.sheet-essais { background: var(--badge-essais); }

.chant-row .info {
  min-width: 0;
  flex: 1;
}

.chant-row .title {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chant-row .ref {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chant-row .number {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
}

.audio-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.audio-mark svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  margin-top: 40px;
}

/* --- Vue chant --- */

.chant-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10;
}

.chant-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  border-bottom: 1px solid var(--border);
}

.icon-button {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
}

.audio-button {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
}

.audio-button.playing {
  background: var(--accent);
  color: #fff;
}

.chant-header-text {
  min-width: 0;
  flex: 1;
}

.chant-header-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chant-header-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swipe-area {
  flex: 1;
  display: flex;
  width: 200%;
  height: 100%;
  transition: transform 0.25s ease-out;
  touch-action: pan-y;
}

.swipe-area.dragging {
  transition: none;
}

.pane {
  width: 50%;
  height: 100%;
  overflow: hidden;
}

.pane-pdf {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}

.partition-pages {
  min-height: 100%;
  padding: 10px 0 32px;
}

.partition-page {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 12px;
  background: #fff;
}

.partition-unavailable {
  margin: 40px auto;
  color: var(--muted);
  text-align: center;
}

.pane-lyrics {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lyrics-content {
  padding: 20px 20px 60px;
  font-size: 17px;
  line-height: 1.6;
}

.lyrics-content p {
  margin: 0 0 1em;
}

.lyrics-content .no-lyrics {
  color: var(--muted);
  text-align: center;
  margin-top: 40px;
}

.pane-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.pane-dots[hidden] {
  display: none;
}

.pane-tabs {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 4px 10px max(4px, env(safe-area-inset-bottom));
  gap: 6px;
}

.pane-tabs[hidden] {
  display: none;
}

.pane-tab {
  flex: 1;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.pane-tab.active {
  background: rgba(95, 158, 160, 0.14);
  color: var(--accent);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
}

.dot.active {
  background: var(--accent);
}
