/* ============================================================
 * MC 建筑导入器 · VECTNEL
 * ============================================================ */

:root {
  --bg: #0b0f14;
  --bg-soft: #10151c;
  --panel: #141a22;
  --panel-2: #182029;
  --border: #222c38;
  --border-soft: #1b232d;
  --text: #e6edf3;
  --text-dim: #8b98a8;
  --text-faint: #5f6b7a;
  --accent: #10b981;
  --accent-dim: #0d9668;
  --accent-glow: rgba(16, 185, 129, 0.18);
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(16, 185, 129, 0.07), transparent 65%),
    radial-gradient(700px 420px at 92% 8%, rgba(56, 189, 248, 0.05), transparent 60%);
}

code { font-family: var(--mono); font-size: 0.92em; }

.hidden { display: none !important; }

/* ------------------------- 顶栏 ------------------------- */

.topbar {
  flex: 0 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.82);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; box-shadow: 0 0 22px rgba(16, 185, 129, 0.28); }
.brand-text h1 { font-size: 15px; font-weight: 650; letter-spacing: 0.2px; }
.brand-text span { font-size: 11px; color: var(--text-faint); letter-spacing: 0.6px; text-transform: uppercase; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.badge-local {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--accent);
  background: rgba(16, 185, 129, 0.09);
  border: 1px solid rgba(16, 185, 129, 0.24);
  padding: 5px 11px; border-radius: 999px;
}

.topbar-link {
  font-size: 13px; color: var(--text-dim); text-decoration: none;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  transition: all 0.18s;
}
.topbar-link:hover { color: var(--text); border-color: var(--accent); background: var(--accent-glow); }

/* ------------------------- 主区 ------------------------- */

#app { flex: 1 1 auto; position: relative; overflow: hidden; }

/* ------------------------- 上传区 ------------------------- */

.dropzone {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  overflow: hidden;
}

.dz-grid {
  position: absolute; inset: -40%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 46px 46px;
  transform: perspective(560px) rotateX(58deg);
  mask-image: radial-gradient(closest-side, #000 25%, transparent 78%);
  -webkit-mask-image: radial-gradient(closest-side, #000 25%, transparent 78%);
  pointer-events: none;
  animation: gridDrift 26s linear infinite;
}

@keyframes gridDrift { from { background-position: 0 0; } to { background-position: 92px 92px; } }

.dz-inner {
  position: relative;
  width: min(680px, 100%);
  padding: 46px 40px 34px;
  border-radius: 20px;
  border: 1.5px dashed var(--border);
  background: linear-gradient(180deg, rgba(20, 26, 34, 0.86), rgba(16, 21, 28, 0.72));
  backdrop-filter: blur(8px);
  text-align: center;
  transition: border-color 0.22s, background 0.22s, transform 0.22s;
}

.dropzone.dragover .dz-inner {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.1), rgba(16, 21, 28, 0.8));
  transform: translateY(-2px);
  box-shadow: 0 18px 50px -12px rgba(16, 185, 129, 0.28);
}

.dz-icon {
  width: 62px; height: 62px; margin: 0 auto 20px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.26);
  color: var(--accent);
}
.dz-icon svg { width: 28px; height: 28px; }

.dz-inner h2 { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.dz-sub { font-size: 13.5px; color: var(--text-dim); margin-bottom: 24px; line-height: 1.7; }
.dz-sub code {
  background: var(--panel-2); border: 1px solid var(--border-soft);
  padding: 2px 7px; border-radius: 6px; color: var(--accent); margin: 0 1px;
}

.btn {
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 11px 30px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: all 0.18s;
}
.btn-primary {
  background: linear-gradient(180deg, #12c98b, var(--accent-dim));
  color: #04120c; border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px -6px rgba(16, 185, 129, 0.6);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-link {
  display: block;
  margin: 14px auto 0;
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: 12.5px;
  color: var(--text-faint);
  padding: 4px 8px; border-radius: 6px;
  transition: color 0.16s;
}
.btn-link:hover { color: var(--accent); }

.dz-formats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--border-soft);
}
.fmt { text-align: left; }
.fmt b { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-dim); }
.fmt span { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }

/* ------------------------- 工作区 ------------------------- */

.workspace {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: 1fr 348px;
}

.stage { position: relative; overflow: hidden; background: #12161c; }
#canvas { display: block; width: 100%; height: 100%; }

.stage-toolbar {
  position: absolute; top: 16px; left: 16px;
  display: flex; flex-direction: column; gap: 8px;
}

.tool {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(20, 26, 34, 0.88);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.16s;
}
.tool:hover { color: var(--accent); border-color: rgba(16, 185, 129, 0.45); background: rgba(16, 185, 129, 0.1); }
.tool svg { width: 17px; height: 17px; }

.stage-hint {
  position: absolute; bottom: 16px; left: 16px;
  font-size: 11.5px; color: var(--text-faint);
  background: rgba(11, 15, 20, 0.7);
  padding: 6px 11px; border-radius: 8px;
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.layer-panel {
  position: absolute; top: 16px; right: 16px;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: rgba(20, 26, 34, 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  font-size: 12px; color: var(--text-dim);
}
.layer-panel input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 108px; height: 3px; border-radius: 2px;
  background: var(--border);
  outline: none; cursor: pointer;
}
.layer-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b0f14; cursor: grab;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.layer-panel input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; background: var(--accent);
  border: 2px solid #0b0f14; cursor: grab;
}
#layerValue { min-width: 32px; text-align: right; font-family: var(--mono); color: var(--accent); }

/* ------------------------- 侧栏 ------------------------- */

.sidebar {
  border-left: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  padding: 18px 16px 26px;
  display: flex; flex-direction: column; gap: 16px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #232d3a; border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.file-card {
  padding: 14px 15px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), rgba(24, 32, 41, 0.6));
  border: 1px solid var(--border);
}
.file-format {
  display: inline-block;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent); background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.24);
  padding: 3px 8px; border-radius: 5px; margin-bottom: 9px;
}
.file-name {
  font-size: 14px; font-weight: 600; word-break: break-all; line-height: 1.45;
}
.file-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  padding: 11px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border-soft);
}
.stat-k { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.stat b { font-size: 15px; font-weight: 600; font-family: var(--mono); letter-spacing: -0.3px; }

.section { border-top: 1px solid var(--border-soft); padding-top: 15px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 11px;
}
.section-head h3 { font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.4px; }
.section-head span { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

.palette-list {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 260px; overflow-y: auto; padding-right: 4px;
}
.palette-list::-webkit-scrollbar { width: 6px; }
.palette-list::-webkit-scrollbar-thumb { background: #232d3a; border-radius: 3px; }

.pal-row {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; border-radius: 7px;
  font-size: 12px; transition: background 0.14s;
}
.pal-row:hover { background: var(--panel-2); }
.pal-sw {
  width: 13px; height: 13px; border-radius: 3.5px; flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.28);
}
.pal-name {
  flex: 1 1 auto; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 11.5px;
}
.pal-count { color: var(--text-faint); font-family: var(--mono); font-size: 11px; }
.pal-bar {
  flex: 0 0 46px; height: 4px; border-radius: 2px;
  background: var(--border); overflow: hidden;
}
.pal-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* 导出 */

.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.exp {
  text-align: left; cursor: pointer;
  padding: 10px 12px; border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  transition: all 0.16s;
}
.exp b { display: block; font-size: 12.5px; font-weight: 550; margin-bottom: 3px; }
.exp span { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); }
.exp:hover {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.08);
  transform: translateY(-1px);
}
.exp:hover b { color: var(--accent); }
.exp:active { transform: translateY(0); }
.exp[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.toggle {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; font-size: 12px; color: var(--text-dim); cursor: pointer;
}
.toggle input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.toggle code { color: var(--accent); font-size: 11px; }

/* ------------------------- Toast / Loading ------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 34px;
  transform: translate(-50%, 20px);
  padding: 11px 20px; border-radius: 10px;
  background: rgba(24, 32, 41, 0.96);
  border: 1px solid var(--border);
  color: var(--text); font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 100; max-width: 80vw;
  box-shadow: 0 12px 34px -10px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.toast.ok { border-color: rgba(16, 185, 129, 0.5); }

.loading {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  background: rgba(11, 15, 20, 0.78);
  backdrop-filter: blur(6px);
}
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(16, 185, 129, 0.16);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text-dim); }

/* ------------------------- 页脚 ------------------------- */

.footer {
  flex: 0 0 auto;
  height: 34px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 11.5px; color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  background: rgba(11, 15, 20, 0.6);
}
.footer .dot { opacity: 0.4; }

/* ------------------------- 响应式 ------------------------- */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar {
    border-left: none; border-top: 1px solid var(--border);
    max-height: 44vh; padding: 14px;
  }
  .stage-hint { display: none; }
  .layer-panel { top: auto; bottom: 14px; right: 14px; }
  .badge-local { display: none; }
  .dz-formats { grid-template-columns: 1fr; gap: 12px; }
  .dz-inner { padding: 32px 22px 26px; }
  .dz-inner h2 { font-size: 17px; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 14px; height: 54px; }
  .brand-text span { display: none; }
  .export-grid { grid-template-columns: 1fr; }
}
