:root {
  --bg: #0b1220;
  --panel: #111a2b;
  --panel-2: #182338;
  --panel-3: #0f1727;
  --text: #eaf2ff;
  --muted: #90a4c3;
  --line: #253553;
  --accent: #4f8cff;
  --success: #33c27f;
  --danger: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
body.light {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-2: #f7f9fd;
  --panel-3: #edf3fb;
  --text: #15233b;
  --muted: #5f6f89;
  --line: #dbe5f1;
  --accent: #2f6fff;
  --success: #1d9c63;
  --danger: #dc4d4d;
  --shadow: 0 10px 30px rgba(44, 69, 115, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif; }
body { min-height: 100vh; }
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; gap: 16px; padding: 16px 18px;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--panel), var(--panel-2));
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.control { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; }
.control span,.muted,.status { color: var(--muted); font-size: 13px; }
select,.filename { background: transparent; color: var(--text); border: none; outline: none; font-size: 14px; }
.btn { height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.upload-btn { display: inline-flex; align-items: center; }
.workspace { flex: 1; display: grid; grid-template-columns: 260px 1.2fr 0.9fr; gap: 16px; padding: 16px; min-height: 0; }
.sidebar,.center-panel,.preview-panel { min-height: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); overflow: hidden; box-shadow: var(--shadow); }
.sidebar { display: flex; flex-direction: column; }
.sidebar-head,.panel-header,.editor-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.tabs-list { padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.tab-item {
  padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-3); cursor: pointer;
}
.tab-item.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tab-item .name { font-weight: 600; display: block; margin-bottom: 6px; word-break: break-all; }
.tab-item .meta { color: var(--muted); font-size: 12px; }
.tab-item .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-btn { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; padding: 4px 8px; }
.mini-btn.delete:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.center-panel { display: flex; flex-direction: column; }
.tabbar { display: flex; gap: 8px; overflow: auto; flex: 1; }
.editor-tab {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-3); cursor: pointer; white-space: nowrap;
}
.editor-tab.active { border-color: var(--accent); color: #fff; background: var(--accent); }
.editor-meta { display: flex; align-items: center; gap: 12px; }
.filename { min-width: 220px; font-weight: 600; }
.editor-container { flex: 1; min-height: 420px; }
.preview-panel { display: flex; flex-direction: column; }
.preview-actions { display: flex; gap: 8px; }
.preview-hint { padding: 14px 16px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.6; }
#previewFrame { flex: 1; width: 100%; border: none; background: #fff; min-height: 360px; }
.status.saved { color: var(--success); }
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .toolbar { justify-content: flex-start; }
  .sidebar { max-height: 260px; }
  .editor-container { min-height: 52vh; }
  #previewFrame { min-height: 42vh; }
}
