: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(20,20,26,.58);
  -webkit-backdrop-filter: blur(7px) saturate(115%); backdrop-filter: blur(7px) saturate(115%);
  border-bottom: 1px solid rgba(76,76,91,.72); box-shadow: 0 8px 28px rgba(0,0,0,.18); }
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; }
.nav-menu-btn { display: none; width: 38px; height: 38px; flex: none; align-items: center; justify-content: center;
  border: 1px solid var(--line2); border-radius: 10px; background: #14141b; color: var(--text);
  padding: 0; cursor: pointer; font-family: inherit; }
.nav-menu-btn:hover { border-color: var(--accent); background: #1b1a25; }
.nav-menu-btn:focus-visible { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,.22); }
@media (max-width: 840px) {
  nav.top { gap: 10px; padding: 0 14px; }
  nav.top .brand { flex: none; }
  nav.top .links { display: none; position: absolute; top: calc(100% + 8px); right: 12px;
    width: min(300px, calc(100vw - 24px)); flex-direction: column; gap: 3px; padding: 8px;
    border: 1px solid var(--line2); border-radius: 13px; background: rgba(23,23,29,.98);
    box-shadow: 0 18px 50px rgba(0,0,0,.55); backdrop-filter: blur(14px); }
  nav.top .links.open { display: flex; }
  nav.top .links a { display: block; padding: 11px 12px; border-radius: 8px; white-space: nowrap; }
  nav.top .links a:hover { background: #20202a; }
  nav.top .links a.active { color: #fff; background: rgba(108,92,231,.24); }
  .nav-menu-btn { display: inline-flex; }
  nav.top .nav-auth { gap: 8px; }
}
@media (max-width: 380px) {
  nav.top { padding-inline: 10px; }
  nav.top .brand { font-size: 13px; letter-spacing: 1.5px; }
  nav.top .credits-pill { padding-inline: 8px; }
  .credits-pill span { display: none; }
}
.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; }
.nav-auth { display: flex; align-items: center; gap: 12px; }
/* 點數膠囊：頭貼左側，icon＋數字＋點 */
.credits-pill { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px 0 9px;
  border-radius: 999px; border: 1px solid var(--line2); background: #14141b; color: var(--text) !important;
  font-size: 13px; line-height: 1; white-space: nowrap; }
.credits-pill:hover { border-color: var(--accent); }
.credits-pill svg { color: var(--accent2); flex: none; }
.credits-pill b { font-weight: 700; font-variant-numeric: tabular-nums; }
.credits-pill span { color: var(--dim); font-size: 11.5px; }
.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); }
/* ── Form controls：input／select／textarea 共用同一套規範 ── */
.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; line-height: 1.4;
  transition: border-color .12s ease, box-shadow .12s ease; }
.field:hover:not(:focus):not(:disabled) { border-color: #45454f; }
.field:focus, input.search:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,.18); }
.field:disabled { opacity: .5; cursor: not-allowed; }
.field::placeholder { color: #565660; }
/* 下拉：關掉原生外觀，換上與深色介面一致的 chevron，不再露出 OS 灰色下拉 */
select.field { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%238b8b96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px; }
select.field:focus { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%239b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E"); }
select.field option { background: var(--panel); color: var(--text); }
textarea.field { resize: vertical; font-family: inherit; line-height: 1.5; }
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="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); }
/* 多色去背 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 .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); }

/* ── 建立節點表單 ─────────────────────────── */
.nc { max-width: 720px; margin: 0 auto; }
.nc > label { display: block; font-size: 12.5px; color: var(--dim); margin: 14px 0 5px; }
.nc > .field { width: 100%; }
/* 參數列：type 一選，右側就換成對應的預設值編輯器 */
.nc-prow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nc-prow .nc-key { flex: 0 0 150px; }
.nc-prow .nc-type { flex: 0 0 116px; }
.nc-prow .nc-label { flex: 1 1 130px; min-width: 110px; }
.nc-prow .nc-def { flex: 1 1 150px; min-width: 120px; display: flex; gap: 6px; align-items: center; }
.nc-prow .nc-def .field { flex: 1; min-width: 0; }
.nc-prow .nc-def input[type=color] { width: 38px; height: 34px; padding: 2px; border: 1px solid var(--line2);
  border-radius: 8px; background: var(--panel); cursor: pointer; flex: none; }
/* toggle 開關 */
.sw { position: relative; width: 42px; height: 24px; flex: none; cursor: pointer; }
.sw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sw .track { position: absolute; inset: 0; background: var(--line2); border-radius: 999px; transition: background .15s; }
.sw .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .15s; }
.sw input:checked + .track { background: var(--accent); }
.sw input:checked + .track::after { transform: translateX(18px); }
.nc-opts { flex: 1 1 100%; font-size: 12px; color: var(--dim); margin: 2px 0 0 158px; }
.nc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; }
.nc-h { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 16px 0 8px; }
.nc-h b { font-weight: 650; }
.nc-mini { margin-left: auto; width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line2);
  background: transparent; color: var(--accent2); font-size: 17px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; line-height: 0; padding: 0; }
.nc-mini:hover { border-color: var(--accent); color: var(--accent); }
.nc-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.nc-row .field { flex: 1; min-width: 0; }
.nc-prow { flex-wrap: wrap; }
.nc-del { width: 34px; height: 36px; border-radius: 8px; border: 1px solid var(--line2); background: transparent;
  color: var(--dim); font-size: 17px; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center; line-height: 0; padding: 0; }
.nc-del:hover { color: var(--bad); border-color: var(--bad); }

/* ── 自訂下拉選單（取代原生 select，連展開清單都自繪）── */
.sel { position: relative; display: inline-flex; align-items: center; padding-right: 34px;
  cursor: pointer; user-select: none; background-image: none; }
.sel .sel-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel .sel-chev { position: absolute; right: 12px; top: 50%; width: 11px; height: 11px; pointer-events: none;
  transform: translateY(-50%); transition: transform .15s ease;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%238b8b96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E"); }
.sel.open { border-color: var(--accent); }
.sel.open .sel-chev { transform: translateY(-50%) rotate(180deg); }
.sel:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,92,231,.18); }
.sel-pop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 200; display: none;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 5px;
  box-shadow: 0 16px 42px rgba(0,0,0,.55); max-height: 264px; overflow: auto; }
.sel.open .sel-pop { display: block; }
.sel-opt { padding: 8px 11px; border-radius: 7px; font-size: 14px; color: var(--text); white-space: nowrap; }
.sel-opt:hover { background: #23232d; }
.sel-opt.on { color: var(--accent2); }
.sel-opt.on::after { content: "✓"; float: right; margin-left: 14px; font-size: 12px; }
.nc-actions { display: flex; align-items: center; gap: 14px; margin: 22px 0 8px; }
.nc-msg { font-size: 13px; color: var(--dim); }
.nc-msg.ok { color: #56ce86; }
.nc-msg.bad { color: #ff7a86; }
.nc-json { margin-top: 14px; }
.nc-json summary { cursor: pointer; color: var(--dim); font-size: 12.5px; }
.nc-json pre { background: #101015; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 11.5px; line-height: 1.5; overflow: auto; max-height: 320px; color: #cfd2e6; }

/* ── 可複製 ID 晶片（節點/專案，方便貼給 AI 或分享）── */
.idchip { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--dim);
  background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 4px 9px;
  cursor: pointer; white-space: nowrap; transition: color .12s ease, border-color .12s ease; }
.idchip:hover { color: var(--text); border-color: var(--accent); }
.idchip.copied { color: var(--good); border-color: var(--good); }

/* ── 節點詳情 ── */
.nd-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.nd-head h2 { margin: 0; font-size: 20px; }
.nd-ver { color: var(--dim); font-size: 13px; }
.nd-pub { font-size: 12px; color: var(--good); border: 1px solid #235c39; border-radius: 999px; padding: 2px 10px; }
.nd-desc { color: var(--dim); font-size: 14px; line-height: 1.7; margin: 4px 0 18px; max-width: 720px; }
.nd-kv { display: flex; gap: 16px; align-items: baseline; padding: 11px 0; border-top: 1px solid var(--line); }
.nd-kv > label { flex: 0 0 84px; color: var(--dim); font-size: 12.5px; }
.nd-ep { font-size: 13px; color: var(--text); word-break: break-all; }
.pill { display: inline-block; background: var(--bg); border: 1px solid var(--line2); border-radius: 6px;
  padding: 3px 9px; font-size: 12.5px; margin: 2px 4px 2px 0; }

/* ── 分頁 Tabs（我的節點 使用中/封存）── */
.tabs { display: flex; gap: 2px; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; color: var(--dim); font-size: 14px; font-family: inherit; cursor: pointer;
  padding: 9px 15px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

/* ── 參數：滑桿即時預覽（作者拖著感受手感、定 min/max/預設）── */
.nc-num { max-width: 62px; flex: 0 0 62px; -moz-appearance: textfield; appearance: textfield; text-align: center; padding: 10px 8px; }
.nc-num::-webkit-outer-spin-button, .nc-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.nc-slider { display: flex; align-items: center; gap: 9px; flex: 1 1 160px; min-width: 140px; }

/* ── n8n 式 Request 建立器（Header / Query / Body：欄位 ⇄ JSON）── */
/* 不用 overflow:hidden——否則會裁掉自訂下拉的展開清單。改由子元素自行圓角。 */
.rq-sec { border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; }
.rq-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #14141a;
  border-radius: 11px 11px 0 0; }
.rq-sec:has(.rq-body:empty) .rq-head { border-radius: 11px; }
.rq-head b { font-size: 13.5px; }
.rq-head .sel { margin-left: auto; flex: 0 0 140px; }
.rq-body { padding: 12px 14px; }
.rq-kv { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.rq-kv .field { flex: 1; min-width: 0; }
.rq-kv .field.k { flex: 0 0 200px; }
.rq-kv-add { font-size: 12.5px; color: var(--accent2); background: none; border: 0; cursor: pointer; padding: 2px 0; }
.rq-hint { color: var(--dim); font-size: 12px; margin: 0 0 8px; }
/* JSON 編輯器：透明 textarea 疊在上色 <pre> 上 */
.json-ed { position: relative; border: 1px solid var(--line2); border-radius: 8px; background: #101015; overflow: hidden; }
.json-ed.bad { border-color: var(--bad); }
.json-hl, .json-ta { margin: 0; padding: 11px 13px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px; line-height: 1.55; white-space: pre; overflow-wrap: normal; tab-size: 2; }
.json-hl { position: absolute; inset: 0; pointer-events: none; overflow: auto; color: #cfd2e6; }
.json-ta { position: relative; width: 100%; min-height: 120px; resize: vertical; background: transparent;
  color: transparent; caret-color: var(--text); border: 0; outline: none; overflow: auto; display: block; }
.j-key { color: #9b8cf0; } .j-str { color: #6fdc99; } .j-num { color: #e0b45c; }
.j-kw { color: #8ab4f8; } .j-expr { color: #ff9f6b; font-weight: 600; }
.json-err { color: var(--bad); font-size: 12px; margin-top: 6px; min-height: 14px; }

/* ── API 金鑰建立時的一次性揭露框 ── */
.tk-reveal { border: 1px solid var(--accent); background: #1a1830; border-radius: 12px; padding: 14px 16px; margin: 14px 0; }
.tk-reveal b { display: block; font-size: 13px; color: var(--accent2); margin-bottom: 10px; }
.tk-reveal-row { display: flex; gap: 8px; align-items: center; }
.tk-reveal-row code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; background: var(--bg);
  border: 1px solid var(--line2); border-radius: 8px; padding: 9px 12px; font-size: 12.5px;
  font-family: ui-monospace, Menlo, monospace; color: var(--text); }

/* ── 節點試跑面板 ── */
.nd-field { margin: 12px 0; }
.nd-field > label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 5px; }
.nd-field textarea.field, .nd-field input.field { width: 100%; }
.nd-field .nc-slider { max-width: 320px; }
.nd-out-port { margin: 12px 0; }
.nd-out-port > label { display: block; font-size: 12px; color: var(--accent2); margin-bottom: 5px; }
.nd-out-pre { margin: 0; padding: 12px 14px; background: #101015; border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  color: var(--text); max-height: 420px; overflow: auto; }

/* Response 映射列 */
.resp-port { flex: 0 0 120px; font-size: 12.5px; color: var(--accent2); background: var(--bg);
  border: 1px solid var(--line2); border-radius: 8px; padding: 9px 12px; text-align: center; }
.resp-arrow { color: var(--dim); flex: none; }
/* ── 站內 AI 助理：畫面正下方置中的懸浮指令列 ＋ 上方對話面板 ── */
#hsai-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 900;
  width: min(720px, calc(100vw - 24px)); }
.hsai-glow { position: absolute; width: 220px; height: 90px; border-radius: 50%; filter: blur(46px); opacity: .32; pointer-events: none; }
.hsai-glow.g1 { left: -30px; top: -8px; background: #ff7a45; }
.hsai-glow.g2 { right: -30px; top: -8px; background: #4a7dff; }
.hsai-bar-in { position: relative; background: rgba(20,20,26,.58); border: 1px solid rgba(76,76,91,.72); border-radius: 22px;
  padding: 12px 14px 10px; box-shadow: 0 8px 28px rgba(0,0,0,.28);
  -webkit-backdrop-filter: blur(7px) saturate(115%); backdrop-filter: blur(7px) saturate(115%); }
#hsai-tags { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; max-height: 68px; overflow-x: hidden; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(132,116,255,.48) transparent; padding: 0 3px 8px; }
#hsai-tags[hidden] { display: none; }
#hsai-tags::-webkit-scrollbar { width: 5px; }
#hsai-tags::-webkit-scrollbar-thumb { background: rgba(132,116,255,.48); border-radius: 999px; }
.hsai-tag { display: inline-flex; align-items: center; flex: 1 1 145px; min-width: 120px; max-width: 180px; height: 30px;
  box-sizing: border-box; overflow: hidden; padding: 3px 9px 3px 3px; border: 1px solid rgba(121,102,255,.45); border-radius: 999px;
  background: rgba(92,73,190,.18); color: #d9d5ff; font-size: 11px; }
.hsai-tag b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hsai-tag-thumb { flex: 0 0 24px; width: 24px; height: 24px; margin-right: 7px; border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%; object-fit: cover; background: #0c0c12; }
.hsai-tag-kind { flex: 0 0 auto; min-width: 24px; margin-right: 6px; padding: 2px 5px; border-radius: 999px;
  background: rgba(126,108,255,.16); color: #a99fff; font-style: normal; text-align: center; }
#hsai-ta { width: 100%; box-sizing: border-box; resize: none; background: none; border: 0; color: var(--text);
  font-size: 14px; line-height: 1.55; font-family: inherit; max-height: 120px; padding: 2px 4px 6px; }
#hsai-ta:focus { outline: none; }
#hsai-ta::placeholder { color: #6a6a76; }
.hsai-ctl { display: flex; align-items: center; gap: 8px; }
.hsai-ctl .spacer { flex: 1; }
#hsai-attach { width: 30px; height: 30px; border-radius: 50%; border: 1px solid #3a3a46; background: #17171f;
  color: var(--dim); font-size: 16px; cursor: pointer; line-height: 1; }
#hsai-attach:hover { color: #fff; border-color: var(--accent); }
.hsai-model-wrap { position: relative; }
#hsai-model-btn { display: flex; align-items: center; gap: 6px; border: 1px solid #3a3a46; background: #17171f;
  color: #c9c9d4; border-radius: 20px; padding: 6px 12px; font-size: 12px; font-family: inherit; cursor: pointer; }
#hsai-model-btn:hover { border-color: var(--accent); color: #fff; }
#hsai-model-btn .ic { color: var(--accent2); }
#hsai-model-btn .caret { font-size: 10px; color: var(--dim); }
#hsai-model-menu { position: absolute; bottom: calc(100% + 8px); left: 0; min-width: 210px;
  background: #17171dfa; border: 1px solid #33333d; border-radius: 12px; padding: 5px; box-shadow: 0 12px 36px #000a; }
#hsai-model-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: #c9c9d4;
  font-size: 12.5px; font-family: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
#hsai-model-menu button:hover { background: #26262e; color: #fff; }
#hsai-model-menu button.on { background: #26262e; color: #fff; }
#hsai-voice { display: flex; align-items: center; gap: 6px; border: 1px solid #3a3a46; background: #17171f;
  color: #c9c9d4; border-radius: 20px; padding: 6px 12px; font-size: 12px; font-family: inherit; cursor: pointer; }
#hsai-voice:hover { border-color: var(--accent); color: #fff; }
#hsai-voice.rec { border-color: #ff4d4f; color: #ff8d95; animation: hsai-pulse 1.2s ease-in-out infinite; }
#hsai-send { width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #b06ef0, #6c5ce7 55%, #4a7dff); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 14px #6c5ce766; }
#hsai-send:hover { filter: brightness(1.12); }
#hsai-send:disabled { opacity: .5; cursor: default; }
.hsai-drop { position: absolute; inset: 0; border-radius: 22px; background: #0d0d13ee; border: 1px dashed var(--accent);
  display: flex; align-items: center; justify-content: center; color: var(--accent2); font-size: 13px; z-index: 2; }
.hsai-drop[hidden] { display: none; }

#hsai-chat { position: fixed; left: 50%; bottom: var(--hsai-safe-bottom, 118px); transform: translateX(-50%); z-index: 899;
  width: min(720px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - var(--hsai-safe-bottom, 118px) - 24px));
  max-height: min(560px, calc(100dvh - var(--hsai-safe-bottom, 118px) - 24px));
  display: flex; flex-direction: column; background: rgba(20,20,26,.58); border: 1px solid rgba(76,76,91,.72); border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.28); overflow: hidden;
  -webkit-backdrop-filter: blur(7px) saturate(115%); backdrop-filter: blur(7px) saturate(115%); }
#hsai-chat[hidden] { display: none; }
.hsai-chat-hd { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid #26262e; }
.hsai-chat-hd b { font-size: 13px; }
#hsai-clear { margin-left: auto; }
#hsai-clear, #hsai-min { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 12px; font-family: inherit; padding: 3px 6px; }
#hsai-clear:hover, #hsai-min:hover { color: var(--text); }
.hsai-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.hsai-empty { color: var(--dim); font-size: 12.5px; line-height: 1.7; padding: 8px 4px; }
.hsai-b { max-width: 86%; padding: 9px 12px; border-radius: 13px; font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; }
.hsai-b.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.hsai-b.user.has-context { width: min(92%, 620px); max-width: 92%; }
.hsai-message-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 7px; }
.hsai-message-tags .hsai-tag { flex: 1 1 125px; min-width: 105px; max-width: 160px; height: 26px; padding-right: 7px;
  border-color: rgba(255,255,255,.24); background: rgba(15,13,32,.2); color: #fff; }
.hsai-message-tags .hsai-tag-thumb { flex-basis: 20px; width: 20px; height: 20px; margin-right: 5px; }
.hsai-message-tags .hsai-tag-kind { min-width: 20px; margin-right: 5px; padding: 1px 4px; color: #ebe8ff; }
.hsai-b.assistant { align-self: flex-start; background: #23232b; border: 1px solid var(--line2); border-bottom-left-radius: 5px; }
.hsai-b.hsai-think { color: var(--dim); font-style: italic; animation: hsai-pulse 1.2s ease-in-out infinite; }
@keyframes hsai-pulse { 50% { opacity: .45; } }
.hsai-send-flight { position: fixed; z-index: 898; box-sizing: border-box; max-height: 150px; overflow: hidden; pointer-events: none;
  transform-origin: 50% 0; animation: hsai-send-flight .48s cubic-bezier(.22,.72,.24,1) both; }
.hsai-flight-tags { display: flex; flex-wrap: wrap; gap: 5px; max-height: 66px; overflow: hidden; margin-bottom: 7px; }
.hsai-flight-tags .hsai-tag { flex: 1 1 140px; max-width: 180px; }
.hsai-flight-text { overflow: hidden; color: #f2f0ff; font-size: 14px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
@keyframes hsai-send-flight {
  0% { opacity: 1; transform: translateY(0) scale(1); clip-path: inset(0 0 0 0 round 20px); }
  62% { opacity: .88; transform: translateY(calc(var(--hsai-flight-y, -64px) * .72)) scale(.985); clip-path: inset(0 0 12% 0 round 18px); }
  100% { opacity: 0; transform: translateY(var(--hsai-flight-y, -64px)) scale(.96); clip-path: inset(0 0 100% 0 round 16px); }
}
@media (prefers-reduced-motion: reduce) { .hsai-send-flight { display: none; animation: none; } }
.hsai-tool { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim);
  background: #1b1b22; border: 1px solid var(--line2); border-radius: 20px; padding: 3px 10px; }
.hsai-tool .dot { width: 6px; height: 6px; border-radius: 50%; background: #3fb950; }
.hsai-tool.err .dot { background: #ff4d4f; }
.hsai-act { align-self: flex-start; max-width: 92%; background: #1b1b23; border: 1px solid #3d3d49;
  border-radius: 12px; padding: 10px 12px; font-size: 12.5px; }
.hsai-act b { font-size: 12.5px; }
.hsai-act details { margin-top: 6px; }
.hsai-act summary { color: var(--dim); font-size: 11px; cursor: pointer; }
.hsai-act pre { margin: 6px 0 0; font-size: 10.5px; color: #cfcfd6; background: #101016; border: 1px solid var(--line2);
  border-radius: 8px; padding: 7px; max-height: 150px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.hsai-act-btns { display: flex; gap: 8px; margin-top: 9px; }
.hsai-act-ok { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 6px 14px;
  font-size: 12px; font-family: inherit; cursor: pointer; }
.hsai-act-ok:hover { background: var(--accent2); }
.hsai-act-ok:disabled { opacity: .6; cursor: default; }
.hsai-act-no { background: none; color: var(--dim); border: 1px solid var(--line2); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; font-family: inherit; cursor: pointer; }
.hsai-act-no:hover { color: var(--text); border-color: #4a4a56; }
.hsai-act-done { margin-top: 8px; font-size: 12px; color: #3fb950; }
.hsai-act-done.err { color: #ff8d95; }
.hsai-act-done.dim { color: var(--dim); }
@media (max-width: 640px) {
  /* 窄版只收寬，不改變垂直錨點：避免響應式切換時整顆 AI 對話框往下跳。 */
  #hsai-bar { width: calc(100vw - 16px); }
  #hsai-chat { width: calc(100vw - 16px); max-height: calc(100dvh - 190px); }
  #hsai-voice span { display: none; }
}
