* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #141a26;
  --bg2: #1a2231;
  --bg3: #202a3c;
  --border: #2c374c;
  --text: #e9edf5;
  --dim: #8b95a7;
  --accent: #d94f3d;
  --accent2: #e8b35a;
  --green: #4ccc8a;
  --grey: #5a6478;
  --err: #ff6b62;
  --outbg: #0f131c;
}

html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 标题栏 ---------- */
#titlebar {
  height: 79px;
  background: var(--bg2);
  display: flex;
  align-items: center;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}
#tb-logo {
  width: 44px; height: 44px;
  margin-left: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
#tb-icon { width: 100%; height: 100%; object-fit: cover; }
#tb-text { margin-left: 10px; }
#tb-title { font-size: 19px; font-weight: 700; }
#tb-sub  { font-size: 12px; color: var(--dim); margin-top: 2px; }

#tb-btns { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
.tb-btn {
  width: 30px; height: 30px;
  background: transparent; border: none;
  color: var(--dim); font-size: 14px; cursor: pointer;
  border-radius: 3px; display: flex; align-items: center; justify-content: center;
}
.tb-btn:hover { background: var(--bg3); color: var(--text); }
.tb-close:hover { background: var(--accent); color: var(--text); }

/* ---------- 主体 ---------- */
#body { flex: 1; display: flex; min-height: 0; }

/* 侧边栏 */
#sidebar {
  width: 228px;
  background: var(--bg2);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
#sb-label {
  font-size: 12px; font-weight: 700; color: var(--dim);
  padding: 14px 18px 6px 18px;
}
#sb-nav { flex: 1; overflow-y: auto; min-height: 50px; }

.nav-row {
  display: flex; align-items: center;
  height: 46px; padding: 0 8px;
  cursor: pointer; user-select: none;
}
.nav-row:hover, .nav-row.selected { background: var(--bg3); }
.nav-child { padding-left: 16px; height: 40px; }
.nav-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin: 0 8px 0 6px; flex-shrink: 0;
}
.nav-dot.green { background: var(--green); }
.nav-dot.grey  { background: var(--grey); }
.nav-name { flex: 1; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-arrow { color: var(--dim); font-size: 12px; padding: 4px 8px; }
.nav-tag { color: var(--accent2); font-size: 11px; margin-right: 8px; flex-shrink: 0; }

#sb-ver {
  padding: 14px; flex-shrink: 0;
}
#sb-ver {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 14px;
  padding: 12px 14px;
}
.ver-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.ver-line  { font-size: 12px; color: var(--dim); margin-top: 2px; }

/* 内容区 */
#content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#ch-header { padding: 10px 18px 0 18px; }
#ch-title { font-size: 16px; font-weight: 700; }
#ch-desc  { font-size: 12px; color: var(--dim); margin-top: 2px; }
#ch-body  { flex: 1; overflow-y: auto; padding: 12px 18px 6px 18px; }

#ch-output-wrap { display: none; padding: 0 18px 6px 18px; flex-shrink: 0; }
#ch-out-label { font-size: 12px; font-weight: 700; color: var(--dim); margin-bottom: 4px; }
#ch-output {
  background: var(--outbg);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 140px;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}
.out-ok   { color: var(--green); }
.out-err  { color: var(--err); }
.out-key  { color: var(--accent2); }
.out-acc  { color: var(--accent); }
.out-dim  { color: var(--dim); }

/* 状态栏 */
#statusbar {
  height: 33px;
  background: var(--bg2);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  font-size: 12px; color: var(--dim);
  flex-shrink: 0;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; }
.card-title { font-size: 13px; font-weight: 700; flex: 1; }
.card-provider { font-size: 11px; color: var(--dim); }
.card-desc { font-size: 12px; color: var(--dim); margin-top: 6px; }
.card-sub  { font-size: 11px; color: var(--dim); margin-top: 4px; word-break: break-all; }

.card-params { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.param-col label { display: block; font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.param-col input {
  background: var(--outbg); color: var(--text);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 6px 8px; font-size: 12px; width: 180px;
  font-family: inherit;
}
.param-col input:focus { outline: 1px solid var(--accent); }

.btn-run {
  margin-top: 8px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 4px;
  font-size: 12px; font-weight: 700;
  padding: 6px 18px; cursor: pointer;
}
.btn-run:hover { background: #e4543f; }

.btn-plain {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; padding: 6px 28px; cursor: pointer;
}
.btn-plain:hover { background: var(--bg3); }
.btn-disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 首页 ---------- */
#home-wrap { text-align: center; padding: 30px 0 10px 0; }
#home-title { font-size: 32px; font-weight: 700; }
#home-sub { font-size: 15px; color: var(--accent); margin-top: 14px; }
#home-credit { font-size: 14px; color: var(--accent2); margin-top: 16px; }
#home-local { font-size: 13px; color: var(--dim); margin-top: 4px; }
#home-imgs { margin-top: 18px; }
#home-imgs img {
  height: 220px;
  border-radius: 4px;
  cursor: pointer;
  object-fit: contain;
}
#home-btns { margin-top: 18px; display: flex; gap: 24px; justify-content: center; }

/* ---------- 占位 ---------- */
.placeholder-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: center;
  padding: 44px 0 30px 0;
}
.placeholder-icon { font-size: 44px; font-weight: 700; color: var(--grey); }
.placeholder-t1 { font-size: 14px; font-weight: 700; margin-top: 8px; }
.placeholder-t2 { font-size: 12px; color: var(--dim); margin-top: 4px; }

/* ---------- 浮层/弹窗 ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.ov-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 26px;
  display: flex; flex-direction: column;
}
.ov-title { font-size: 20px; font-weight: 700; text-align: center; margin-top: 6px; }
.ov-sub { font-size: 12px; color: var(--accent); text-align: center; margin: 6px 0 14px 0; }
.ov-row { display: flex; font-size: 13px; margin-top: 8px; }
.ov-key { width: 92px; color: var(--text); }
.ov-btns { text-align: center; margin-top: 14px; }

.ov-about { width: 360px; }
.ov-sponsor { width: 520px; }
.sp-tip { text-align: center; font-size: 12px; color: var(--dim); margin-bottom: 12px; }
.sp-body { display: flex; gap: 16px; }
.sp-qr img { width: 200px; height: 200px; object-fit: contain; cursor: zoom-in; }
.sp-list { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sp-list-title { font-size: 14px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
#sp-list-body { flex: 1; overflow-y: auto; max-height: 200px; font-size: 13px; }
.sp-item { display: flex; justify-content: space-between; padding: 3px 0; }
.sp-item .amt { color: var(--accent2); font-weight: 700; }

#hover-preview {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 90;
}
#hover-preview img {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  max-width: 760px; max-height: 560px;
  object-fit: contain;
}

/* ---------- 通知 / 下载进度 ---------- */
#toast-wrap {
  position: fixed; right: 16px; bottom: 46px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200; pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent2);
  border-radius: 4px;
  padding: 10px 14px;
  min-width: 240px; max-width: 380px;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
  font-size: 12px;
  animation: toast-in .25s ease-out;
}
.toast.ok   { border-left-color: var(--green); }
.toast.err  { border-left-color: var(--err); }
.toast .t-title { font-weight: 700; margin-bottom: 4px; }
.toast .t-body  { color: var(--dim); word-break: break-all; }
.toast.out { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in  { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateX(30px); opacity: 0; } }

.prog-wrap { height: 6px; background: var(--outbg); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.prog-fill { height: 100%; width: 0; background: var(--accent2); border-radius: 3px; transition: width .15s linear; }

/* ---------- 按钮状态 / 动画 ---------- */
.btn-run .spin {
  display: none; width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%;
  animation: rot .7s linear infinite;
  vertical-align: -2px; margin-right: 6px;
}
.btn-run.loading { opacity: .8; cursor: progress; }
.btn-run.loading .spin { display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

.btn-run.flash-ok  { background: var(--green); animation: pulse .5s; }
.btn-run.flash-err { background: var(--err); animation: pulse .5s; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }

.out-line { animation: line-in .2s ease-out; }
@keyframes line-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

#sb-status.flash { animation: sflash .6s; }
@keyframes sflash { 0% { color: var(--accent2); } 100% { color: var(--dim); } }