/*
 * Hymns Site — 公共样式表
 * 所有页面共用的 Design Tokens、基础重置、共用组件
 */

/* ==========================================================================
   1. Design Tokens
   ========================================================================== */
:root {
  --primary: #1a3a2a;
  --primary-dark: #0f2318;
  --primary-hover: #1f4a36;
  --primary-light: #edf4f0;
  --bg: #f4f3ef;
  --border: #d4ddd9;
  --shadow-sm: 0 1px 4px oklch(0.2 0.04 155 / 0.07);
  --shadow-md: 0 4px 16px oklch(0.2 0.04 155 / 0.1);
  --shadow-card: 0 8px 32px oklch(0.2 0.04 155 / 0.1);
  --text: #1a2e24;
  --muted: #3d5246;
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   2. 基础重置
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: 'Noto Sans SC', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
img,
svg {
  display: block;
  max-width: 100%;
}
button {
  cursor: pointer;
  font-family: inherit;
}
input,
select,
textarea {
  font-family: inherit;
  color: var(--text);
}

/* ==========================================================================
   3. 卡片
   ========================================================================== */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-card);
}
.card-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.card-subtitle {
  font-size: 0.87rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
  margin-top: -1rem;
}
.card-divider {
  border: none;
  border-top: 1px solid #e8ede9;
  margin: 1.2rem 0 1rem;
}

/* ==========================================================================
   5. 表单元素
   ========================================================================== */
.form-group {
  margin-bottom: 1rem;
}
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: white;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px oklch(from #1a3a2a l c h / 0.1);
}
.hint {
  font-size: 0.77rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* ==========================================================================
   6. 按钮
   ========================================================================== */
.btn {
  width: 100%;
  padding: 0.8rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.97rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition:
    background var(--transition),
    box-shadow var(--transition);
  box-shadow: 0 2px 10px oklch(0.2 0.04 155 / 0.18);
}
.btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px oklch(0.2 0.04 155 / 0.24);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-ghost {
  width: 100%;
  padding: 0.7rem;
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.93rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.6rem;
  transition:
    background var(--transition),
    border-color var(--transition);
}
.btn-ghost:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ==========================================================================
   7. 页脚链接
   ========================================================================== */
.footer-link {
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}
.footer-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.footer-link a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   9. Toast 全局组件（统一浮层提示）
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 20px rgba(15, 35, 24, 0.3);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  white-space: nowrap;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.toast.out {
  animation: toastOut 0.2s ease forwards;
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

/* ==========================================================================
   11. Spinner 加载动画
   10. Header（统一 header 组件样式）
   ========================================================================== */
header {
  background: var(--primary);
  color: white;
  height: 64px;
  padding: 0 2rem;
  /* 三栏 grid：左右各占内容宽，中间 1fr 自动撑满 → 标题绝对居中 */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(15, 35, 24, 0.4);
}
header .header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-start;
  min-width: 0;
}
header .header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.75rem;
  min-width: 0;
}
header .header-center .header-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Noto Serif SC', serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: white;
}
header .header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-end;
  min-width: 0;
}

/* 品牌（与 index.css 一致） */
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: white;
  flex-shrink: 0;
}
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-text h1 {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  color: white;
}
.header-brand-sub {
  font-size: 0.66rem;
  opacity: 0.65;
  white-space: nowrap;
  line-height: 1.3;
  color: white;
}

/* 标题（单独显示时的后备样式） */
.header-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 返回按钮 */
.header-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
}
.header-nav-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}
.header-extra-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.header-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.18s;
}
.header-back svg {
  display: block;
  width: 18px;
  height: 18px;
}
.header-back:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
  transform: scale(1.05);
}

/* Header 响应式 */
@media (max-width: 768px) {
  header {
    padding: 0 0.75rem;
    height: 56px;
  }
  .logo-text {
    display: none;
  }
  .logo-wrap {
    gap: 0;
  }
  .logo-mark {
    width: 34px;
    height: 34px;
  }
  .header-back {
    width: 34px;
    height: 34px;
  }
}
@media (max-width: 480px) {
  header {
    padding: 0 0.5rem;
    height: 50px;
  }
  .logo-mark {
    width: 34px;
    height: 34px;
  }
  .header-back {
    width: 30px;
    height: 30px;
  }
}

.header-login-btn {
  padding: 0.4rem 1rem;
  border-radius: 7px;
  font-size: 0.83rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.header-login-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* 用户菜单（下拉） */
.user-menu {
  position: relative;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: all 0.15s;
}
.avatar:hover {
  background: rgba(255, 255, 255, 0.28);
}
.dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: #fff;
  border: 1px solid #d8d3cc;
  border-radius: 12px;
  box-shadow:
    0 12px 32px rgba(20, 50, 36, 0.13),
    0 4px 12px rgba(20, 50, 36, 0.07);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
  animation: dropIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.dropdown.show {
  display: block;
}
.dropdown-header {
  padding: 0.85rem 1rem;
  background: #edf4f0;
  border-bottom: 1px solid #e2ddd7;
}
.dropdown-header .name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #1a2922;
}
.perm {
  display: inline-block;
  margin-top: 5px;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}
.perm.yes {
  background: #d1fae5;
  color: #065f46;
}
.perm.no {
  background: #fef3c7;
  color: #92400e;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1rem;
  color: #1a2922;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}
.dropdown-item:hover {
  background: #edf4f0;
}
.dropdown-item.danger {
  color: #dc2626;
}
.dropdown-item.danger:hover {
  background: #fef2f2;
}
.dropdown-divider {
  height: 1px;
  background: #e2ddd7;
}

/* Auth 页面 minimal header */
.site-header.auth-header {
  position: relative;
  z-index: 1;
}
body.has-minimal-header {
  padding-top: 60px;
}

/* ==========================================================================
   ========================================================================== */
.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.3rem;
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   12. 分享按钮
   ========================================================================== */
.btn-share {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--primary-mid);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.btn-share:hover {
  background: var(--primary-mid);
  border-color: var(--accent);
}

/* ==========================================================================
   13. 播放历史
   ========================================================================== */
.btn-clear-history {
  font-size: 0.75rem;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  transition: color var(--transition);
}
.btn-clear-history:hover {
  color: var(--text);
}

/* ==========================================================================
   14. PWA 安装提示模块
   ========================================================================== */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  padding: 0.75rem 1rem;
  display: none;
  align-items: center;
  justify-content: center;
  animation: slideUpBanner 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUpBanner {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 600px;
}
.pwa-install-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}
.pwa-install-text {
  flex: 1;
  min-width: 0;
}
.pwa-install-text strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text);
}
.pwa-install-text span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1px;
}
.pwa-install-btn {
  padding: 0.45rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background var(--transition);
  flex-shrink: 0;
}
.pwa-install-btn:hover {
  background: var(--primary-hover);
}
.pwa-install-close {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}
.pwa-install-close:hover {
  color: var(--text);
}

/* ==========================================================================
   13. 离线缓存按钮
   ========================================================================== */
.btn-offline {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--primary-mid);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  min-width: 60px;
  white-space: nowrap;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.btn-offline:hover {
  background: var(--primary-mid);
  border-color: var(--accent);
}
.btn-offline.cached {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #065f46;
}
.btn-offline.cached:hover {
  background: #a7f3d0;
  border-color: #34d399;
}
.btn-offline.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* 播放列表删除按钮 */
