/* ==================================================
   Worship Songs · PWA-приложение пользователя
   ================================================== */

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e4e7ee;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --topbar-h: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

[hidden],
.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* ==================================================
   Экран входа
   ================================================== */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  position: relative;
}

.login-gear {
  position: absolute;
  top: 12px;
  right: 12px;
  appearance: none;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.login-gear:hover,
.login-gear:focus-visible {
  opacity: 1;
  background: var(--primary-soft);
  outline: none;
}

.admin-password-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.admin-password-field .field-label {
  font-size: 13px;
}

.login-title {
  margin: 0;
  font-size: 28px;
  text-align: center;
}

.login-subtitle {
  margin: 6px 0 24px;
  text-align: center;
  color: var(--muted);
}

/* ==================================================
   Шапка и навигация
   ================================================== */

.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand {
  font-weight: 700;
  font-size: 17px;
  flex: 1;
}

.admin-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 18px;
  text-decoration: none;
}

.user-chip {
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.06);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav .nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  flex: 1;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  cursor: pointer;
}

.bottom-nav .nav-icon {
  font-size: 22px;
  line-height: 1;
}

.bottom-nav .nav-label {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.bottom-nav .nav-item.is-active {
  color: var(--primary);
}

.bottom-nav .nav-item.is-active .nav-icon {
  transform: scale(1.15);
}

/* Приподнятая центральная кнопка «Поиск» (как FAB в мобильных приложениях). */
.bottom-nav .nav-fab {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
}

.bottom-nav .nav-fab .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  transform: translateY(-16px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.4);
  border: 4px solid var(--bg);
  transition: background 0.15s, transform 0.15s;
}

.bottom-nav .nav-fab.is-active .nav-icon {
  background: var(--primary-dark);
}

.bottom-nav .nav-logout {
  color: var(--danger);
}

.content {
  padding: 16px 14px 96px;
  flex: 1;
}

/* ==================================================
   Карточки
   ================================================== */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 19px;
}

.card-subtitle {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 10px;
}

.section-title {
  margin: 0;
  font-size: 17px;
}

/* ==================================================
   Формы и кнопки
   ================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field-hint {
  font-weight: 400;
  color: var(--muted);
  opacity: 0.8;
}

.input,
textarea.input,
select.input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: #f7f8fa;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-danger {
  color: var(--danger);
  border-color: #f3c9c9;
}

.btn-danger:hover {
  background: #fdecec;
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 6px 10px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar .input {
  flex: 1;
  min-width: 180px;
}

/* ==================================================
   Поиск: радио-кнопки способа поиска
   ================================================== */

.search-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.search-radio {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.search-radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.search-radio:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.search-radio.is-checked {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ==================================================
   План служения
   ================================================== */

.plan-card {
  border-left: 5px solid var(--primary);
}

.plan-card.is-published {
  border-left-color: var(--ok);
}

.plan-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3f4f8;
  color: var(--muted);
}

.plan-status.published {
  background: #e7f6ec;
  color: var(--ok);
}

.song-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.song-row:first-child {
  border-top: 0;
}

/* Компактная строка «только название» (Актуальное служение на главной). */
.song-row-plain {
  padding: 6px 0;
  gap: 10px;
}

.song-row-plain .song-title {
  font-size: 15px;
}

.song-position {
  color: var(--muted);
  font-size: 13px;
  min-width: 22px;
  text-align: center;
  font-weight: 700;
}

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

.song-title {
  font-weight: 600;
  word-break: break-word;
}

.song-meta {
  color: var(--muted);
  font-size: 13px;
}

.song-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.tag {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
}

/* Теги-кнопки (темы/категории) — кликабельны. */
button.tag {
  appearance: none;
  border: 0;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

button.tag:hover {
  background: var(--primary);
  color: #fff;
}

/* Чипы разделов (темы/категории) на экране поиска. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.chip:active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Шапка активного фильтра (тема/категория). */
.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.filter-head-title {
  font-size: 15px;
  color: var(--text);
  word-break: break-word;
}

.song-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ==================================================
   Результаты поиска, пустые состояния
   ================================================== */

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

/* ==================================================
   Пагинация
   ================================================== */

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.page-info {
  color: var(--muted);
  font-size: 14px;
}

/* ==================================================
   Аудио
   ================================================== */

.player {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}

.player audio {
  width: 100%;
}

/* ==================================================
   Модальные окна
   ================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

@media (min-width: 560px) {
  .modal-backdrop {
    align-items: center;
    padding: 24px;
  }
}

.modal {
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
}

@media (min-width: 560px) {
  .modal {
    border-radius: 16px;
    max-width: 560px;
  }
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg);
}

.modal-body {
  padding: 16px 18px 24px;
}

/* ==================================================
   Тосты
   ================================================== */

#toast-root {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #232a3b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 100%;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #14532d;
}

.toast-error {
  background: #7f1d1d;
}

/* ==================================================
   Детали плана, текст песни, мобильная навигация
   ================================================== */

.plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.song-text {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.song-text summary {
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 14px;
}

.song-text p {
  white-space: pre-wrap;
  color: var(--text);
  font-size: 15px;
}

.toast-live {
  background: var(--primary-dark);
}



