      * {
      margin: 0;
      padding: 0;
      box-sizing: border-box
    }

    :root {
      --bg: #f5f5f0;
      --card: #fff;
      --text: #1a1a2e;
      --text2: #666;
      --primary: #4a6fa5;
      --accent: #ff8c42;
      --border: #e0e0e0;
      --shadow: 0 2px 12px rgba(0, 0, 0, .08);
      --radius: 12px
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      overflow-x: hidden
    }

    .container {
      max-width: 1200px;
      margin: 0 auto;
      padding: 16px
    }

    .header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 12px;
      flex-wrap: wrap;
      gap: 8px
    }

    h1 {
      font-size: 20px;
      font-weight: 800
    }

    .stats {
      font-size: 12px;
      color: var(--text2)
    }

    .search-row {
      display: flex;
      gap: 8px;
      margin-bottom: 12px
    }

    .search-row input {
      flex: 1;
      padding: 10px 14px;
      border: 2px solid var(--border);
      border-radius: var(--radius);
      font-size: 14px;
      outline: none
    }

    .search-row input:focus {
      border-color: var(--primary)
    }

    .sort-row {
      display: flex;
      gap: 8px;
      margin-bottom: 12px;
      align-items: center
    }

    .sort-btn {
      padding: 6px 12px;
      border-radius: 16px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      border: 2px solid var(--border);
      background: var(--card);
      transition: all .2s;
      user-select: none
    }

    .sort-btn:hover {
      border-color: var(--primary)
    }

    .sort-btn.active {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary)
    }

    .level-tabs {
      display: flex;
      gap: 6px;
      margin-bottom: 14px;
      flex-wrap: wrap
    }

    .level-tab {
      padding: 5px 12px;
      border-radius: 16px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      border: 2px solid var(--border);
      background: var(--card);
      transition: all .2s;
      user-select: none
    }

    .level-tab:hover {
      border-color: var(--primary)
    }

    .level-tab.active {
      background: var(--primary);
      color: #fff;
      border-color: var(--primary)
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      gap: 12px;
      margin-bottom: 24px
    }

    .book-card {
      background: var(--card);
      border-radius: var(--radius);
      overflow: hidden;
      cursor: pointer;
      box-shadow: var(--shadow);
      transition: transform .2s, box-shadow .2s
    }

    .book-card:hover {
      transform: translateY(-3px);
      box-shadow: 0 6px 20px rgba(0, 0, 0, .12)
    }

    .book-card:active {
      transform: translateY(-1px)
    }

    .book-card .cover {
      width: 100%;
      aspect-ratio: 3/4;
      object-fit: cover;
      display: block;
      background: #e8e8e3
    }

    .book-card .cover-ph {
      width: 100%;
      aspect-ratio: 3/4;
      display: none;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #e8e8e3, #d8d8d3);
      color: var(--text2);
      font-size: 36px
    }

    .book-card .info {
      padding: 6px 8px
    }

    .book-card .title {
      font-size: 11px;
      font-weight: 600;
      line-height: 1.3;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden
    }

    .book-card .level {
      font-size: 10px;
      color: var(--text2);
      margin-top: 2px
    }

    .reader-overlay {
      position: fixed;
      inset: 0;
      background: #000;
      z-index: 1000;
      display: none;
      flex-direction: column
    }

    .reader-overlay.active {
      display: flex
    }

    .reader-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 6px 12px;
      background: rgba(0, 0, 0, .7);
      color: #fff;
      z-index: 10;
      min-height: 44px
    }

    .reader-top button {
      background: none;
      border: none;
      color: #fff;
      font-size: 18px;
      cursor: pointer;
      padding: 4px 8px;
      min-width: 36px;
      min-height: 36px;
      display: flex;
      align-items: center;
      justify-content: center
    }

    .reader-top .page-info {
      font-size: 13px;
      font-weight: 600
    }

    .reader-top .book-title {
      font-size: 12px;
      opacity: .7;
      max-width: 40%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap
    }

    .reader-main {
      flex: 1;
      position: relative;
      overflow: hidden;
      touch-action: pan-y
    }

    .reader-scroll {
      width: 100%;
      height: 100%;
      overflow-y: auto;
      overflow-x: hidden;
      scroll-snap-type: y mandatory;
      -webkit-overflow-scrolling: touch
    }

    .page-slide {
      width: 100%;
      min-height: 100%;
      scroll-snap-align: start;
      scroll-snap-stop: always;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0
    }

    .page-slide img {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
      user-select: none;
      -webkit-user-drag: none;
      transition: opacity .2s
    }

    /* Skeleton loading for page images */
    .page-slide.loading::after {
      content: '加载中...';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: var(--text2, #888);
      font-size: 14px;
      pointer-events: none;
      animation: pulse 1.5s ease-in-out infinite;
    }
    .page-slide.loading {
      position: relative;
      background: linear-gradient(90deg, rgba(0,0,0,0.03) 25%, rgba(0,0,0,0.06) 50%, rgba(0,0,0,0.03) 75%);
      background-size: 200% 100%;
      animation: shimmer 1.5s infinite;
    }
    @keyframes shimmer {
      0% { background-position: 200% 0; }
      100% { background-position: -200% 0; }
    }
    @keyframes pulse {
      0%, 100% { opacity: 0.5; }
      50% { opacity: 1; }
    }

    .reader-main img {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
      user-select: none;
      -webkit-user-drag: none;
      transition: opacity .2s
    }

    .reader-nav {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 25%;
      z-index: 5;
      cursor: pointer;
      overscroll-behavior: contain
    }

    .reader-nav.prev {
      left: 0
    }

    .reader-nav.next {
      right: 0
    }

    .reader-bottom {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      padding: 6px 12px;
      background: rgba(0, 0, 0, .7);
      z-index: 10;
      flex-wrap: wrap;
      min-height: 44px
    }

    .audio-bar {
      display: flex;
      align-items: center;
      gap: 6px;
      color: #fff;
      padding: 3px 10px;
      background: rgba(255, 255, 255, .1);
      border-radius: 20px
    }

    .audio-bar button {
      background: none;
      border: none;
      color: #fff;
      font-size: 16px;
      cursor: pointer;
      min-width: 28px;
      min-height: 28px;
      display: flex;
      align-items: center;
      justify-content: center
    }

    .audio-bar .time {
      font-size: 10px;
      min-width: 28px;
      text-align: center
    }

    .audio-bar input[type=range] {
      width: 70px;
      height: 4px;
      accent-color: var(--accent)
    }

    .ctrl-btn {
      background: rgba(255, 255, 255, .15);
      border: none;
      color: #fff;
      padding: 5px 12px;
      border-radius: 14px;
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
      min-height: 28px;
      transition: background .2s
    }

    .ctrl-btn:hover {
      background: rgba(255, 255, 255, .25)
    }

    .ctrl-btn.active {
      background: var(--accent)
    }

    .progress-bar {
      width: 100%;
      height: 3px;
      background: rgba(255, 255, 255, .2)
    }

    .progress-bar .fill {
      height: 100%;
      background: var(--accent);
      transition: width .3s
    }

    .celebration {
      position: fixed;
      inset: 0;
      z-index: 2000;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, .85)
    }

    .celebration.active {
      display: flex
    }

    .celebration .content {
      text-align: center;
      animation: bounce .6s ease-out
    }

    .celebration .emoji {
      font-size: 64px;
      margin-bottom: 12px
    }

    .celebration .msg {
      font-size: 24px;
      font-weight: 800;
      color: #FFD700;
      text-shadow: 0 2px 8px rgba(255, 215, 0, .5);
      margin-bottom: 8px
    }

    .celebration .sub {
      font-size: 14px;
      color: rgba(255, 255, 255, .7);
      margin-bottom: 16px
    }

    .celebration button {
      background: linear-gradient(135deg, #FFD700, #FF8C00);
      border: none;
      color: #fff;
      padding: 10px 28px;
      border-radius: 20px;
      font-size: 14px;
      font-weight: 700;
      cursor: pointer
    }

    .confetti {
      position: absolute;
      top: -20px;
      width: 8px;
      height: 8px;
      opacity: 0;
      animation: fall 3s ease-in forwards
    }

    @keyframes fall {
      0% {
        transform: translateY(0) rotate(0);
        opacity: 1
      }

      100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0
      }
    }

    @keyframes bounce {
      0% {
        transform: scale(.3);
        opacity: 0
      }

      50% {
        transform: scale(1.1)
      }

      100% {
        transform: scale(1);
        opacity: 1
      }
    }

    .empty {
      text-align: center;
      padding: 40px;
      color: var(--text2)
    }

    /* ========== Reading Status Indicators ========== */
    .book-card .cover-wrap {
      position: relative;
      width: 100%;
      aspect-ratio: 3/4;
      overflow: hidden
    }

    .book-card .cover-wrap img {
      width: 100%;
      height: 100%;
      object-fit: cover
    }

    .book-card .cover-wrap.completed::after {
      content: '';
      position: absolute;
      inset: 0;
      background: rgba(255, 255, 255, .35);
      pointer-events: none;
      z-index: 3
    }

    .book-card .completed-check {
      position: absolute;
      top: 6px;
      right: 6px;
      width: 26px;
      height: 26px;
      background: #4caf50;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 6;
      box-shadow: 0 2px 6px rgba(0, 0, 0, .3)
    }

    .book-card .completed-check svg {
      width: 14px;
      height: 14px;
      fill: #fff
    }

    .book-card .reading-progress {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 4px;
      background: rgba(0, 0, 0, .15);
      z-index: 5
    }

    .book-card .reading-progress-fill {
      height: 100%;
      background: var(--accent);
      border-radius: 0 2px 2px 0;
      transition: width .3s
    }

    .book-card .reading-progress-text {
      position: absolute;
      bottom: 8px;
      right: 6px;
      font-size: 10px;
      color: #fff;
      font-weight: 600;
      background: rgba(0, 0, 0, .5);
      padding: 1px 6px;
      border-radius: 3px;
      z-index: 5
    }

    /* ========== Nav Actions ========== */
    .nav-actions {
      display: flex;
      align-items: center;
      gap: 6px
    }

    .nav-btn {
      background: rgba(255, 255, 255, .15);
      border: none;
      color: var(--text);
      padding: 5px 10px;
      border-radius: 8px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 4px;
      transition: all .2s
    }

    .nav-btn:hover {
      background: rgba(0, 0, 0, .08)
    }

    .nav-btn svg {
      width: 16px;
      height: 16px;
      fill: currentColor
    }

    /* ========== Key Verification Overlay ========== */
    .key-overlay {
      position: fixed;
      inset: 0;
      z-index: 5000;
      background: linear-gradient(135deg, #0f1b2d, #1b3a5c);
      display: none;
      overflow-y: auto;
      overflow-x: hidden;
      scroll-snap-type: y mandatory;
      -webkit-overflow-scrolling: touch
    }

    .key-overlay.open {
      display: block
    }

    .key-page {
      height: 100vh;
      scroll-snap-align: start;
      scroll-snap-stop: always;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 40px 0;
      overflow-y: auto
    }

    .key-card {
      background: #fff;
      border-radius: 16px;
      padding: 36px;
      max-width: 400px;
      width: 90%;
      text-align: center;
      box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
      flex-shrink: 0
    }

    .key-card h2 {
      font-size: 22px;
      color: var(--primary);
      margin-bottom: 8px
    }

    .key-card .key-sub {
      font-size: 13px;
      color: #777;
      margin-bottom: 20px
    }

    .key-card .device-section {
      background: #f0f4f8;
      border-radius: 10px;
      padding: 12px;
      margin-bottom: 20px
    }

    .key-card .device-label {
      font-size: 11px;
      color: #777;
      margin-bottom: 4px
    }

    .key-card .device-value {
      font-size: 26px;
      font-weight: 800;
      color: var(--primary);
      letter-spacing: 6px;
      font-family: 'Courier New', monospace
    }

    .key-card .key-input {
      width: 100%;
      padding: 12px 14px;
      font-size: 20px;
      font-weight: 700;
      text-align: center;
      letter-spacing: 4px;
      text-transform: uppercase;
      border: 2px solid var(--border);
      border-radius: 10px;
      font-family: 'Courier New', monospace;
      outline: none;
      transition: border-color .2s
    }

    .key-card .key-input:focus {
      border-color: var(--primary)
    }

    .key-card .key-input.error {
      border-color: #e53e3e;
      animation: shake .4s
    }

    @keyframes shake {

      0%,
      100% {
        transform: translateX(0)
      }

      25% {
        transform: translateX(-8px)
      }

      75% {
        transform: translateX(8px)
      }
    }

    .key-card .key-error {
      color: #e53e3e;
      font-size: 12px;
      margin-top: 8px;
      min-height: 18px
    }

    .key-card .key-submit {
      width: 100%;
      padding: 12px;
      margin-top: 14px;
      background: linear-gradient(135deg, var(--primary), #2a5f8f);
      color: #fff;
      font-size: 15px;
      font-weight: 700;
      border-radius: 10px;
      border: none;
      cursor: pointer;
      transition: transform .2s, box-shadow .2s
    }

    .key-card .key-submit:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(74, 111, 165, .4)
    }

    /* ========== Preview Section (inside key-overlay) ========== */
    .scroll-hint {
      text-align: center;
      color: rgba(255, 255, 255, .5);
      font-size: 13px;
      padding: 16px 0 8px;
      flex-shrink: 0;
      animation: hintBounce 2s ease-in-out infinite
    }

    @keyframes hintBounce {
      0%, 100% { transform: translateY(0) }
      50% { transform: translateY(6px) }
    }

    .scroll-hint svg {
      display: inline-block;
      vertical-align: middle;
      margin-right: 4px
    }

    .preview-section {
      width: 100%;
      max-width: 900px;
      padding: 0 16px;
      display: flex;
      flex-direction: column;
      align-items: center;
      user-select: none
    }

    .preview-section h3 {
      color: #fff;
      font-size: 22px;
      margin-bottom: 4px;
      text-shadow: 0 2px 8px rgba(0,0,0,.3)
    }

    .preview-section .preview-sub {
      color: rgba(255, 255, 255, .6);
      font-size: 13px;
      margin-bottom: 24px
    }

    .carousel-wrap {
      position: relative;
      width: 100%;
      height: 420px;
      perspective: 1400px;
      overflow: hidden
    }

    .carousel-track {
      position: absolute;
      top: 50%;
      left: 50%;
      transform-style: preserve-3d;
      transition: transform .5s cubic-bezier(.25,.1,.25,1)
    }

    .carousel-item {
      position: absolute;
      width: 240px;
      height: 320px;
      border-radius: 14px;
      overflow: hidden;
      cursor: pointer;
      transition: transform .5s cubic-bezier(.25,.1,.25,1), opacity .5s ease, box-shadow .5s ease;
      box-shadow: 0 12px 40px rgba(0,0,0,.5);
      backface-visibility: hidden
    }

    .carousel-item img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block
    }

    .carousel-item .preview-badge {
      position: absolute;
      top: 6px;
      right: 6px;
      background: var(--accent);
      color: #fff;
      font-size: 10px;
      font-weight: 700;
      padding: 3px 8px;
      border-radius: 6px;
      white-space: nowrap;
      box-shadow: 0 2px 6px rgba(0,0,0,.3)
    }

    .carousel-item .preview-info {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 8px 10px;
      background: linear-gradient(transparent, rgba(0,0,0,.8));
      color: #fff
    }

    .carousel-item .preview-title {
      font-size: 13px;
      font-weight: 600;
      line-height: 1.3;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    .carousel-item .preview-level {
      font-size: 11px;
      opacity: .7
    }

    .carousel-dots {
      display: flex;
      gap: 8px;
      margin-top: 16px;
      justify-content: center
    }

    .carousel-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: rgba(255,255,255,.3);
      cursor: pointer;
      transition: all .3s
    }

    .carousel-dot.active {
      background: #fff;
      transform: scale(1.3)
    }

    /* ========== Reading Limit Overlay ========== */
    .limit-overlay {
      position: absolute;
      inset: 0;
      z-index: 20;
      background: rgba(0, 0, 0, .75);
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      backdrop-filter: blur(4px)
    }

    .limit-overlay.open {
      display: flex
    }

    .limit-card {
      background: #fff;
      border-radius: 16px;
      padding: 36px;
      max-width: 400px;
      width: 90%;
      text-align: center;
      box-shadow: 0 20px 60px rgba(0, 0, 0, .5)
    }

    .limit-card h2 {
      font-size: 22px;
      color: var(--primary);
      margin-bottom: 8px
    }

    .limit-card .limit-sub {
      font-size: 14px;
      color: #777;
      margin-bottom: 16px
    }

    .limit-card .device-section {
      margin-bottom: 16px
    }

    .limit-card .device-label {
      font-size: 12px;
      color: #999;
      margin-bottom: 4px
    }

    .limit-card .device-value {
      font-family: 'Courier New', monospace;
      font-size: 18px;
      font-weight: 700;
      color: var(--primary);
      letter-spacing: 2px;
      background: #f5f7fa;
      padding: 8px 12px;
      border-radius: 8px;
      margin-bottom: 12px
    }

    .limit-card .key-input {
      width: 100%;
      padding: 12px;
      border: 2px solid #ddd;
      border-radius: 10px;
      font-size: 18px;
      text-align: center;
      letter-spacing: 4px;
      font-weight: 600;
      outline: none;
      transition: border-color .2s;
      box-sizing: border-box
    }

    .limit-card .key-input:focus {
      border-color: var(--primary)
    }

    .limit-card .key-error {
      color: #e74c3c;
      font-size: 13px;
      min-height: 20px;
      margin-top: 6px
    }

    .limit-card .key-submit {
      width: 100%;
      padding: 12px;
      background: var(--primary);
      color: #fff;
      border: none;
      border-radius: 10px;
      font-size: 16px;
      font-weight: 600;
      cursor: pointer;
      margin-top: 8px;
      transition: transform .1s, box-shadow .2s
    }

    .limit-card .key-submit:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(74, 111, 165, .4)
    }

    .limit-card .limit-close {
      background: none;
      border: none;
      color: #999;
      font-size: 13px;
      cursor: pointer;
      margin-top: 12px
    }

    /* ========== Name Input Overlay ========== */
    .name-overlay {
      position: fixed;
      inset: 0;
      z-index: 5000;
      background: linear-gradient(135deg, #0f1b2d, #1b3a5c);
      display: none;
      align-items: center;
      justify-content: center
    }

    .name-overlay.open {
      display: flex
    }

    .name-card {
      background: #fff;
      border-radius: 16px;
      padding: 36px;
      max-width: 400px;
      width: 90%;
      text-align: center;
      box-shadow: 0 20px 60px rgba(0, 0, 0, .4)
    }

    .name-card h2 {
      font-size: 22px;
      color: var(--primary);
      margin-bottom: 8px
    }

    .name-card .name-sub {
      font-size: 13px;
      color: #777;
      margin-bottom: 20px
    }

    .name-card .name-input {
      width: 100%;
      padding: 12px 14px;
      font-size: 18px;
      font-weight: 600;
      text-align: center;
      border: 2px solid var(--border);
      border-radius: 10px;
      outline: none;
      transition: border-color .2s
    }

    .name-card .name-input:focus {
      border-color: var(--primary)
    }

    .name-card .name-submit {
      width: 100%;
      padding: 12px;
      margin-top: 14px;
      background: linear-gradient(135deg, #4caf50, #388e3c);
      color: #fff;
      font-size: 15px;
      font-weight: 700;
      border-radius: 10px;
      border: none;
      cursor: pointer;
      transition: transform .2s, box-shadow .2s
    }

    .name-card .name-submit:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(76, 175, 80, .4)
    }

    /* ========== Achievement Overlay ========== */
    .ach-overlay {
      position: fixed;
      inset: 0;
      z-index: 3000;
      background: rgba(0, 0, 0, .7);
      display: none;
      align-items: flex-start;
      justify-content: center;
      overflow-y: auto;
      padding: 40px 16px;
      backdrop-filter: blur(4px)
    }

    .ach-overlay.open {
      display: flex
    }

    .ach-content {
      background: #fff;
      border-radius: 16px;
      max-width: 780px;
      width: 100%;
      padding: 28px;
      box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
      animation: fadeInUp .3s ease
    }

    @keyframes fadeInUp {
      from {
        opacity: 0;
        transform: translateY(20px)
      }

      to {
        opacity: 1;
        transform: translateY(0)
      }
    }

    .ach-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 20px
    }

    .ach-header h2 {
      font-size: 24px;
      font-weight: 800;
      background: linear-gradient(135deg, #FF6B6B, #FFD93D, #6BCB77, #4D96FF);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text
    }

    .ach-close {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: #f0f0f0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      color: #666;
      border: none;
      cursor: pointer;
      transition: all .2s
    }

    .ach-close:hover {
      background: #e0e0e0
    }

    .ach-summary {
      display: flex;
      gap: 16px;
      margin-bottom: 24px;
      justify-content: center
    }

    .ach-summary .stat {
      background: linear-gradient(135deg, #f0f4f8, #e8edf3);
      border-radius: 12px;
      padding: 12px 20px;
      text-align: center;
      min-width: 100px
    }

    .ach-summary .stat-val {
      font-size: 24px;
      font-weight: 800;
      color: var(--primary)
    }

    .ach-summary .stat-lbl {
      font-size: 11px;
      color: #777;
      margin-top: 2px
    }

    .ach-section {
      margin-bottom: 24px
    }

    .ach-section-title {
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 12px;
      padding-bottom: 6px;
      border-bottom: 2px solid var(--border);
      display: flex;
      align-items: center;
      gap: 6px
    }

    .ach-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
      gap: 10px
    }

    .badge {
      border-radius: 12px;
      padding: 12px 6px;
      text-align: center;
      transition: transform .2s;
      position: relative
    }

    .badge:hover {
      transform: translateY(-2px)
    }

    .badge.locked {
      background: #e8e8e8;
      opacity: .6
    }

    .badge.unlocked {
      box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
      animation: badgeGlow 2s ease-in-out infinite alternate
    }

    @keyframes badgeGlow {
      from {
        box-shadow: 0 4px 16px rgba(0, 0, 0, .15)
      }

      to {
        box-shadow: 0 4px 24px rgba(0, 0, 0, .25)
      }
    }

    .badge .badge-icon {
      width: 46px;
      height: 46px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 22px;
      margin: 0 auto 6px
    }

    .badge.locked .badge-icon {
      background: #ccc
    }

    .badge .badge-name {
      font-size: 11px;
      font-weight: 700;
      line-height: 1.2;
      margin-bottom: 2px
    }

    .badge.locked .badge-name {
      color: #999
    }

    .badge.unlocked .badge-name {
      color: var(--text)
    }

    .badge .badge-desc {
      font-size: 9px;
      color: #777;
      line-height: 1.2
    }

    .badge .badge-date {
      font-size: 9px;
      color: #4caf50;
      margin-top: 3px;
      font-weight: 600
    }

    /* ========== Init Confirm Overlay ========== */
    .init-overlay {
      position: fixed;
      inset: 0;
      z-index: 20000;
      background: rgba(0, 0, 0, .6);
      display: none;
      align-items: center;
      justify-content: center;
      backdrop-filter: blur(4px)
    }

    .init-overlay.open {
      display: flex
    }

    .init-card {
      background: #fff;
      border-radius: 16px;
      padding: 28px;
      max-width: 380px;
      width: 90%;
      text-align: center;
      box-shadow: 0 20px 60px rgba(0, 0, 0, .3)
    }

    .init-card h3 {
      font-size: 18px;
      color: var(--text);
      margin-bottom: 10px
    }

    .init-card .init-msg {
      font-size: 13px;
      color: #777;
      margin-bottom: 6px;
      line-height: 1.6
    }

    .init-card .init-warn {
      font-size: 11px;
      color: #e53e3e;
      margin-bottom: 18px
    }

    .init-card .init-btns {
      display: flex;
      gap: 10px
    }

    .init-card .init-btn {
      flex: 1;
      padding: 10px;
      border-radius: 10px;
      font-weight: 700;
      font-size: 14px;
      border: none;
      cursor: pointer;
      transition: all .2s
    }

    .init-card .init-cancel {
      background: #f0f0f0;
      color: #666
    }

    .init-card .init-cancel:hover {
      background: #e0e0e0
    }

    .init-card .init-confirm {
      background: #e53e3e;
      color: #fff
    }

    .init-card .init-confirm:hover {
      background: #c53030
    }

    /* ========== Achievement Toast ========== */
    .ach-toast {
      position: fixed;
      top: 70px;
      left: 50%;
      transform: translateX(-50%);
      background: linear-gradient(135deg, #FFD700, #FFA000);
      color: #333;
      padding: 12px 24px;
      border-radius: 14px;
      font-weight: 700;
      z-index: 3500;
      box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
      animation: toastIn .5s ease, toastOut .5s ease 2.5s forwards;
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 14px
    }

    @keyframes toastIn {
      from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px)
      }

      to {
        opacity: 1;
        transform: translateX(-50%) translateY(0)
      }
    }

    @keyframes toastOut {
      from {
        opacity: 1;
        transform: translateX(-50%) translateY(0)
      }

      to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px)
      }
    }

    @media(max-width:600px) {
      .grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px
      }

      .book-card .title {
        font-size: 10px
      }

      .book-card .level {
        font-size: 9px
      }

      .audio-bar input[type=range] {
        width: 50px
      }

      h1 {
        font-size: 17px
      }

      .header {
        flex-direction: column;
        align-items: flex-start
      }

      .reader-top .book-title {
        max-width: 30%
      }
    }

    @media(min-width:1200px) {
      .grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
      }
    }

/* ========== Quiz Styles ========== */
.quiz-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.quiz-overlay.active {
  display: flex;
}
.quiz-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.quiz-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.quiz-back {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
}
.quiz-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quiz-nav {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.quiz-nav::-webkit-scrollbar { display: none; }
.quiz-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.quiz-dot.current {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.quiz-dot.answered {
  border-color: var(--primary);
  background: var(--primary-container, #e3e8f0);
  color: var(--primary);
}
.quiz-dot.correct {
  border-color: #4CAF50;
  background: #E8F5E9;
  color: #4CAF50;
}
.quiz-dot.wrong {
  border-color: #D32F2F;
  background: #FFEBEE;
  color: #D32F2F;
}
.quiz-dot.redone {
  border-color: #FF9800;
  background: #FFF3E0;
  color: #FF9800;
}
.quiz-summary {
  margin: 8px 16px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  flex-shrink: 0;
}
.quiz-summary.perfect {
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #A5D6A7;
}
.quiz-summary.has-wrong {
  background: #FFF8E1;
  color: #F57F17;
  border: 1px solid #FFE082;
}
.quiz-warning {
  margin: 8px 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #EF9A9A;
  font-size: 14px;
  flex-shrink: 0;
}
.quiz-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.quiz-question-num {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.quiz-question-num .q-icon {
  font-size: 16px;
}
.quiz-question-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.5;
}
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-container-low, #f5f5f5);
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-option:active {
  transform: scale(0.98);
}
.quiz-option.selected {
  border-color: var(--primary);
  background: rgba(74, 111, 165, 0.1);
}
.quiz-option.correct-opt {
  border-color: #4CAF50;
  background: #E8F5E9;
}
.quiz-option.wrong-opt {
  border-color: #D32F2F;
  background: #FFEBEE;
}
.quiz-option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  flex-shrink: 0;
}
.quiz-option.selected .quiz-option-letter {
  background: var(--primary);
  color: #fff;
}
.quiz-option.correct-opt .quiz-option-letter {
  background: #4CAF50;
  color: #fff;
}
.quiz-option.wrong-opt .quiz-option-letter {
  background: #D32F2F;
  color: #fff;
}
.quiz-option-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
  padding-top: 3px;
  flex: 1;
}
.quiz-option-icon {
  font-size: 18px;
  flex-shrink: 0;
  padding-top: 3px;
}
.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 8px;
}
.quiz-nav-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.quiz-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.quiz-submit-btn {
  padding: 8px 24px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.quiz-redo-btn {
  padding: 8px 24px;
  border-radius: 8px;
  border: none;
  background: #FF9800;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.quiz-back-btn {
  padding: 8px 24px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
/* Celebration quiz button */
.celeb-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}
.celeb-btn {
  padding: 12px 32px;
  border-radius: 24px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  min-width: 160px;
}
.celeb-quiz {
  background: #FFD700;
  color: #333;
}
/* Quiz star badge on book card */
.book-card .quiz-star {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* ========== Profile Overlay ========== */
.profile-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: none;
  overflow-y: auto;
}
.profile-overlay.active { display: block; }
.profile-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 32px;
}
.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 1;
}
.profile-header h2 { font-size: 18px; }
.profile-back {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
}
.profile-body { padding: 16px; }
.profile-greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}
.profile-stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.profile-stat-card {
  flex: 1;
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
}
.profile-stat-card .stat-icon { font-size: 28px; margin-bottom: 6px; }
.profile-stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--primary); }
.profile-stat-card .stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; }
.profile-progress-section { margin-bottom: 20px; }
.profile-progress-label { font-size: 14px; color: var(--text2); margin-bottom: 6px; }
.profile-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.profile-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}
.profile-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.profile-ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.profile-ach-card {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.profile-ach-card:hover { transform: scale(1.03); }
.profile-ach-card.unlocked { border-color: transparent; }
.profile-ach-card .ach-icon { font-size: 22px; margin-bottom: 4px; }
.profile-ach-card .ach-name { font-size: 11px; font-weight: 600; color: var(--text); line-height: 1.3; }
.profile-ach-card .ach-desc { font-size: 9px; color: var(--text2); line-height: 1.2; margin-top: 1px; opacity: 0.8; }
.profile-ach-card.locked .ach-icon { opacity: 0.3; }
.profile-ach-card.locked .ach-name { opacity: 0.4; }
.profile-ach-card.locked .ach-desc { opacity: 0.3; }
.profile-ach-card .ach-date { font-size: 9px; color: var(--text2); margin-top: 2px; opacity: 0.7; }

/* ========== Theme Dialog ========== */
.theme-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
}
.theme-dialog-overlay.active { display: flex; }
.theme-dialog {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  min-width: 280px;
  max-width: 90vw;
}
.theme-dialog h3 { font-size: 18px; margin-bottom: 16px; text-align: center; }
.theme-options { display: flex; flex-direction: column; gap: 10px; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}
.theme-option:hover { border-color: var(--primary); }
.theme-option.active { border-color: var(--primary); background: rgba(74,111,165,0.08); }
.theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0,0,0,0.1);
}
.theme-option-info { flex: 1; }
.theme-option-name { font-size: 15px; font-weight: 600; color: var(--text); }
.theme-option-desc { font-size: 12px; color: var(--text2); }
.theme-option-check { font-size: 18px; color: var(--primary); }

/* ========== Theme Variants ========== */
[data-theme="ocean"] {
  --bg: #f0f4f8;
  --card: #fff;
  --text: #1a2332;
  --text2: #5a6a7e;
  --primary: #3B82F6;
  --accent: #06B6D4;
  --border: #d1d9e6;
  --shadow: 0 2px 12px rgba(59,130,246,.08);
}
[data-theme="forest"] {
  --bg: #f0f5f0;
  --card: #fff;
  --text: #1a2e1a;
  --text2: #5a7a5a;
  --primary: #22C55E;
  --accent: #A78BFA;
  --border: #c8dcc8;
  --shadow: 0 2px 12px rgba(34,197,94,.08);
}
[data-theme="coral"] {
  --bg: #f5f0f0;
  --card: #fff;
  --text: #2e1a1a;
  --text2: #7a5a5a;
  --primary: #FF6B6B;
  --accent: #4ECDC4;
  --border: #e6d1d1;
  --shadow: 0 2px 12px rgba(255,107,107,.08);
}