:root {
      --bg: #f3f6fb;
      --paper: #fffef9;
      --ink: #1f2937;
      --muted: #64748b;
      --line: #d9e2ec;
      --brand: #0f766e;
      --brand-soft: #ecfdf5;
      --accent: #c2410c;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: "Noto Serif TC", "PingFang TC", "Noto Sans TC", sans-serif;
      color: var(--ink);
      background:
        radial-gradient(circle at 8% 0, #fff3dd 0, transparent 40%),
        radial-gradient(circle at 94% 4%, #dcfce7 0, transparent 36%),
        var(--bg);
    }
    body.focus-mode .left,
    body.focus-mode .right { display: none; }
    body.focus-mode .layout { grid-template-columns: 1fr; }

    .top {
      position: sticky;
      top: 0;
      z-index: 40;
      border-bottom: 1px solid var(--line);
      background: #fffffff0;
      backdrop-filter: blur(8px);
    }
    .topin {
      max-width: 1380px;
      margin: 0 auto;
      padding: 10px 14px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
    }
    .brand { font-weight: 700; color: var(--brand); letter-spacing: .2px; }
    .sub { font-size: 12px; color: var(--muted); }
    .head-actions { display: flex; gap: 8px; align-items: center; }

    .btn {
      display: inline-block;
      border: 1px solid var(--line);
      background: #fff;
      color: #0f172a;
      text-decoration: none;
      border-radius: 8px;
      padding: 6px 10px;
      font-size: 13px;
      cursor: pointer;
    }
    .btn.main {
      border-color: #0f766e;
      background: #0f766e;
      color: #fff;
    }

    .layout {
      max-width: 1380px;
      margin: 12px auto;
      padding: 0 12px;
      display: grid;
      grid-template-columns: 330px 1fr 300px;
      gap: 12px;
    }
    .panel {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: var(--paper);
      box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
    }

    .left {
      padding: 12px;
      align-self: stretch;
    }
    .left h3 { margin: 4px 0 8px; color: var(--brand); font-size: 18px; }
    .left .hint { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
    .search {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 10px 11px;
      font-size: 14px;
      outline: none;
      margin-bottom: 10px;
      background: #fff;
    }
    .search:focus { border-color: #94d5cc; box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
    .group-title {
      margin: 12px 0 6px;
      font-size: 12px;
      color: #475569;
      letter-spacing: .2px;
      border-left: 3px solid #94a3b8;
      padding-left: 8px;
      font-weight: 700;
    }
    .toc-item {
      width: 100%;
      border: 1px solid #e6edf5;
      background: #fff;
      text-align: left;
      border-radius: 10px;
      padding: 10px 11px;
      margin-bottom: 7px;
      cursor: pointer;
      font-size: 14px;
      color: #334155;
      line-height: 1.45;
    }
    .toc-item:hover { background: #f8fafc; }
    .toc-item.active {
      background: var(--brand-soft);
      border-color: #9de7cf;
      color: #065f46;
    }
    .toc-item small {
      display: block;
      font-size: 12px;
      color: #64748b;
      margin-top: 3px;
    }
    .toc-row {
      display: flex;
      align-items: center;
      gap: 7px;
    }
    .dot {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      background: #cbd5e1;
      flex: none;
    }
    .dot.read { background: #16a34a; }

    .center {
      display: flex;
      flex-direction: column;
      gap: 10px;
      min-width: 0;
    }
    .guide-box {
      border: 1px solid #d7e7df;
      border-radius: 12px;
      background: linear-gradient(120deg, #f0fdf4, #fff7ed);
      padding: 12px;
    }
    .guide-box h4 {
      margin: 0 0 6px;
      font-size: 16px;
      color: #065f46;
    }
    .guide-box p {
      margin: 0 0 8px;
      font-size: 13px;
      color: #475569;
      line-height: 1.75;
    }
    .guide-actions { display: flex; gap: 8px; flex-wrap: wrap; }

    .meta {
      border: 1px solid var(--line);
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
      padding: 10px 12px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
    }
    .name-wrap { min-width: 0; }
    .name {
      font-size: 15px;
      font-weight: 700;
      color: #0f172a;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .subname {
      font-size: 12px;
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .actions { display: flex; gap: 6px; flex-wrap: wrap; }
    .page-badge {
      display: inline-block;
      border: 1px solid #c7d2fe;
      background: #eef2ff;
      color: #3730a3;
      border-radius: 999px;
      padding: 2px 9px;
      font-size: 12px;
      margin-top: 4px;
    }
    .viewer-wrap {
      position: relative;
      flex: 1;
      min-height: 380px;
    }
    .viewer {
      width: 100%;
      height: 100%;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
      overflow: auto;
      padding: 12px;
    }
    .viewer .doc {
      margin: 0;
      border: 0;
      box-shadow: none;
      border-radius: 0;
      padding: 14px 16px 20px;
      line-height: 1.9;
      color: #1f2937;
      background: #fff;
    }
    .viewer .doc h1,
    .viewer .doc h2,
    .viewer .doc h3 {
      color: var(--brand);
    }
    .viewer .doc h2 {
      border-bottom: 1px solid #e6edf5;
      padding-bottom: 6px;
      margin-top: 20px;
    }
    .viewer .doc table {
      border-collapse: collapse;
      width: 100%;
      margin: 12px 0 18px;
      font-size: 0.94em;
    }
    .viewer .doc th,
    .viewer .doc td {
      border: 1px solid #d6e0ea;
      padding: 10px 12px;
      text-align: left;
      vertical-align: top;
    }
    .viewer .doc th {
      background: #f5f8fc;
    }
    .viewer .doc tr:nth-child(even) td {
      background: #fbfdff;
    }
    .viewer .doc .toc {
      background: #f6fffd;
      border: 1px solid #cfe9e4;
      border-radius: 12px;
      padding: 12px 14px;
      margin: 14px 0;
    }
    .chapter-flash {
      position: absolute;
      inset: 0;
      display: grid;
      place-items: center;
      border-radius: 12px;
      border: 1px solid #e2e8f0;
      background: linear-gradient(120deg, #f0fdf4, #eff6ff);
      opacity: 0;
      pointer-events: none;
      transform: scale(.985);
      transition: opacity .35s ease, transform .35s ease;
    }
    .chapter-flash.show {
      opacity: 1;
      transform: scale(1);
    }
    .flash-inner {
      text-align: center;
      color: #0f172a;
      padding: 20px;
    }
    .flash-kicker {
      font-size: 12px;
      color: #0f766e;
      margin-bottom: 6px;
      letter-spacing: .3px;
    }
    .flash-title {
      font-size: 24px;
      font-weight: 700;
      line-height: 1.4;
    }
    .flash-sub {
      margin-top: 8px;
      font-size: 14px;
      color: #475569;
    }

    .right {
      padding: 12px;
      align-self: stretch;
    }
    .block { margin-bottom: 14px; }
    .right h4 { margin: 4px 0 7px; color: var(--accent); font-size: 15px; }
    .right p { margin: 8px 0; font-size: 14px; color: #475569; line-height: 1.7; }
    .plain-box {
      border: 1px solid #dbeafe;
      background: #f8fbff;
      border-radius: 10px;
      padding: 10px;
      font-size: 13px;
      color: #334155;
      line-height: 1.8;
      white-space: pre-line;
    }
    .visual-card {
      border: 1px solid #dbeafe;
      background: #ffffff;
      border-radius: 12px;
      overflow: hidden;
    }
    .visual-card img {
      width: 100%;
      display: block;
      background: #f8fafc;
      border-bottom: 1px solid #e2e8f0;
    }
    .visual-body {
      padding: 9px 10px;
    }
    .visual-title {
      margin: 0 0 4px;
      font-size: 13px;
      color: #0f172a;
      font-weight: 700;
    }
    .visual-desc {
      margin: 0;
      font-size: 12px;
      color: #475569;
      line-height: 1.7;
      white-space: pre-line;
    }
    .visual-link {
      display: inline-block;
      margin-top: 7px;
      color: #0b63b6;
      font-size: 12px;
      text-decoration: none;
    }
    .visual-link:hover { text-decoration: underline; }
    .extras-card .visual-body {
      padding: 10px;
      border-top: 1px dashed #dbe7f5;
    }
    .extras-section {
      margin-top: 10px;
      padding-top: 8px;
      border-top: 1px dashed #dbe7f5;
    }
    .extras-list {
      margin: 6px 0 0 18px;
      padding: 0;
      color: #475569;
      font-size: 12px;
      line-height: 1.7;
    }
    .extras-list li {
      margin: 4px 0;
    }
    .extras-preview {
      margin-top: 8px;
    }
    .extras-preview a {
      display: block;
      margin-top: 8px;
    }
    .extras-preview img {
      width: 100%;
      display: block;
      border: 1px solid #d8e1eb;
      border-radius: 8px;
      background: #fff;
    }
    .plain-switch {
      display: flex;
      gap: 6px;
      margin-bottom: 8px;
    }
    .plain-btn {
      border: 1px solid #cbd5e1;
      background: #fff;
      border-radius: 999px;
      padding: 4px 10px;
      font-size: 12px;
      color: #334155;
      cursor: pointer;
    }
    .plain-btn.active {
      border-color: #0f766e;
      background: #ecfdf5;
      color: #065f46;
      font-weight: 700;
    }
    .chip {
      display: inline-block;
      border: 1px solid #f1c27d;
      background: #fff7ed;
      color: #9a3412;
      border-radius: 999px;
      padding: 2px 8px;
      font-size: 12px;
      margin-right: 6px;
      margin-bottom: 6px;
    }
    .tag {
      display: inline-block;
      border: 1px solid #bfdbfe;
      background: #eff6ff;
      color: #1d4ed8;
      border-radius: 999px;
      padding: 2px 8px;
      font-size: 12px;
      margin: 0 6px 6px 0;
    }
    .progress { margin: 8px 0 10px; }
    .progress .bar {
      height: 10px;
      background: #eef2f7;
      border-radius: 999px;
      overflow: hidden;
      border: 1px solid #dde6f1;
    }
    .progress .fill {
      height: 100%;
      width: 0;
      background: linear-gradient(90deg, #0f766e, #14b8a6);
    }
    .links a {
      display: block;
      margin: 6px 0;
      color: #0b63b6;
      text-decoration: none;
    }
    .links a:hover { text-decoration: underline; }
    .range {
      width: 100%;
      accent-color: #0f766e;
    }
    .small {
      font-size: 12px;
      color: var(--muted);
      margin-top: 6px;
    }
    .book-foot {
      border: 1px dashed #cbd5e1;
      border-radius: 10px;
      padding: 8px 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: #475569;
      font-size: 12px;
      background: #fff;
    }
    .book-foot-title {
      display: flex;
      align-items: center;
      min-height: 30px;
      font-size: 12px;
      line-height: 1.2;
      color: #475569;
    }
    .book-foot .page {
      display: inline-flex;
      align-items: center;
      min-height: 30px;
      font-variant-numeric: tabular-nums;
      color: #0f766e;
      font-weight: 700;
      font-size: 12px;
    }
    .book-foot-actions {
      display: flex;
      align-items: center;
      gap: 0;
    }
    .book-foot-actions .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 30px;
      padding: 4px 10px;
      font-size: 12px;
      border-radius: 0;
      margin: 0;
    }
    .book-foot-actions .btn:first-of-type {
      border-top-left-radius: 8px;
      border-bottom-left-radius: 8px;
    }
    .book-foot-actions .btn:last-of-type {
      border-top-right-radius: 8px;
      border-bottom-right-radius: 8px;
      border-left: 0;
    }
    .mobile-progress {
      display: none;
      position: fixed;
      left: 10px;
      right: 10px;
      bottom: calc(10px + env(safe-area-inset-bottom));
      z-index: 55;
      border: 1px solid #d7e1ef;
      border-radius: 999px;
      background: rgba(255, 255, 255, .96);
      box-shadow: 0 8px 20px rgba(15, 23, 42, .12);
      overflow: hidden;
    }
    .mobile-progress .mobile-progress-fill {
      height: 8px;
      width: 0;
      background: linear-gradient(90deg, #0f766e, #14b8a6);
      transition: width .15s linear;
    }
    .mobile-progress .mobile-progress-text {
      display: block;
      padding: 4px 10px;
      font-size: 11px;
      color: #334155;
      text-align: center;
      font-variant-numeric: tabular-nums;
    }
    .chapter-gallery {
      border: 1px solid #dbe7f5;
      border-radius: 12px;
      background: #ffffff;
      padding: 12px;
    }
    .chapter-gallery h3 {
      margin: 0 0 8px;
      font-size: 16px;
      color: #0f172a;
    }
    .chapter-gallery .note {
      margin: 0 0 10px;
      font-size: 13px;
      color: #475569;
      line-height: 1.7;
    }
    .gallery-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .gallery-item {
      border: 1px solid #e2e8f0;
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }
    .gallery-item img {
      width: 100%;
      display: block;
      border-bottom: 1px solid #e2e8f0;
      background: #f8fafc;
    }
    .gallery-body {
      padding: 8px 9px;
    }
    .gallery-body p {
      margin: 0;
      font-size: 12px;
      line-height: 1.65;
      color: #334155;
      white-space: pre-line;
    }
    .gallery-body a {
      display: inline-block;
      margin-top: 6px;
      font-size: 12px;
      color: #0b63b6;
      text-decoration: none;
    }
    .gallery-body a:hover { text-decoration: underline; }
    #chapterTrail {
      list-style: none;
      padding: 0;
      margin: 8px 0 0;
      font-size: 13px;
      color: #475569;
    }
    #chapterTrail li { margin: 5px 0; }
    .cover {
      position: fixed;
      inset: 0;
      z-index: 80;
      display: none;
      place-items: center;
      background:
        radial-gradient(circle at 20% 12%, rgba(16,185,129,.2), transparent 36%),
        radial-gradient(circle at 78% 20%, rgba(245,158,11,.25), transparent 40%),
        rgba(15, 23, 42, .78);
      padding: 14px;
    }
    .cover.show { display: grid; }
    .cover-card {
      width: min(860px, 96vw);
      border: 1px solid rgba(255,255,255,.3);
      border-radius: 20px;
      background: linear-gradient(120deg, #fffef9, #f8fafc);
      box-shadow: 0 18px 56px rgba(2, 6, 23, .4);
      overflow: hidden;
    }
    .cover-top {
      padding: 22px 22px 16px;
      background:
        radial-gradient(circle at 90% 0, rgba(16,185,129,.18), transparent 45%),
        radial-gradient(circle at 10% 90%, rgba(245,158,11,.2), transparent 45%);
      border-bottom: 1px solid #e2e8f0;
    }
    .cover-kicker {
      font-size: 12px;
      color: #0f766e;
      letter-spacing: .4px;
    }
    .cover-title {
      margin-top: 8px;
      font-size: 34px;
      line-height: 1.25;
      color: #0f172a;
      font-weight: 800;
    }
    .cover-sub {
      margin-top: 8px;
      color: #475569;
      line-height: 1.7;
      font-size: 15px;
    }
    .cover-bottom {
      padding: 14px 22px 22px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }
    .cover-meta { color: #64748b; font-size: 13px; }
    .cover-actions { display: flex; gap: 8px; flex-wrap: wrap; }

    @media (max-width: 1150px) {
      body {
        background: #f5f7fb;
      }
      .top {
        position: static;
        backdrop-filter: none;
        background: #ffffff;
      }
      .layout {
        grid-template-columns: 1fr;
        height: auto;
        max-width: 820px;
        padding: 4px 12px 24px;
      }
      .left, .right { display: none; }
      .meta, .book-foot { display: none; }
      .center { gap: 0; }
      .topin { padding: 8px 10px; }
      .top .sub,
      #coverBtn,
      #focusBtn { display: none; }
      .brand { font-size: 14px; }
      .viewer-wrap {
        min-height: 0;
        flex: 0;
      }
      .viewer {
        height: auto;
        overflow: visible;
        border: 0;
        box-shadow: none;
        background: transparent;
        padding: 0;
      }
      .viewer .doc {
        margin: 0 auto;
        max-width: 760px;
        border: 1px solid var(--line);
        border-radius: 10px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
        padding: 18px 16px 26px;
      }
      .viewer .doc.continuous-doc {
        line-height: 2;
        letter-spacing: 0.01em;
      }
      .viewer .doc.continuous-doc .doc-chapter {
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 18px;
        padding-bottom: 18px;
      }
      .viewer .doc.continuous-doc .doc-chapter:last-child {
        border-bottom: 0;
        margin-bottom: 0;
        padding-bottom: 0;
      }
      .viewer .doc.continuous-doc .chapter-head {
        margin-bottom: 12px;
      }
      .viewer .doc.continuous-doc .chapter-kicker {
        margin: 0 0 4px;
        font-size: 12px;
        color: #64748b;
      }
      .viewer .doc.continuous-doc .chapter-title {
        margin: 0;
        color: var(--brand);
        font-size: 20px;
        line-height: 1.35;
      }
      .viewer .doc.continuous-doc .chapter-hint {
        margin: 6px 0 0;
        font-size: 13px;
        color: #475569;
        line-height: 1.7;
      }
      .viewer .doc.continuous-doc p,
      .viewer .doc.continuous-doc li {
        font-size: 16px;
      }
      .viewer .doc.continuous-doc h2 {
        font-size: 22px;
      }
      .viewer .doc.continuous-doc h3 {
        font-size: 18px;
      }
      .viewer .doc.continuous-doc p {
        margin: 0 0 14px;
      }
      .viewer .doc.continuous-doc ul,
      .viewer .doc.continuous-doc ol {
        margin-top: 0;
        margin-bottom: 14px;
      }
      .viewer .doc.continuous-doc table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }

      @media (max-width: 640px) {
        .layout {
          padding-left: 8px;
          padding-right: 8px;
        }
        .viewer .doc {
          padding: 16px 13px 22px;
        }
        .viewer .doc.continuous-doc .chapter-title {
          font-size: 19px;
        }
        .viewer .doc.continuous-doc p,
        .viewer .doc.continuous-doc li {
          font-size: 15px;
        }
      }
      .gallery-grid { grid-template-columns: 1fr; }
      .flash-title { font-size: 19px; }
      .cover-title { font-size: 25px; }
      .mobile-progress { display: block; }
    }
