/* ===== 基础重置 ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --bg-card: #1a1a1a;
  --bg-hover: #222;
  --fg: rgba(255, 255, 255, 0.92);
  --fg-muted: rgba(255, 255, 255, 0.55);
  --fg-faint: rgba(255, 255, 255, 0.3);
  --border: rgba(255, 255, 255, 0.08);
  --accent: #c89b5c;
  --accent-dim: rgba(200, 155, 92, 0.15);
  --radius: 6px;
  --font-stack: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  min-height: 100vh;
}

/* ===== 头部 ===== */
header {
  padding: 48px 24px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.header-text h1 {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.subtitle {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-top: 4px;
}

.header-links {
  display: flex;
  gap: 8px;
}

.link-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg-muted);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.link-item:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.link-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.link-meta {
  font-size: 0.75rem;
  color: var(--fg-faint);
}

/* ===== 主体 ===== */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== 工具栏 ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.back-btn {
  display: none;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.back-btn:hover {
  border-color: var(--fg-faint);
  color: var(--fg);
}

.toolbar input[type="text"] {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.toolbar input[type="text"]:focus {
  border-color: var(--accent);
}

.toolbar input[type="text"]::placeholder {
  color: var(--fg-faint);
}

/* ===== 分类卡片网格 ===== */
.tab-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

/* ===== 分类卡片 ===== */
.category-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.category-card:hover {
  background: var(--bg-hover);
  border-color: rgba(200, 155, 92, 0.3);
}

.category-card .card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.category-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.category-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
}

.category-card .card-meta {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-bottom: 10px;
}

.category-formats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fmt-count {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
}

.fmt-count.gpx { background: rgba(200, 155, 92, 0.12); color: var(--accent); }
.fmt-count.pdf { background: rgba(248, 81, 73, 0.12); color: #f85149; }
.fmt-count.img { background: rgba(63, 185, 80, 0.12); color: #3fb950; }

/* ===== 谱子卡片 ===== */
.tab-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tab-card:hover {
  background: var(--bg-hover);
  border-color: rgba(200, 155, 92, 0.2);
}

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

.tab-card h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.card-versions {
  font-size: 0.75rem;
  color: var(--accent);
}

.card-category {
  font-size: 0.75rem;
  color: var(--fg-faint);
}

.card-dot {
  color: var(--fg-faint);
  font-size: 0.75rem;
}

.card-contributor {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}

.card-contributor:hover {
  text-decoration: underline;
}

.tab-card .formats {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.format-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.format-badge.gpx { background: rgba(200, 155, 92, 0.12); color: var(--accent); }
.format-badge.pdf { background: rgba(248, 81, 73, 0.12); color: #f85149; }
.format-badge.jpg,
.format-badge.jpeg,
.format-badge.png { background: rgba(63, 185, 80, 0.12); color: #3fb950; }

/* ===== 模态框 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  width: 100%;
  max-width: 860px;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 20px;
  padding-right: 32px;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-muted);
  font-size: 1.3rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.close-btn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

/* ===== 预览模式切换器 ===== */
.preview-mode-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}

.mode-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-btn:hover {
  color: var(--fg);
  border-color: var(--fg-faint);
}

.mode-btn.active {
  background: var(--accent-dim);
  border-color: rgba(200, 155, 92, 0.3);
  color: var(--accent);
}

/* ===== alphaTab 容器 ===== */
#alphaTab-container {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  min-height: 400px;
  overflow-x: auto;
  color: #000;
}

#alphaTab-container p {
  color: #666;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.player-controls button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.player-controls button:hover {
  border-color: var(--fg-faint);
  color: var(--fg);
}

.player-controls a {
  padding: 6px 14px;
  border: 1px solid rgba(200, 155, 92, 0.3);
  border-radius: var(--radius);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}

.player-controls a:hover {
  background: rgba(200, 155, 92, 0.22);
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-control label {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.speed-control input[type="range"] {
  width: 100px;
  accent-color: var(--accent);
}

/* ===== 图片画廊 ===== */
.image-gallery {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.image-item {
  position: relative;
}

.image-item .preview-image {
  max-width: 100%;
  border-radius: var(--radius);
  display: block;
  cursor: zoom-in;
  transition: opacity 0.15s ease;
}

.image-item .preview-image:hover {
  opacity: 0.92;
}

.image-item .img-download {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
  backdrop-filter: blur(4px);
}

.image-item:hover .img-download {
  opacity: 1;
}

.image-item .img-download:hover {
  background: rgba(0, 0, 0, 0.75);
}

/* ===== PDF 预览 ===== */
.preview-pdf {
  width: 100%;
  height: 600px;
  border: none;
  border-radius: var(--radius);
}

/* ===== 免责声明 ===== */
.disclaimer-banner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 24px;
  background: rgba(224, 123, 57, 0.12);
  border: 1px solid rgba(224, 123, 57, 0.3);
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: 0.85rem;
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.disclaimer-banner strong {
  color: #e07b39;
  font-weight: 600;
}

.disclaimer-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ===== 底部 ===== */
footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--fg-faint);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 60px;
}

footer .divider {
  margin: 0 8px;
}

.footer-link {
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--fg);
}

.signature {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  margin-left: 6px;
  opacity: 0.75;
  vertical-align: middle;
}

footer .signature {
  font-size: 1rem;
  opacity: 1;
  margin-left: 0;
}

/* ===== 贡献者标签 ===== */
.contributor-tag {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-bottom: 12px;
}

.contributor-tag a {
  color: var(--accent);
  text-decoration: none;
}

.contributor-tag a:hover {
  text-decoration: underline;
}

/* ===== 致谢按钮 ===== */
.credits-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.credits-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== 致谢墙 ===== */
.credits-content {
  max-width: 480px;
}

.credits-sub {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.credits-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.credits-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.credits-name {
  font-weight: 500;
}

.credits-name a {
  color: var(--accent);
  text-decoration: none;
}

.credits-name a:hover {
  text-decoration: underline;
}

.credits-count {
  font-size: 0.75rem;
  color: var(--fg-faint);
}

.credits-empty {
  color: var(--fg-faint) !important;
  justify-content: center !important;
  font-size: 0.85rem;
}

.credits-cta {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.6;
}

.credits-cta p:first-child {
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.credits-contact {
  list-style: none;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.credits-contact li {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.credits-contact li a {
  color: var(--accent);
  text-decoration: none;
}

.credits-contact li a:hover {
  text-decoration: underline;
}

.credits-promise {
  margin-top: 8px !important;
  font-size: 0.8rem;
  color: var(--fg-faint) !important;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--fg-faint);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--fg-muted);
}

/* ===== 响应式 ===== */

/* 平板 */
@media (max-width: 768px) {
  .tab-list {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
  }
}

/* 手机 */
@media (max-width: 640px) {
  header {
    padding: 24px 16px 20px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-text h1 {
    font-size: 1.35rem;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  .header-links {
    width: 100%;
    flex-direction: row;
    gap: 6px;
  }

  .link-item {
    flex: 1;
    padding: 6px 10px;
  }

  main {
    padding: 16px 12px;
  }

  .toolbar {
    gap: 8px;
    margin-bottom: 16px;
  }

  .toolbar input[type="text"] {
    font-size: 0.85rem;
    padding: 8px 12px;
    min-width: 0;
  }

  .back-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .credits-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .tab-list {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .category-card {
    padding: 14px 16px;
  }

  .category-icon {
    font-size: 1.2rem;
  }

  .category-card h3 {
    font-size: 0.95rem;
  }

  .tab-card {
    padding: 12px 14px;
    gap: 8px;
  }

  .tab-card h3 {
    font-size: 0.85rem;
  }

  .card-meta-row {
    flex-wrap: wrap;
  }

  .card-category,
  .card-dot,
  .card-contributor {
    font-size: 0.7rem;
  }

  .format-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
  }

  .modal {
    padding: 12px;
    align-items: flex-start;
    overflow-y: auto;
  }

  .modal-content {
    padding: 16px 14px;
    border-radius: var(--radius);
    margin-top: auto;
    margin-bottom: auto;
    max-height: none;
  }

  .modal-content h2 {
    font-size: 1rem;
    margin-bottom: 12px;
  }

  .close-btn {
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
  }

  .preview-mode-selector {
    gap: 4px;
    margin-bottom: 12px;
  }

  .mode-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .player-controls {
    gap: 6px;
    margin-bottom: 12px;
  }

  .player-controls button {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .player-controls a {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .speed-control label {
    font-size: 0.75rem;
  }

  .speed-control input[type="range"] {
    width: 70px;
  }

  #alphaTab-container {
    padding: 10px;
    min-height: 300px;
  }

  .preview-pdf {
    height: 350px;
  }

  .image-gallery {
    gap: 10px;
  }

  .image-item .img-download {
    opacity: 1;
    top: 6px;
    right: 6px;
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .contributor-tag {
    font-size: 0.75rem;
    margin-bottom: 8px;
  }

  .credits-content {
    max-width: 100%;
  }

  .credits-list li {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .credits-cta {
    font-size: 0.8rem;
  }

  .disclaimer-banner {
    margin: 0 12px;
    padding: 10px 14px;
    font-size: 0.78rem;
  }

  footer {
    padding: 24px 16px;
    font-size: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  footer .divider {
    margin: 0 4px;
  }
}

/* 小屏手机 */
@media (max-width: 380px) {
  .header-text h1 {
    font-size: 1.2rem;
  }

  .header-links {
    flex-direction: column;
    gap: 4px;
  }

  .link-item {
    width: 100%;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar input[type="text"] {
    width: 100%;
    order: 2;
  }

  .back-btn {
    order: 1;
  }

  .credits-btn {
    order: 3;
    margin-left: auto;
  }

  .preview-pdf {
    height: 280px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
