:root { color-scheme: dark;
  --bg: #0e0e12; --panel: #17171d; --line: #26262e; --line2: #33333d;
  --text: #ececf1; --dim: #8b8b96; --accent: #6c5ce7; --accent2: #9b8cf0;
  --good: #6fdc99; --bad: #ff8fa0; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
       font-family: system-ui, -apple-system, "PingFang TC", sans-serif; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ─────────────────────────────── */
nav.top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 26px;
  padding: 0 22px; height: 56px; background: rgba(14,14,18,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
nav.top .brand { color: var(--accent); font-weight: 800; letter-spacing: 2px; font-size: 14px; }
nav.top .links { display: flex; gap: 20px; }
nav.top .links a { color: var(--dim); font-size: 14px; padding: 4px 2px; }
nav.top .links a.active, nav.top .links a:hover { color: var(--text); text-decoration: none; }
nav.top .spacer { flex: 1; }
.avatar-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line2);
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.avatar-wrap { position: relative; }
.dropdown { position: absolute; right: 0; top: 44px; min-width: 190px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
.dropdown.open { display: block; }
.dropdown .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown .who b { display: block; font-size: 14px; }
.dropdown .who span { font-size: 12px; color: var(--dim); }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 9px 12px;
  border-radius: 8px; color: var(--text); font-size: 14px; background: none; border: 0;
  cursor: pointer; font-family: inherit; }
.dropdown a:hover, .dropdown button:hover { background: #1f1f27; text-decoration: none; }
.dropdown button.danger { color: var(--bad); }
.login-link { background: var(--accent); color: #fff !important; padding: 8px 18px;
  border-radius: 8px; font-size: 14px; font-weight: 600; }
.login-link:hover { text-decoration: none; filter: brightness(1.1); }

/* ── Layout ─────────────────────────────── */
main.page { max-width: 1020px; margin: 0 auto; padding: 34px 24px 80px; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head .spacer { flex: 1; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border: 1px solid var(--line2); color: var(--text); }
input.field, input.search { background: var(--panel); color: var(--text); border: 1px solid var(--line2);
  border-radius: 8px; padding: 10px 14px; font-size: 14.5px; font-family: inherit; }
input.field:focus, input.search:focus { outline: none; border-color: var(--accent); }
input.search { width: min(360px, 100%); }

/* ── Cards / grid ───────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 16px; }
.card .desc { color: var(--dim); font-size: 13px; line-height: 1.6; flex: 1; }
.badge { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line2); color: var(--dim); }
.badge.video { color: #8ab4f8; border-color: #2c4a7a; }
.badge.subtitle { color: #e0b45c; border-color: #6a5323; }
.badge.audio { color: var(--good); border-color: #235c39; }
.author { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.author .ava { width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; overflow: hidden; flex: none; }
.author .ava img { width: 100%; height: 100%; object-fit: cover; }
.author span { font-size: 12.5px; color: var(--dim); }

/* ── List rows ──────────────────────────── */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px 18px; display: flex; align-items: center; gap: 14px; }
.row .info { flex: 1; min-width: 0; }
.row .info b { font-size: 15px; }
.row .info span { display: block; color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.row code { font-size: 11.5px; color: var(--dim); background: var(--bg);
  border: 1px solid var(--line2); border-radius: 5px; padding: 2px 7px; }

/* ── States ─────────────────────────────── */
.empty { text-align: center; color: var(--dim); padding: 60px 20px; font-size: 14.5px; line-height: 1.8; }
.error-box { background: #3a1a20; border: 1px solid #7a2a35; color: var(--bad); border-radius: 10px;
  padding: 12px 16px; font-size: 13.5px; }
@keyframes shimmer { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
.skeleton { border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  min-height: 110px; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton.row-sk { min-height: 62px; border-radius: 12px; }

/* ── JSON panel ─────────────────────────── */
.json-panel { background: #14141a; border: 1px solid #2a2a34; border-radius: 12px; overflow: hidden; }
.json-panel .bar { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid #2a2a34; }
.json-panel .bar b { font-size: 13px; color: var(--dim); flex: 1; }
.json-panel pre { margin: 0; padding: 16px; overflow: auto; max-height: 480px; font-size: 12.5px;
  line-height: 1.6; color: #a5d6a7; font-family: "SF Mono", Menlo, Consolas, monospace; }

/* ── Auth card ──────────────────────────── */
.auth-card { max-width: 400px; margin: 8vh auto 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--dim); font-size: 13px; margin: 0 0 22px; }
.auth-card label { display: block; font-size: 13px; color: #b9b9c3; margin: 14px 0 6px; }
.auth-card input { width: 100%; }
.auth-card .btn { width: 100%; margin-top: 22px; padding: 12px; font-size: 15px; }

/* ── SPA Modal（模組詳情 pop-up）───────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,8,12,0.72); backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 20px; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  width: min(860px, 100%); box-shadow: 0 24px 80px rgba(0,0,0,0.6); }
.modal .m-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .m-head h2 { margin: 0; font-size: 19px; flex: 1; }
.modal .m-close { background: none; border: 0; color: var(--dim); font-size: 22px; cursor: pointer;
  line-height: 1; padding: 4px 8px; border-radius: 8px; }
.modal .m-close:hover { color: var(--text); background: #1f1f27; }
.modal .m-body { padding: 20px 22px 26px; }
.modal .m-preview { position: relative; aspect-ratio: 16/9; background: #101016;
  border-radius: 12px; overflow: hidden; margin-bottom: 18px; contain: layout paint style; }
.modal .m-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.modal h3 { font-size: 14px; color: #b9b9c3; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: 1px; }
.modal .m-desc { color: var(--dim); font-size: 14px; line-height: 1.7; margin: 0; }
.modal pre.code { background: #0e0e12; border: 1px solid var(--line2); border-radius: 10px;
  padding: 14px 16px; overflow: auto; max-height: 340px; font-size: 12px; line-height: 1.6;
  color: #a5d6a7; font-family: "SF Mono", Menlo, Consolas, monospace; margin: 0; }
.modal .code-bar { display: flex; align-items: center; margin: 20px 0 8px; }
.modal .code-bar h3 { margin: 0; flex: 1; }
.param-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.param-table th, .param-table td { border: 1px solid var(--line2); padding: 7px 10px; text-align: left; }
.param-table th { background: #101016; color: var(--dim); font-weight: 600; }

/* ── 市集（剪映式）───────────────────── */
.market { display: grid; grid-template-columns: 170px 1fr; gap: 26px; }
@media (max-width: 720px) { .market { grid-template-columns: 1fr; } }
.sidebar { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 76px; align-self: start; }
.sidebar button { text-align: left; background: none; border: 0; color: var(--dim); font-size: 14px;
  font-family: inherit; padding: 9px 14px; border-radius: 8px; cursor: pointer; }
.sidebar button:hover { color: var(--text); background: var(--panel); }
.sidebar button.active { color: var(--accent2); background: var(--panel); font-weight: 700; }
.mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.mod { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; transition: border-color 0.15s, transform 0.15s; }
.mod:hover { border-color: var(--accent); transform: translateY(-2px); }
.thumb { position: relative; aspect-ratio: 16/9; background: #101016; overflow: hidden;
  contain: layout paint style; }
.thumb .audio-face, .m-preview .audio-face { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: var(--dim); }
.wave { display: flex; gap: 3px; align-items: flex-end; height: 26px; }
.wave i { width: 4px; border-radius: 2px; background: var(--accent2); animation: wv 1s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: .12s; } .wave i:nth-child(3) { animation-delay: .24s; }
.wave i:nth-child(4) { animation-delay: .36s; } .wave i:nth-child(5) { animation-delay: .48s; }
@keyframes wv { 0%,100% { height: 6px; } 50% { height: 24px; } }
.playBtn { background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 6px 16px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.mod .meta { padding: 12px 14px 14px; }
.mod .meta h3 { margin: 0 0 6px; font-size: 14.5px; }
.mod .badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.badge.size { color: #b9b9c3; }
.thumb .sizeTag { position: absolute; top: 8px; right: 8px; z-index: 5; background: rgba(14,14,18,0.72);
  border: 1px solid var(--line2); color: #d6d6de; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; }

/* ── 參數即時調整 ───────────────────── */
.pv-ctl { display: flex; align-items: center; gap: 10px; }
.pv-ctl input[type="range"] { flex: 1; accent-color: var(--accent); }
.pv-ctl input[type="color"] { width: 44px; height: 28px; border: 1px solid var(--line2);
  border-radius: 6px; background: var(--bg); padding: 2px; cursor: pointer; }
.pv-ctl select { background: var(--bg); color: var(--text); border: 1px solid var(--line2);
  border-radius: 6px; padding: 5px 8px; font-family: inherit; }
.pv-ctl input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.pv-ctl .pv-val { min-width: 44px; text-align: right; font-size: 12px; color: var(--dim);
  background: var(--bg); border: 1px solid var(--line2); border-radius: 5px; padding: 2px 7px; }
/* 多色去背 colorkeys：每列一色 + 各自容差，可增刪 */
.ck { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.ck-row { display: flex; align-items: center; gap: 9px; }
.ck-row input[type="color"] { width: 40px; height: 26px; border: 1px solid var(--line2);
  border-radius: 6px; background: var(--bg); padding: 2px; cursor: pointer; flex: none; }
.ck-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.ck-row .ck-tol { min-width: 40px; text-align: right; font-size: 12px; color: var(--dim);
  background: var(--bg); border: 1px solid var(--line2); border-radius: 5px; padding: 2px 6px; }
.ck-row .ck-del { flex: none; width: 24px; height: 24px; border-radius: 6px; cursor: pointer;
  background: transparent; border: 1px solid var(--line2); color: var(--dim); font-size: 12px; line-height: 1; }
.ck-row .ck-del:hover { color: var(--bad); border-color: var(--bad); }
.ck-add { align-self: flex-start; background: transparent; border: 1px dashed var(--line2);
  color: var(--accent2); border-radius: 7px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.ck-add:hover { border-color: var(--accent); color: var(--accent); }
.ck-full { font-size: 12px; color: var(--dim); }
