/* ============================================
   Map — 2D-style Book Spines + Timeline
   ============================================ */

/* --- Spines Container --- */
.spines-container {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  position: relative;
}

/* --- Book Spine — matching 2D 3D effect --- */
.spine {
  display: flex;
  align-items: center;
  min-height: 35px;
  padding: 0 var(--space-sm);
  cursor: pointer;
  user-select: none;
  position: relative;
  -webkit-tap-highlight-color: transparent;

  /* Base color from CSS variable */
  background-color: var(--spine-color, #555);

  /* 3D book spine: matches 2D's dkC(0.32)/brC(0.12) */
  background-image: linear-gradient(
    180deg,
    rgba(0,0,0,0.32) 0%,
    rgba(255,255,255,0.12) 50%,
    rgba(0,0,0,0.32) 100%
  );
  background-blend-mode: overlay;

  /* Subtle bottom border (book edge separation) */
  border-bottom: 1px solid rgba(0,0,0,0.30);

  /* Rounded top/bottom like 2D's Q curves */
  border-radius: 2px;

  transition: filter var(--duration-fast) ease;
  overflow: hidden;
}

/* --- Subgenre Dots on Spine --- */
.spine-dots {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
}

.sd {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--dc);
  transform: translate(-50%,-50%);
  outline: 0.5px solid rgba(255,255,255,0.6);
  box-shadow: 0 0 1px rgba(0,0,0,0.4);
}

.spine:active {
  filter: brightness(1.12);
}

.spine.expanded {
  filter: brightness(1.06);
  border-radius: 2px 2px 0 0;
}

.spine-name-zh {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: var(--leading-tight);
  pointer-events: none;
  flex: 1;
}

.spine-info-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-size: 12px;
  font-style: italic;
  font-weight: 700;
  font-family: serif;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  padding: 0;
  cursor: pointer;
  z-index: 2;
  transition: background var(--duration-fast) ease;
  -webkit-tap-highlight-color: transparent;
}
.spine-info-btn:active {
  background: rgba(255,255,255,0.35);
}

.count-inline {
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  margin-left: 4px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

/* --- Timeline --- */
.timeline-wrapper {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--duration-normal) var(--ease-out);
  touch-action: pan-x pinch-zoom;
}
.timeline-wrapper.expanded { max-height: var(--timeline-height); }

.timeline {
  /* SG color tint via JS-set --sg-color-rgb */
  --sg-tint-opacity: 0.08;
  position: relative;
  z-index: 0;
  background: var(--color-timeline-bg);
  border-radius: 0;
  overflow: hidden;
  position: relative;
  touch-action: pan-x pinch-zoom;
}

.timeline::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(var(--sg-color-rgb, 200, 200, 200), var(--sg-tint-opacity, 0.08));
  pointer-events: none;
  z-index: 0;
}


.timeline-svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: calc(var(--timeline-height) - 4px);
  touch-action: pan-x pinch-zoom;
  cursor: grab;
}
.timeline-svg:active { cursor: grabbing; }

/* --- Supergenre Detail Panel (2D side-pane inspired) --- */
.sg-detail-panel {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: hsla(49,41%,92%,0.97);
  box-shadow: none;
  z-index: 60;
  transform: translateY(100%);
  transition: transform var(--duration-normal) var(--ease-out);
  display: flex;
  flex-direction: column;
}
.sg-detail-panel.active {
  transform: translateY(0);
}
.sg-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}
.sg-panel-header {
  flex-shrink: 0;
  padding: 14px 24px 12px;
  border-bottom: 1px solid rgba(181,176,158,0.5);
}
.sg-panel-close {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  border: none;
  font-size: 20px;
  color: #262626;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.sg-panel-close:active {
  background: rgba(0,0,0,0.15);
}
/* sg-panel-header-row removed, elements are direct children now */
.sg-panel-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.sg-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.1);
  font-size: 15px;
  color: #262626;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.sg-header-btn:active {
  background: rgba(0,0,0,0.15);
}
.sg-tts-btn.playing {
  background: rgba(52,199,89,0.2);
  border-color: #34c759;
  color: #34c759;
}
.sg-lang-btn {
  font-size: 11px;
  font-weight: 600;
  width: auto;
  padding: 0 8px;
  border-radius: 14px;
}
.sg-panel-name {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: #262626;
  line-height: 1.3;

}
.sg-panel-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 2px;
}
.sg-panel-years {
  font-size: 15px;
  font-weight: 600;
  color: #2c2c2c;
}
.sg-panel-count {
  font-size: 14px;
  color: #5a5a5a;
}
.sg-panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 24px 0;
  -webkit-overflow-scrolling: touch;
}
.sg-panel-desc {
  font-size: 13.4px;
  line-height: 1.7;
  color: #262626;
  font-family: 'Open Sans', system-ui, sans-serif;
}
.sg-panel-desc a {
  color: #2c2c2c;
  font-style: italic;
  font-weight: 600;
  text-decoration: none;
}
.sg-panel-desc b, .sg-panel-desc strong {
  font-weight: 700;
}
.sg-panel-placeholder {
  font-size: 13px;
  color: #888;
  text-align: center;
  padding: 40px 0;
}

/* --- Subgenre handle bar (2D sub-pane inspired) --- */
.sg-panel-sub {
  flex-shrink: 0;
  border-top: 1px solid rgba(181,176,158,0.5);
}
.sg-panel-sub-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  background: #d3cdb6;
  color: #262626;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.sg-panel-sub-handle:active {
  background: #ccc5ab;
}
.sg-sub-handle-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sg-panel-sub-handle small {
  font-weight: 400;
  font-size: 14px;
  color: #5a5a5a;
}
.sg-panel-sub-arrow {
  font-size: 16px;
  transition: transform 0.2s ease;
}
.sg-panel-sub-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease-out);
  background: rgba(211,205,182,0.3);
}
.sg-panel-sub-list.open {
  max-height: 320px;
  overflow-y: auto;
}
.sg-sub-item {
  display: flex;
  align-items: center;
  padding: 8px 24px;
  gap: 10px;
  border-bottom: 1px solid rgba(181,176,158,0.25);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sg-sub-item:active {
  background: rgba(211,205,182,0.4);
}
.sg-sub-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sg-sub-name {
  flex: 1;
  font-size: 13px;
  color: #262626;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sg-sub-year {
  font-size: 12px;
  color: #777;
  flex-shrink: 0;
}

/* ============================================
   Subgenre Detail Panel (matches 2D style)
   ============================================ */
/* ============================================
   Subgenre Detail Panel (matches 2D style)
   ============================================ */
.sub-detail-panel {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: hsla(49,41%,92%,0.97);
  box-shadow: none;
  z-index: 60;
  transform: translateY(100%);
  transition: transform var(--duration-normal) var(--ease-out);
  display: flex;
  flex-direction: column;
}
.sub-detail-panel.active {
  transform: translateY(0);
}
.sub-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* Header */
.sub-panel-header {
  flex-shrink: 0;
  padding: 14px 24px 10px;
  border-bottom: 1px solid rgba(181,176,158,0.5);
}
.sub-panel-close {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  border: none;
  font-size: 20px;
  color: #262626;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.sub-panel-close:active {
  background: rgba(0,0,0,0.15);
}
.sub-panel-name {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: #262626;
  line-height: 1.3;
  padding-right: 30px;
}
.sub-panel-parent {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.sub-parent-label {
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}
.sub-panel-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}
.sub-panel-year {
  font-size: 15px;
  font-weight: 600;
  color: #2c2c2c;
}
.sub-panel-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.sub-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.1);
  font-size: 15px;
  color: #262626;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.sub-header-btn:active {
  background: rgba(0,0,0,0.15);
}
.sub-tts-btn.playing {
  background: rgba(52,199,89,0.2);
  border-color: #34c759;
  color: #34c759;
}
.sub-lang-btn {
  font-size: 11px;
  font-weight: 600;
  width: auto;
  padding: 0 8px;
  border-radius: 14px;
}

/* Scroll content area */
.sub-panel-scroll {
  order: 2;
  flex: 1;
  overflow-y: scroll;
  padding: 14px 24px 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sub-panel-scroll.hidden {
  display: none;
}
.sub-panel-desc {
  font-size: 13.4px;
  line-height: 1.7;
  color: #262626;
  font-family: 'Open Sans', system-ui, sans-serif;
}
.sub-panel-desc a {
  color: #2c2c2c;
  font-style: italic;
  font-weight: 600;
  text-decoration: none;
}
.sub-panel-desc b, .sub-panel-desc strong {
  font-weight: 700;
}
.sub-panel-placeholder {
  font-size: 13px;
  color: #888;
  text-align: center;
  padding: 40px 0;
}

/* Relationships section (2D master/slave style) */
.sub-panel-relations {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(181,176,158,0.4);
  padding-bottom: 20px;
}
.sub-rel-group {
  margin-bottom: 14px;
}
.sub-rel-group:last-child {
  margin-bottom: 0;
}
.sub-rel-label {
  font-size: 11px;
  font-weight: 700;
  color: #5a5a5a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.sub-rel-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sub-rel-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  color: #2c2c2c;
  background: rgba(211,205,182,0.6);
  border: 1px solid rgba(181,176,158,0.3);
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sub-rel-tag small {
  font-weight: 400;
  font-size: 10px;
  color: #777;
  margin-left: 4px;
}
.sub-rel-tag.primary {
  background: #d3cdb6;
  border-color: #b5b09e;
}
.sub-rel-placeholder {
  font-size: 12px;
  color: #999;
  font-style: italic;
}

/* Tracks wrapper (hidden by default) */
.sub-panel-tracks-wrapper {
  order: 4;
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.sub-panel-tracks-wrapper.open {
  display: flex;
}
.sub-panel-tracks-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  -webkit-overflow-scrolling: touch;
}
.sub-track-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 6px;
  border-bottom: 1px solid rgba(181,176,158,0.2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.sub-track-item:active {
  background: rgba(211,205,182,0.4);
}
.sub-track-item.active-track {
  background: rgba(211,205,182,0.5);
}
.sub-track-seq {
  width: 24px;
  font-size: 11px;
  color: #999;
  flex-shrink: 0;
  text-align: right;
}
.sub-track-name {
  flex: 1;
  font-size: 13px;
  color: #262626;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
}
.pl-icons {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.pli {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  color: #999;
  text-decoration: none;
  opacity: 0.5;
  transition: all 0.12s;
}
.pli:hover {
  opacity: 1;
  transform: scale(1.15);
}
.pli.qq { color: #19B7EA; }
.pli.qq:hover { color: #19B7EA; }
.pli.ne { color: #D43C33; }
.pli.ne:hover { color: #D43C33; }
.pli.kg { color: #FF6600; }
.pli.kg:hover { color: #FF6600; }
.pli.yt { color: #FF0000; }
.pli.yt:hover { color: #FF0000; }
.pli.gy { opacity: 0.2; color: #ccc; cursor: default; }
.sub-track-platforms {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
  margin-right: 6px;
}
.sub-track-loading {
  font-size: 13px;
  color: #888;
  text-align: center;
  padding: 30px;
}

/* Platform bar */


/* Player container */
#sub-player-container {
  flex-shrink: 0;
  width: 100%;
  display: none;
  background: #000;
}
#sub-player-container.active {
  display: block;
  height: calc(42.86vw - 90px);
  max-height: 36vh;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
#sub-player-container .prism-big-play-btn {
  position: relative !important;
  left: 50% !important;
  bottom: auto !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}
/* Tracks handle bar */
.sub-panel-tracks-handle {
  order: 3;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  background: #d3cdb6;
  color: #262626;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  border-top: 1px solid rgba(181,176,158,0.5);
}
.sub-panel-tracks-handle:active {
  background: #ccc5ab;
}
.sub-tracks-handle-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sub-panel-tracks-handle small {
  font-weight: 400;
  font-size: 14px;
  color: #5a5a5a;
}
.sub-panel-tracks-arrow {
  font-size: 16px;
  transition: transform 0.2s ease;
}
.sub-panel-tracks-wrapper.open ~ .sub-panel-tracks-handle {
  order: 2;
  border-top: none;
  border-bottom: 1px solid rgba(181,176,158,0.5);
}

/* Parent supergenre button */
.sub-parent-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 2px 10px;
  border: none;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--pbtn, #555);
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.15s ease;
  line-height: 1.6;
}
.sub-parent-btn:active {
  filter: brightness(1.2);
}

.sg-tts-btn.playing, .sub-tts-btn.playing {
  color: #22c55e;
}

/* ─── Search Modal ─── */
.search-modal {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: none;
}
.search-modal.active { display: block; }

.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.search-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
}

.search-input {
  flex: 1;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 16px;
  font-family: system-ui, sans-serif;
  outline: none;
}
.search-input::placeholder { color: var(--color-text-muted); }

.search-close-btn {
  width: 40px; height: 40px;
  border: none; background: none;
  color: var(--color-text-muted);
  font-size: 24px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.search-sort {
  display: flex;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: none;
}

.search-sort-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  cursor: pointer;
  white-space: nowrap;
}

.search-sort-btn:nth-child(1) { flex: 1.4; }
.search-sort-btn:nth-child(2) { flex: 1; }
.search-sort-btn:nth-child(3) { width: 52px; justify-content: flex-end; }

.search-sort-btn.active {
  color: var(--color-accent);
}

.sort-arrow {
  font-size: 9px;
  opacity: 0.6;
}
.search-sort-btn.active .sort-arrow {
  opacity: 1;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: background 0.15s;
}
.search-item:active { background: rgba(255,255,255,0.08); }

.search-item-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 4px;
}

.search-item-name {
  flex: 1.4;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-sg {
  flex: 1;
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-year {
  width: 52px;
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: right;
  flex-shrink: 0;
}

.search-empty {
  padding: 32px 12px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ─── Quiz ─── */
.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: var(--color-surface);
  display: none;
  flex-direction: column;
}
.quiz-overlay.active { display: flex; }

.quiz-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.quiz-close {
  width: 36px; height: 36px;
  border: none; background: none;
  color: var(--color-text-muted);
  font-size: 24px;
  cursor: pointer;
}

.quiz-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}

.quiz-progress {
  font-size: 13px;
  color: var(--color-text-muted);
}

.quiz-player-area {
  background: var(--color-surface-raised);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}

.quiz-playing-label {
  font-size: 14px;
  color: var(--color-accent);
  margin-bottom: 8px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.quiz-play-btn {
  display: inline-block;
  padding: 8px 20px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--color-text-secondary);
  cursor: pointer;
  margin-top: 8px;
}

.quiz-question {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
}

.quiz-option:active { background: var(--color-surface-raised); }

.quiz-option.correct {
  border-color: #34c759;
  background: rgba(52,199,89,0.1);
}

.quiz-option.wrong {
  border-color: #ff3b30;
  background: rgba(255,59,48,0.1);
}

.quiz-option.disabled { pointer-events: none; opacity: 0.6; }

.quiz-option-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.quiz-feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  font-size: 14px;
  text-align: center;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.correct { background: rgba(52,199,89,0.1); color: #34c759; }
.quiz-feedback.wrong { background: rgba(255,59,48,0.1); color: #ff3b30; }

.quiz-next-btn {
  display: block;
  margin: 16px auto 0;
  padding: 10px 32px;
  border: none;
  border-radius: 20px;
  background: var(--color-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.quiz-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 16px;
}

.quiz-result-score {
  font-size: 48px;
  font-weight: 700;
  color: var(--color-accent);
}

.quiz-result-detail {
  font-size: 14px;
  color: var(--color-text-muted);
  text-align: center;
}

.quiz-retry-btn {
  padding: 12px 40px;
  border: 1.5px solid var(--color-accent);
  border-radius: 24px;
  background: transparent;
  color: var(--color-accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.sg-quiz-btn { font-size: 16px; }

.quiz-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  padding: 12px 16px;
  background: var(--color-surface-raised);
  border-radius: 10px;
  margin-bottom: 16px;
  text-align: center;
}

.quiz-result-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

.qr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.qr-item.qr-correct { color: #34c759; }
.qr-item.qr-wrong { color: #ff3b30; }
.qr-icon { font-weight: 700; width: 18px; }
.qr-answer { flex: 1; }
.qr-type { opacity: 0.5; }

.quiz-back-btn {
  padding: 12px 40px;
  border: 1.5px solid var(--color-border);
  border-radius: 24px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.auth-scores {
  padding: 12px 0;
  border-top: 1px solid var(--color-border);
  margin-bottom: 8px;
}

.auth-scores-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.auth-score-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.auth-score-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.auth-score-value {
  margin-left: auto;
  font-weight: 600;
  color: var(--color-accent);
}

.auth-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
}
.auth-badge {
  font-size: 22px;
  opacity: 0.7;
}

/* ─── User Center ─── */
.uc-stats {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 12px;
}

.uc-stat {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  background: var(--color-surface-raised);
  border-radius: 8px;
}

.uc-stat-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--color-accent);
}

.uc-stat-label {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.uc-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 8px 0 6px;
}

.uc-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
}

.uc-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--color-surface-raised);
  border-radius: 12px;
  font-size: 11px;
}

.uc-badge-icon {
  font-size: 14px;
}

.uc-badge-name {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.uc-score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.uc-score-label {
  width: 80px;
  font-size: 11px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uc-score-pct {
  width: 32px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
}

.uc-score-track {
  flex: 1;
  height: 6px;
  background: var(--color-surface-raised);
  border-radius: 3px;
  overflow: hidden;
}

.uc-score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ─── Dashboard ─── */
.dashboard {
  position: fixed;
  top: var(--topbar-height); left: 0; right: 0; bottom: 0;
  z-index: 280;
  background: var(--color-surface);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.dash-header {
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.dash-back {
  width: 60px;
  height: 36px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--color-accent);
  cursor: pointer;
}

.dash-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.dash-spacer { width: 60px; }

.dash-body {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* Stats row */
.dash-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.dash-stat {
  flex: 1;
  text-align: center;
  padding: 14px 8px;
  background: var(--color-surface-raised);
  border-radius: 10px;
}

.dash-stat-val {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--color-accent);
}

.dash-stat-lbl {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Section */
.dash-section {
  margin-bottom: 20px;
}

.dash-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
}

/* Module progress cards */
.dash-module-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--color-surface-raised);
  border-radius: 8px;
  margin-bottom: 6px;
  width: 100%;
  box-sizing: border-box;
}

.dash-module-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dash-module-name {
  width: 90px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.dash-module-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.dash-module-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.dash-module-pct {
  width: 36px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: right;
}

/* Badge grid */
.dash-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dash-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  background: var(--color-surface-raised);
  border-radius: 10px;
  min-width: 72px;
}

.dash-badge.locked {
  opacity: 0.3;
}

.dash-badge-icon {
  font-size: 22px;
}

.dash-badge-name {
  font-size: 10px;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.2;
}

.dash-badge-tip {
  position: fixed;
  z-index: 999;
  background: #1c1c1e;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 160px;
  max-width: 200px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: tipIn 0.2s ease-out;
  pointer-events: none;
}

@keyframes tipIn {
  from { opacity: 0; transform: translateY(-90%); }
  to { opacity: 1; transform: translateY(-100%); }
}

.dash-badge-tip-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}

.dash-badge-tip-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.dash-badge-tip-desc {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.dash-badge-prog { font-size: 9px; color: var(--color-text-muted); margin-top: 2px; }

.dash-badges .dash-badge.locked { display: none; }
.dash-badges.expanded .dash-badge.locked { display: flex; }

.dash-badge-group-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 10px 0 6px;
  cursor: pointer;
  user-select: none;
}

.dash-badge-row {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 8px;
}
.dash-badge-row.dash-badge-earned {
  display: flex;
}
.dash-badge-row.expanded {
  display: flex;
}


/* Remove old collapse rules */
.dash-badges .dash-badge.locked { display: flex; }

/* ─── Badge Columns ─── */
.dash-badge-columns {
  display: flex;
  gap: 6px;
}

.dash-badge-col {
  flex: 1;
  min-width: 0;
  background: var(--color-surface-raised);
  border-radius: 10px;
  padding: 10px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}
.dash-badge-col:nth-child(1) .dash-badge-col-item.earned .dash-badge-col-item-name { color: #ff9500; }
.dash-badge-col:nth-child(2) .dash-badge-col-item.earned .dash-badge-col-item-name { color: #34c759; }
.dash-badge-col:nth-child(3) .dash-badge-col-item.earned .dash-badge-col-item-name { color: #007aff; }
.dash-badge-col:nth-child(4) .dash-badge-col-item.earned .dash-badge-col-item-name { color: #af52de; }
.dash-badge-col:nth-child(5) .dash-badge-col-item.earned .dash-badge-col-item-name { color: #ff3b30; }
.dash-badge-col:nth-child(1) .dash-badge-col-top .dash-badge-col-title { color: #ff9500; }
.dash-badge-col:nth-child(2) .dash-badge-col-top .dash-badge-col-title { color: #34c759; }
.dash-badge-col:nth-child(3) .dash-badge-col-top .dash-badge-col-title { color: #007aff; }
.dash-badge-col:nth-child(4) .dash-badge-col-top .dash-badge-col-title { color: #af52de; }
.dash-badge-col:nth-child(5) .dash-badge-col-top .dash-badge-col-title { color: #ff3b30; }

.dash-badge-col.expanded {
  background: rgba(255,255,255,0.06);
}

.dash-badge-col-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.dash-badge-col-top {
  padding: 4px 0;
}

.dash-badge-col-icon {
  display: block;
  font-size: 24px;
  margin-bottom: 2px;
}

.dash-badge-col-title {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.dash-badge-col-empty .dash-badge-col-icon,
.dash-badge-col-empty .dash-badge-col-title {
  opacity: 0.3;
}

.dash-badge-col-list {
  display: none;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin-top: 4px;
}

.dash-badge-col.expanded .dash-badge-col-list {
  display: block;
}

.dash-badge-col-item {
  padding: 5px 0;
  font-size: 11px;
  text-align: center;
}

.dash-badge-col-item.locked {
  opacity: 0.3;
}

.dash-badge-col-item-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.dash-badge-col-check {
  width: 10px;
  font-size: 8px;
  color: #34c759;
  flex-shrink: 0;
}

.dash-badge-col-item-name {
  flex: 1;
  text-align: center;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-badge-col-item-prog {
  font-size: 10px;
  color: #fff;
  font-weight: 500;
  
}

.dash-badge-col-item {
  padding: 3px 0;
}
.dash-badge-col-item-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.dash-badge-col-item-prog {
  font-size: 10px;
  color: #fff;
  font-weight: 500;
  
}

/* ─── Badge Toast ─── */
.badge-toast {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  z-index: 999;
  background: #1c1c1e;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-width: 200px;
}

.badge-toast.show {
  transform: translateX(-50%) translateY(0);
}

.badge-toast-icon {
  font-size: 32px;
}

.badge-toast-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.badge-toast-title {
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
}

.badge-toast-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.badge-particle {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  z-index: 1000;
  pointer-events: none;
  animation: particleBurst 0.8s ease-out forwards;
}

@keyframes particleBurst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--px), var(--py)) scale(0); opacity: 0; }
}

.badge-toast-detail {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}
