﻿/* 绔嬩綋娓╁鏁板瓧瀛敓 路 浜や簰鏌ョ湅鍣?   宸ョ▼鏁板瓧瀛敓椋庢牸锛氭繁鑹插簳銆侀潚鑹插己璋冦€佺粏杈规銆佺瓑瀹芥暟瀛?*/

:root {
  --bg: #070b10;
  --bg-panel: #0d131a;
  --bg-panel-2: #111a23;
  --bg-elevated: #16212c;
  --line: #223140;
  --line-soft: #1a2632;
  --text: #dbe6ee;
  --text-dim: #8b9caa;
  --text-faint: #5f7180;
  --accent: #4fc3e8;
  --accent-soft: rgba(79, 195, 232, 0.14);
  --accent-line: rgba(79, 195, 232, 0.4);
  --warn: #ffc247;
  --danger: #ff6b6b;
  --ok: #5fd39a;
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --mono: "Consolas", "Cascadia Mono", "SFMono-Regular", "Menlo", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: 272px 1fr 308px;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  width: 100vw;
  background:
    radial-gradient(1200px 700px at 55% 45%, rgba(30, 62, 82, 0.18), transparent 70%),
    var(--bg);
}

/* ---------------- 椤舵爮 ---------------- */
#topbar {
  grid-column: 1 / 4;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px;
  background: linear-gradient(180deg, #0e1620 0%, #0a1118 100%);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 250px; }

.brand-mark {
  width: 34px; height: 34px;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  position: relative;
  background: var(--accent-soft);
  box-shadow: inset 0 0 12px rgba(79, 195, 232, 0.18);
}
.brand-mark span {
  position: absolute;
  left: 6px; right: 6px;
  height: 1px;
  background: var(--accent);
  opacity: 0.75;
}
.brand-mark span:nth-child(1) { top: 10px; }
.brand-mark span:nth-child(2) { top: 16px; opacity: 0.45; }
.brand-mark span:nth-child(3) { top: 22px; opacity: 0.25; }
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  top: 6px; bottom: 6px;
  width: 1px;
  background: var(--accent);
  opacity: 0.5;
}
.brand-mark::before { left: 11px; }
.brand-mark::after { right: 11px; }

.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #eaf4fb;
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 9.5px;
  letter-spacing: 1.6px;
  color: var(--text-faint);
  font-family: var(--mono);
}

#stats {
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin-left: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(10, 17, 24, 0.6);
}
.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 5px 11px;
  min-width: 64px;
  border-right: 1px solid var(--line-soft);
}
.stat:last-child { border-right: 0; }
.stat label {
  font-size: 9.5px;
  letter-spacing: 1.4px;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.stat b {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat.wide b { color: var(--warn); font-family: inherit; font-size: 12.5px; letter-spacing: 1px; }

.top-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------------- 鎸夐挳 ---------------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) {
  border-color: var(--accent-line);
  background: #1b2834;
  color: #f2fbff;
  box-shadow: 0 0 0 1px rgba(79, 195, 232, 0.12) inset;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.primary {
  border-color: rgba(79, 195, 232, 0.55);
  background: linear-gradient(180deg, rgba(79, 195, 232, 0.22), rgba(79, 195, 232, 0.08));
  color: #d9f5ff;
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, rgba(79, 195, 232, 0.34), rgba(79, 195, 232, 0.14)); }
.btn.tiny { padding: 2px 7px; font-size: 10.5px; border-radius: 3px; }
.btn.chip { flex: 1 1 calc(50% - 4px); text-align: center; padding: 4px 5px; font-size: 11.5px; }
.btn.chip.active { border-color: var(--accent); color: #d9f5ff; background: var(--accent-soft); }
.btn.preset { text-align: center; padding: 5px 5px; font-size: 12px; }
.btn.preset.active { border-color: var(--accent); color: #d9f5ff; background: var(--accent-soft); box-shadow: 0 0 12px rgba(79, 195, 232, 0.12); }

/* ---------------- 渚ф爮 ---------------- */
#left-panel, #right-panel {
  background: linear-gradient(180deg, var(--bg-panel) 0%, #0a1017 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  z-index: 10;
}
#left-panel { border-right: 1px solid var(--line); }
#right-panel { border-left: 1px solid var(--line); }

.panel-block {
  padding: 9px 13px 8px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.panel-block.grow { flex: 0 0 auto; min-height: 0; }
.panel-block h2 {
  margin: 0 0 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.8px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.block-head h2 { margin: 0; }
.mini-actions { display: flex; gap: 5px; }

/* 鍥惧眰鍒楄〃 */
.layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, opacity .12s;
}
.layer-item:hover { background: rgba(255, 255, 255, 0.035); border-color: var(--line-soft); }
.layer-item.child { margin-left: 18px; position: relative; }
.layer-item.child::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 50%;
  width: 7px;
  height: 1px;
  background: var(--line);
}
.layer-item.is-off { opacity: .5; }
.layer-item input[type="checkbox"] {
  appearance: none;
  width: 13px; height: 13px;
  border: 1px solid #3c5064;
  border-radius: 3px;
  background: #0a1219;
  cursor: pointer;
  position: relative;
  flex: none;
  margin: 0;
}
.layer-item input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: rgba(79, 195, 232, 0.85);
}
.layer-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3.5px; top: 1px;
  width: 4px; height: 7px;
  border: solid #04131c;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.layer-swatch {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.layer-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.layer-name b {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-name span {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-count {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
  padding: 1px 4px;
  flex: none;
}
.layer-loading { color: var(--text-faint); font-size: 12px; padding: 8px 6px; }

/* 瑙嗚/棰勮鎸夐挳缃戞牸 */
.chip-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.preset-grid .btn:last-child { grid-column: 1 / 3; }

/* 寮€鍏宠 */
.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 5px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
.switch-row:hover { background: rgba(255, 255, 255, 0.035); }
.switch-row input { display: none; }
.switch-box {
  position: relative;
  width: 30px; height: 16px;
  border: 1px solid #3c5064;
  border-radius: 9px;
  background: #0a1219;
  flex: none;
  transition: background .15s, border-color .15s;
}
.switch-box::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #6e8294;
  transition: transform .15s, background .15s;
}
.switch-row input:checked + .switch-box { background: rgba(79, 195, 232, 0.2); border-color: var(--accent); }
.switch-row input:checked + .switch-box::after { transform: translateX(14px); background: var(--accent); }
.switch-text { display: flex; flex-direction: column; line-height: 1.3; font-size: 12.5px; }
.switch-text em { font-style: normal; font-size: 10px; color: var(--text-faint); letter-spacing: .4px; }

.help {
  margin-top: 2px;
  padding: 8px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: .4px;
  border-top: 1px solid var(--line-soft);
}

/* ---------------- 鑸炲彴 ---------------- */
#stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
#viewport-wrap { position: absolute; inset: 0; }
#viewport-wrap canvas { display: block; width: 100%; height: 100%; }

#label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}
.screen-label {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 190px;
  padding: 2px 7px 2px 5px;
  background: rgba(8, 15, 22, 0.82);
  border: 1px solid rgba(79, 195, 232, 0.45);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  color: #d6ecf7;
  font-size: 10.5px;
  line-height: 1.35;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.screen-label i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  box-shadow: 0 0 5px var(--accent);
}

#tooltip {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  padding: 5px 9px;
  background: rgba(6, 12, 18, 0.94);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  max-width: 260px;
  transform: translate(14px, 16px);
}
#tooltip b { display: block; font-size: 12px; font-weight: 500; color: #ecf8ff; line-height: 1.35; }
#tooltip span { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); margin-top: 2px; letter-spacing: .3px; }
#tooltip .tt-layer { display: inline-block; font-size: 9.5px; color: var(--accent); margin-top: 3px; letter-spacing: .5px; }
.hidden { display: none !important; }

/* ---------------- 鍔犺浇 / 閿欒瑕嗙洊灞?---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background:
    radial-gradient(700px 420px at 50% 45%, rgba(24, 58, 78, 0.35), transparent 72%),
    rgba(5, 9, 13, 0.92);
  backdrop-filter: blur(2px);
}
.spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(79, 195, 232, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: 14px; letter-spacing: 2px; color: #cfe9f6; }
.loading-detail { font-family: var(--mono); font-size: 11px; color: var(--text-faint); letter-spacing: .5px; }

.error-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 34px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 8px;
  background: rgba(16, 10, 12, 0.85);
  box-shadow: var(--panel-shadow);
  max-width: 460px;
  text-align: center;
}
.error-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 107, 107, 0.6);
  color: var(--danger);
  font-family: var(--mono);
  font-size: 22px;
  line-height: 36px;
  text-align: center;
}
.error-box h3 { margin: 2px 0 0; font-size: 15px; letter-spacing: 1px; color: #ffd9d9; }
.error-box p { margin: 0; font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.error-detail {
  font-family: var(--mono) !important;
  font-size: 10.5px !important;
  color: var(--text-faint) !important;
  word-break: break-all;
  max-width: 380px;
}
.error-box .btn { margin-top: 6px; }

/* ---------------- 鍙充晶淇℃伅闈㈡澘 ---------------- */
.badge {
  font-size: 10px;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.03);
}
.badge.has { color: var(--warn); border-color: rgba(255, 194, 71, 0.4); background: rgba(255, 194, 71, 0.08); }

.info-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 8px;
  text-align: center;
  color: var(--text-faint);
}
.info-empty-icon {
  width: 46px; height: 46px;
  border: 1px dashed #2b3d4d;
  border-radius: 6px;
  position: relative;
  margin-bottom: 4px;
}
.info-empty-icon::before,
.info-empty-icon::after {
  content: "";
  position: absolute;
  background: #2b3d4d;
}
.info-empty-icon::before { left: 8px; right: 8px; top: 22px; height: 1px; }
.info-empty-icon::after { top: 8px; bottom: 8px; left: 22px; width: 1px; }
.info-empty p { margin: 0; font-size: 11.5px; }
.info-empty .dim { color: #48596a; font-size: 10.5px; }

.info-list { margin: 0; display: flex; flex-direction: column; gap: 1px; }
.info-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line-soft);
  align-items: baseline;
}
.info-row:last-child { border-bottom: 0; }
.info-row dt {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-faint);
  white-space: nowrap;
}
.info-row dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.info-row dd.mono { font-family: var(--mono); font-size: 11px; color: #c7dbe7; letter-spacing: .2px; }
.info-row dd.spec { font-size: 11.5px; color: #b9cdd9; }
.info-row dd .layer-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: 1px;
}
.info-row dd .layer-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-faint);
  margin-left: 6px;
}
.info-row dd b { font-weight: 500; }

.info-actions { display: flex; gap: 8px; margin-top: 14px; }
.info-actions .btn { flex: 1; }

.legend-block { max-height: 34%; overflow: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-dim); }
.legend-item i { width: 7px; height: 7px; border-radius: 2px; flex: none; }

/* 婊氬姩鏉?*/
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #223140; border-radius: 4px; border: 2px solid #0d131a; }
::-webkit-scrollbar-thumb:hover { background: #2e4356; }

/* 绐勫睆鍏滃簳 */
@media (max-width: 1180px) {
  #app { grid-template-columns: 240px 1fr 260px; }
  .brand-text p { display: none; }
  #stats .stat { min-width: 66px; padding: 5px 10px; }
}
@media (max-width: 900px) {
  #app { grid-template-columns: 210px 1fr; grid-template-rows: 56px 1fr; }
  #right-panel { display: none; }
}

/* file:// direct-open guidance (double-clicking viewer/index.html) */
#loading.file-protocol-alert {
  background:
    radial-gradient(circle at 50% 42%, rgba(236, 178, 61, 0.10), transparent 46%),
    rgba(7, 12, 17, 0.96);
}
#loading.file-protocol-alert .loading-title {
  color: #ffd166;
  font-size: 24px;
  letter-spacing: 0.3px;
  margin-bottom: 14px;
}
#loading.file-protocol-alert .loading-detail {
  color: #d8e7ef;
  font-size: 15px;
  line-height: 1.85;
  max-width: 760px;
  text-align: left;
  padding: 18px 24px;
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 10px;
  background: rgba(12, 22, 30, 0.92);
}
#loading.file-protocol-alert .loading-detail code {
  color: #7fd6ff;
  background: rgba(64, 145, 180, 0.16);
  border: 1px solid rgba(127, 214, 255, 0.22);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono, "Cascadia Mono", Consolas, monospace);
}
