* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, "Segoe UI", "PingFang SC", sans-serif; background: #1a1d23; color: #e0e3e8; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: #232830; border-bottom: 1px solid #2d333b;
}
header h1 { font-size: 18px; font-weight: 600; color: #4fc3f7; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.status { font-size: 12px; color: #8a96a3; }
.status.error { color: #ff6b6b; }
.status.ok { color: #51cf66; }

main { display: flex; height: calc(100% - 90px); position: relative; }

/* Tab 面板容器: 仅 active 显示 */
.tab-panel { display: none; flex: 0 0 380px; }
.tab-panel.active { display: block; }
#font-sidebar { padding: 12px; background: #1f242c; border-right: 1px solid #2d333b; height: 100%; overflow-y: auto; }

#sidebar {
  width: 380px; overflow-y: auto; padding: 12px;
  background: #1f242c; border-right: 1px solid #2d333b;
}
.panel {
  background: #262c35; border-radius: 6px; padding: 12px;
  margin-bottom: 12px; border: 1px solid #2d333b;
}
.panel h2 { font-size: 13px; margin-bottom: 8px; color: #b8c2cc; font-weight: 600; }
.panel h2 .badge {
  background: #4fc3f7; color: #1a1d23; padding: 2px 6px;
  border-radius: 3px; font-size: 11px; margin-left: 4px;
}
.panel label {
  display: block; font-size: 12px; margin: 6px 0; color: #b8c2cc;
}
.panel input[type="text"], .panel input[type="number"] {
  width: 100%; padding: 6px 8px; border: 1px solid #3a4150;
  background: #1a1d23; color: #e0e3e8; border-radius: 4px;
  font-size: 13px; margin-top: 3px;
}
.panel input[type="text"]:focus, .panel input[type="number"]:focus {
  outline: none; border-color: #4fc3f7;
}
.panel input[type="checkbox"] {
  margin-right: 6px;
}
.inline-label { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.inline-num {
  width: 70px !important; padding: 3px 6px !important;
  font-size: 12px !important; display: inline-block !important;
  margin: 0 2px !important;
}
.hint { font-size: 11px; color: #6b7785; margin-top: 4px; line-height: 1.4; }

.btn {
  padding: 6px 12px; border: 1px solid #3a4150; background: #2d333b;
  color: #e0e3e8; border-radius: 4px; cursor: pointer; font-size: 12px;
  transition: background 0.15s;
}
.btn:hover { background: #3a4150; }
.btn.primary { background: #4fc3f7; color: #1a1d23; border-color: #4fc3f7; font-weight: 600; }
.btn.primary:hover { background: #29b6f6; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.actions .btn { width: 100%; margin-bottom: 6px; }
.check-result {
  margin-top: 8px; padding: 8px; border-radius: 4px;
  background: #1a1d23; font-size: 11px; line-height: 1.5;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  max-height: 200px; overflow-y: auto;
  white-space: pre-wrap;
}
.check-result.ok { border-left: 3px solid #51cf66; }
.check-result.warn { border-left: 3px solid #ffd43b; }
.check-result.error { border-left: 3px solid #ff6b6b; }

.char-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
  margin-top: 8px;
}
.map-toolbar {
  display: flex; gap: 6px; margin-top: 6px;
}
.map-toolbar .btn { flex: 1; font-size: 11px; padding: 5px 8px; }
.map-toolbar .btn.saved { background: #51cf66; color: #1a1d23; border-color: #51cf66; }
.map-toolbar .btn.dirty { background: #ffd43b; color: #1a1d23; border-color: #ffd43b; }
.char-item {
  background: #1a1d23; border: 1px solid #3a4150; border-radius: 4px;
  padding: 4px; text-align: center; cursor: pointer;
  transition: all 0.15s;
  font-size: 14px; font-weight: 600;
}
.char-item:hover { border-color: #4fc3f7; background: #2d333b; }
.char-item.selected { border-color: #4fc3f7; background: #2d333b; }
.char-item.digit { border-color: #5a3a78; }
.char-item.digit:hover { border-color: #cc5de8; }
.char-item.unknown { opacity: 0.5; border-style: dashed; }
.char-item.unknown .char-label { color: #ff6b6b; }
.char-item .char-thumb {
  width: 100%; aspect-ratio: 1; background: #0f1216;
  border-radius: 2px; margin-bottom: 2px;
  display: flex; align-items: center; justify-content: center;
}
.char-item .char-thumb svg { width: 90%; height: 90%; }

#viewport {
  flex: 1; position: relative; background: #0f1216;
}
#three-container { width: 100%; height: 100%; }
#viewport-info {
  position: absolute; bottom: 10px; left: 10px;
  background: rgba(0,0,0,0.6); padding: 6px 10px;
  border-radius: 4px; font-size: 11px;
  display: flex; gap: 12px; color: #b8c2cc;
}

/* 视角切换按钮 */
#view-controls {
  position: absolute; top: 10px; left: 10px;
  display: flex; gap: 4px; z-index: 1000;
  pointer-events: auto;
}
.vc-btn {
  padding: 7px 12px; font-size: 12px;
  background: rgba(15,18,22,0.92); color: #b8c2cc;
  border: 1px solid #4fc3f7; border-radius: 4px;
  cursor: pointer; font-family: ui-monospace, "SF Mono", Consolas, monospace;
  transition: all 0.15s;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}
.vc-btn:hover { background: #4fc3f7; color: #1a1d23; border-color: #4fc3f7; font-weight: 600; }
.vc-btn:active { background: #29b6f6; color: #1a1d23; transform: scale(0.96); }
.vc-btn.active { background: #4fc3f7; color: #1a1d23; border-color: #4fc3f7; font-weight: 600; }

/* Tab 导航 */
#tab-bar {
  display: flex; background: #1f242c; border-bottom: 1px solid #2d333b;
  padding: 0 20px; gap: 4px;
}
.tab-btn {
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  background: transparent; color: #8a96a3;
  border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: all 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: #b8c2cc; background: rgba(79,195,247,0.08); }
.tab-btn.active {
  color: #4fc3f7; border-bottom-color: #4fc3f7;
  background: rgba(79,195,247,0.05);
}

/* Scrollbar */
#sidebar::-webkit-scrollbar { width: 8px; }
#sidebar::-webkit-scrollbar-track { background: #1a1d23; }
#sidebar::-webkit-scrollbar-thumb { background: #3a4150; border-radius: 4px; }

/* Inline progress panel (in actions panel) */
.progress-panel {
  margin-top: 10px;
  padding: 12px;
  background: #1a1d23;
  border: 1px solid #3a4150;
  border-radius: 6px;
  border-left: 3px solid #4fc3f7;
}
.progress-panel[hidden] { display: none; }
.progress-panel.done { border-left-color: #51cf66; }
.progress-panel.error { border-left-color: #ff6b6b; }

.progress-panel h3 {
  font-size: 13px; color: #b8c2cc; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600;
}
.progress-panel h3 #progress-title-text {
  flex: 1;
  color: #4fc3f7;
}
.progress-panel.done h3 #progress-title-text { color: #51cf66; }
.progress-panel.error h3 #progress-title-text { color: #ff6b6b; }

.progress-spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid #3a4150; border-top-color: #4fc3f7;
  border-radius: 50%; animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
.progress-panel.done .progress-spinner { display: none; }
.progress-panel.error .progress-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-wrap {
  background: #0f1216; border-radius: 4px; height: 10px;
  overflow: hidden; margin-bottom: 6px;
  border: 1px solid #2d333b;
}
.progress-bar {
  background: linear-gradient(90deg, #4fc3f7, #29b6f6);
  height: 100%; width: 0; transition: width 0.25s ease;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.5);
}
.progress-panel.done .progress-bar { background: #51cf66; box-shadow: 0 0 8px rgba(81, 207, 102, 0.5); }
.progress-panel.error .progress-bar { background: #ff6b6b; box-shadow: 0 0 8px rgba(255, 107, 107, 0.5); }

.progress-percent {
  text-align: right; font-size: 11px; color: #8a96a3;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  margin-bottom: 8px;
}

.progress-log {
  list-style: none; max-height: 180px; overflow-y: auto;
  font-size: 11px; line-height: 1.55;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  padding: 0; margin: 0;
}
.progress-log li {
  color: #b8c2cc; padding: 2px 4px;
  display: flex; gap: 8px;
  border-radius: 3px;
}
.progress-log li .step { color: #6b7785; flex-shrink: 0; width: 14px; }
.progress-log li.pending { color: #6b7785; opacity: 0.6; }
.progress-log li.pending .step { color: #4a5260; }
.progress-log li.active { color: #4fc3f7; background: rgba(79, 195, 247, 0.08); }
.progress-log li.active .step { color: #4fc3f7; }
.progress-log li.done { color: #51cf66; }
.progress-log li.done .step { color: #51cf66; }
.progress-log li.error { color: #ff6b6b; background: rgba(255, 107, 107, 0.08); }
.progress-log li.error .step { color: #ff6b6b; }

/* Scrollbar for progress log */
.progress-log::-webkit-scrollbar { width: 6px; }
.progress-log::-webkit-scrollbar-track { background: #0f1216; }
.progress-log::-webkit-scrollbar-thumb { background: #3a4150; border-radius: 3px; }