:root {
    --bg: #0e1014;
    --bg-soft: #14171d;
    --bg-card: #191d24;
    --line: #262b34;
    --text: #e9ebef;
    --muted: #8b93a1;
    --accent: #e8a33d;
    --accent-soft: rgba(232, 163, 61, 0.14);
    --radius: 12px;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
    min-height: 100vh;
  }
  a { color: inherit; text-decoration: none; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  img { display: block; }

  .wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

  /* ---------- 顶栏 ---------- */
  .topbar {
    position: sticky; top: 0; z-index: 30;
    background: rgba(14, 16, 20, 0.86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .topbar-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
  .brand { font-size: 19px; font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; }
  .brand span { color: var(--accent); }
  .search { flex: 1; max-width: 420px; position: relative; }
  .search input {
    width: 100%; height: 38px; padding: 0 14px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
    outline: none; transition: border-color 0.18s;
  }
  .search input:focus { border-color: var(--accent); }
  .top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
  .icon-btn {
    height: 34px; padding: 0 12px; border-radius: 999px;
    background: transparent; border: 1px solid transparent; color: var(--muted);
  }
  .icon-btn:hover { color: var(--text); border-color: var(--line); }
  .who { color: var(--muted); font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---------- 通用 ---------- */
  .page { padding: 26px 0 140px; }
  .muted { color: var(--muted); }
  .section { font-size: 15px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); margin: 28px 0 14px; text-transform: uppercase; }
  .btn {
    height: 38px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--bg-card); transition: transform 0.12s, border-color 0.18s, background 0.18s;
  }
  .btn:hover { border-color: #39404d; }
  .btn:active { transform: scale(0.98); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #17130c; font-weight: 600; }
  .btn.primary:hover { background: #f0b357; }
  .btn.ghost { background: transparent; }
  .btn.danger { color: #ff8a8a; border-color: rgba(255, 138, 138, 0.3); }
  .chip {
    display: inline-block; padding: 2px 9px; margin: 0 6px 6px 0; font-size: 12px;
    border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  }

  /* ---------- 登录 ---------- */
  .auth {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: radial-gradient(1100px 600px at 15% 0%, rgba(232, 163, 61, 0.12), transparent 60%),
                radial-gradient(900px 500px at 90% 20%, rgba(74, 116, 255, 0.1), transparent 60%), var(--bg);
  }
  .auth-card { width: 100%; max-width: 380px; padding: 34px 30px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
  .auth-brand { font-size: 26px; font-weight: 700; letter-spacing: 0.08em; margin-bottom: 6px; }
  .auth-brand span { color: var(--accent); }
  .auth form { margin-top: 22px; display: grid; gap: 12px; }
  .field { display: grid; gap: 6px; }
  .field label { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
  .field input, .field select, .field textarea {
    width: 100%; padding: 10px 13px; background: var(--bg); border: 1px solid var(--line);
    border-radius: 10px; outline: none; transition: border-color 0.16s;
  }
  .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
  .field textarea { resize: vertical; min-height: 78px; }
  .auth-foot { margin-top: 16px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
  .auth-foot a { color: var(--muted); border-bottom: 1px dashed var(--line); }

  /* ---------- 书库 / 卡片 ---------- */
  .libs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
  .lib-card {
    display: flex; align-items: center; gap: 14px; padding: 18px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
    transition: border-color 0.18s, transform 0.18s;
  }
  .lib-card:hover { border-color: #39404d; transform: translateY(-2px); }
  .lib-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 20px; }
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
  .card { display: block; }
  .card .cover {
    position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden;
    background: var(--bg-card); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s;
  }
  .card:hover .cover { transform: translateY(-3px); }
  .card .cover img { width: 100%; height: 100%; object-fit: cover; }
  .card-title { margin-top: 10px; font-size: 14px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mini-progress { height: 3px; background: var(--line); border-radius: 2px; margin-top: 7px; overflow: hidden; }
  .mini-progress i { display: block; height: 100%; background: var(--accent); }

  .row { display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 18px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
  .row .card-title { font-size: 13px; }

  /* ---------- 工具栏 ---------- */
  .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 22px; }
  .toolbar h1 { font-size: 24px; margin: 0 12px 0 0; font-weight: 600; }
  .toolbar .spacer { flex: 1; }
  .select {
    height: 34px; padding: 0 10px; border-radius: 8px;
    background: var(--bg-soft); border: 1px solid var(--line);
  }

  /* ---------- 详情 ---------- */
  .back { color: var(--muted); font-size: 13px; }
  .back:hover { color: var(--text); }
  .detail-top { display: flex; gap: 30px; margin-top: 18px; flex-wrap: wrap; }
  .detail-cover { width: 260px; flex: 0 0 260px; aspect-ratio: 1/1; border-radius: 14px; overflow: hidden; background: var(--bg-card); box-shadow: var(--shadow); }
  .detail-cover img { width: 100%; height: 100%; object-fit: cover; }
  .detail-meta { flex: 1; min-width: 260px; }
  .detail-meta h1 { font-family: Georgia, "Songti SC", "Noto Serif SC", serif; font-size: 32px; line-height: 1.25; margin: 0 0 10px; font-weight: 600; }
  .detail-sub { color: var(--muted); font-size: 14px; }
  .detail-actions { display: flex; gap: 10px; margin: 22px 0 8px; flex-wrap: wrap; }
  .desc { color: #c4cad4; white-space: pre-wrap; margin-top: 24px; max-width: 760px; }
  .chapters { display: grid; gap: 2px; margin-top: 10px; max-width: 760px; }
  .chapter {
    display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 8px;
    background: transparent; border: none; text-align: left; width: 100%; color: var(--text);
  }
  .chapter:hover { background: var(--bg-soft); }
  .chapter .idx { width: 26px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
  .chapter .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .chapter .time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
  .chapter.active { background: var(--bg-soft); box-shadow: inset 2px 0 0 var(--accent); }
  .chapter.active .idx, .chapter.active .name { color: var(--accent); }

  /* ---------- 管理 ---------- */
  .panel { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
  .panel h2 { font-size: 16px; margin: 0 0 16px; font-weight: 600; }
  .form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
  .form-grid .full { grid-column: 1 / -1; }
  .up-status { font-size: 12px; color: var(--muted); margin-top: 10px; min-height: 18px; white-space: pre-wrap; }
  .users { width: 100%; border-collapse: collapse; margin-top: 10px; }
  .users td, .users th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
  .users th { color: var(--muted); font-weight: 500; }
  .access-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; }
  .access-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 10px; }
  .access-users { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; }
  .access-user { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
  .access-actions { display: flex; gap: 8px; margin-top: 12px; }

  /* ---------- 播放器 ---------- */
  .player {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    transform: translateY(110%); transition: transform 0.25s ease;
    background: rgba(20, 23, 29, 0.96);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  }
  .player.show { transform: translateY(0); }
  .player-inner { max-width: 1180px; margin: 0 auto; padding: 12px 20px 16px; display: grid; grid-template-columns: 56px minmax(120px, 1fr) auto minmax(180px, 1.6fr) auto; gap: 16px; align-items: center; }
  .pl-cover { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--bg-card); }
  .pl-cover img { width: 100%; height: 100%; object-fit: cover; }
  .pl-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pl-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pl-controls { display: flex; align-items: center; gap: 6px; }
  .pl-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; color: var(--text); display: grid; place-items: center; font-size: 15px; }
  .pl-btn:hover { background: rgba(255, 255, 255, 0.06); }
  .pl-btn.main { width: 44px; height: 44px; background: var(--accent); color: #17130c; font-size: 17px; font-weight: 700; }
  .pl-btn.main:hover { background: #f0b357; }
  .pl-timeline { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .pl-bar { position: relative; flex: 1; height: 22px; display: flex; align-items: center; cursor: pointer; }
  .pl-bar::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; background: #2b313b; border-radius: 2px; }
  .pl-fill { position: absolute; left: 0; height: 4px; background: var(--accent); border-radius: 2px; }
  .pl-knob { position: absolute; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(232, 163, 61, 0.18); }
  .pl-chapters { position: absolute; left: 0; right: 0; height: 12px; pointer-events: none; }
  .pl-chapters i { position: absolute; top: 3px; width: 1px; height: 6px; background: rgba(255, 255, 255, 0.22); }
  .pl-extra { display: flex; align-items: center; gap: 6px; }
  .pl-extra select { height: 30px; padding: 0 6px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--line); font-size: 12px; }
  .timer-btn { font-size: 12px; color: var(--muted); background: transparent; border: 1px solid var(--line); height: 30px; padding: 0 8px; border-radius: 8px; }

  /* ---------- toast ---------- */
  #toast {
    position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%) translateY(12px);
    background: #232830; border: 1px solid #333a45; color: var(--text);
    padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none;
    transition: opacity 0.2s, transform 0.2s; z-index: 80; max-width: 80vw;
  }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  .empty { padding: 60px 0; text-align: center; color: var(--muted); }

  @media (max-width: 820px) {
    .topbar-inner { height: 54px; gap: 10px; }
    .search { max-width: none; }
    .who { display: none; }
    .page { padding: 18px 0 220px; }
    .libs { grid-template-columns: 1fr 1fr; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 16px 12px; }
    .detail-cover { width: 150px; flex: 0 0 150px; }
    .detail-meta h1 { font-size: 24px; }
    .player-inner { grid-template-columns: 44px 1fr auto; grid-template-areas: "cover meta controls" "timeline timeline timeline"; row-gap: 6px; padding: 10px 14px 14px; }
    .pl-cover { grid-area: cover; width: 44px; height: 44px; }
    .pl-meta { grid-area: meta; }
    .pl-controls { grid-area: controls; }
    .pl-timeline { grid-area: timeline; }
    .pl-extra { display: none; }
    #toast { bottom: 190px; }
  }
