:root {
  --bg: #0e1116;
  --bg2: #151a21;
  --bg3: #1c232c;
  --line: #2a333f;
  --fg: #e6ecf3;
  --fg2: #8b98a8;
  --accent: #37d0a0;
  --accent2: #2b9fd8;
  --warn: #e0a33c;
  --danger: #e05c5c;
  --h-top: 52px;
  --h-status: 30px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶栏 ---------- */
#top {
  height: var(--h-top); display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--bg2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand .logo { color: var(--accent); font-size: 18px; }
.brand .title { font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.brand .sub { font-size: 12px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 8px; flex: none; }
button.primary {
  background: var(--accent); color: #06201a; border: 0; border-radius: 6px;
  padding: 7px 14px; font-size: 14px; font-weight: 600;
}
button.primary:hover { filter: brightness(1.1); }

/* ---------- 布局 ---------- */
#app { display: flex; height: calc(100% - var(--h-top)); }
#sidebar {
  width: 250px; flex: none; background: var(--bg2); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 10px;
}
#sidebar.hidden { display: none; }
.panel { margin-bottom: 14px; }
.panel.hidden { display: none; }
.panel h3 {
  margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--fg2);
  text-transform: uppercase; letter-spacing: .8px; display: flex; justify-content: space-between;
}
.panel .cnt { color: var(--accent); font-weight: 400; }
.list { background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; max-height: 34vh; overflow-y: auto; }
.list.info { max-height: none; }
.row { display: flex; align-items: center; gap: 8px; padding: 5px 9px; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.04); }
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(255,255,255,.03); }
.row input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; flex: none; }
.row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; border: 1px solid rgba(255,255,255,.25); }
.row .dim { color: var(--fg2); font-size: 12px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 9px; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.04); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--fg2); flex: none; }
.kv .v { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 视图区 ---------- */
#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#viewerWrap { flex: 1; position: relative; overflow: hidden; background: #0a0d11; }
#viewerHost { position: absolute; inset: 0; }
#viewerHost canvas { display: block; width: 100% !important; height: 100% !important; }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; }

/* 拖拽层 */
#drop { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: 16px; }
#drop.hidden { display: none; }
#drop.over { background: rgba(55,208,160,.07); }
.dropbox {
  width: 100%; max-width: 560px; text-align: center; padding: 34px 22px;
  border: 2px dashed var(--line); border-radius: 14px; background: rgba(21,26,33,.7);
}
#drop.over .dropbox { border-color: var(--accent); }
.dropbox .big { font-size: 19px; font-weight: 600; margin-bottom: 6px; }
.dropbox .small { font-size: 13px; color: var(--fg2); }
.dropbox .small u { color: var(--accent2); cursor: pointer; }
.dropbox .formats { margin-top: 14px; font-size: 12px; color: var(--fg2); line-height: 1.9; }
.dropbox .formats b { color: var(--fg); }
.dropbox .note { margin-top: 12px; font-size: 12px; color: var(--warn); }

/* 忙碌 */
#busy {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center;
  gap: 10px; background: rgba(10,13,17,.72); font-size: 13px;
}
#busy.hidden { display: none; }
.spin {
  width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- 工具栏 ---------- */
#toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 7px 10px; background: var(--bg2); border-top: 1px solid var(--line);
}
#toolbar.hidden { display: none; }
#toolbar button {
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 11px; font-size: 13px;
}
#toolbar button:hover { border-color: var(--accent); color: var(--accent); }
#toolbar button.on { background: var(--accent); color: #06201a; border-color: var(--accent); font-weight: 600; }
#toolbar button:disabled { opacity: .4; cursor: default; }
#toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
#toolbar label { font-size: 13px; color: var(--fg2); display: flex; align-items: center; gap: 6px; }
#toolbar input[type=range] { width: 110px; accent-color: var(--accent); }

/* ---------- 状态栏 ---------- */
#status {
  height: var(--h-status); display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 0 12px; background: var(--bg3); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--fg2);
}
#statusMain { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#statusMain.err { color: var(--danger); }
#statusMain.ok { color: var(--accent); }

/* 图片/PDF 视图 */
#imgView, #pdfView { position: absolute; inset: 0; overflow: auto; display: none; z-index: 3; }
#imgView.on, #pdfView.on { display: block; }
#imgView img { display: block; margin: 0 auto; max-width: none; }
#pdfView canvas { display: block; margin: 12px auto; box-shadow: 0 4px 24px rgba(0,0,0,.6); background: #fff; }

/* ---------- 移动端 ---------- */
@media (max-width: 820px) {
  :root { --h-top: 48px; }
  .brand .sub { display: none; }
  #app { flex-direction: column; }
  #sidebar {
    width: 100%; order: 2; border-right: 0; border-top: 1px solid var(--line);
    max-height: 40vh; padding: 8px;
  }
  #stage { order: 1; }
  .list { max-height: 22vh; }
  #toolbar { padding: 6px; gap: 5px; overflow-x: auto; flex-wrap: nowrap; }
  #toolbar button { padding: 7px 10px; white-space: nowrap; }
  .dropbox { padding: 24px 14px; }
  .dropbox .big { font-size: 17px; }
}

/* ---- 编码选择器 / 警告标记 ---- */
#toolbar label.sel { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted, #8b93a1); white-space: nowrap; }
#toolbar label.sel select {
  background: #171b22; color: #d8dee9; border: 1px solid #2a303a; border-radius: 6px;
  padding: 6px 6px; font-size: 12px; outline: none;
}
.warnTag { display: inline-block; margin-top: 6px; padding: 2px 7px; border-radius: 999px;
  background: rgba(240, 180, 41, .14); color: #f0b429; font-size: 11px; border: 1px solid rgba(240,180,41,.3); }
