* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f5f7fa;
  color: #1f2937;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  height: 52px; box-sizing: border-box;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  color: #fff;
  flex-wrap: wrap;
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 22px; }
.title { font-weight: 700; font-size: 18px; }
.subtitle { font-size: 12px; opacity: 0.85; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar select, .toolbar .btn {
  font-size: 13px;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.toolbar select { background: #fff; color: #1f2937; }
.more-field { display: flex; flex-direction: column; gap: 4px; color: #475569; font-size: 12px; margin-bottom: 8px; }
.more-field select { width: 100%; border: 1px solid #cbd5e1; }
.btn.more-action { width: 100%; margin-top: 4px; background: #eef2ff; color: #4338ca; }
.more-section { font-size: 12px; color: #64748b; margin: 8px 0 2px; padding-bottom: 4px; border-bottom: 1px solid #e2e8f0; }

.btn { background: rgba(255,255,255,0.18); color: #fff; }
.btn.ai-action { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); color: #fff; font-weight: 600; width: 100%; margin-top: 4px; }
.btn.primary { background: #22c55e; font-weight: 600; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.status { font-size: 13px; margin-left: 6px; }
.status.running { color: #fde68a; }
.status.ok { color: #bbf7d0; }
.status.warn { color: #fcd34d; }
.status.error { color: #fecaca; }

.workspace {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 280px;
  min-height: 0;
}
.editor-pane { min-height: 0; border-bottom: 2px solid #e5e7eb; display: flex; flex-direction: column; }
.file-tabs { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 4px; align-items: stretch;
  padding: 4px 8px; background: #f1f5f9; border-bottom: 1px solid #e5e7eb; overflow-x: auto; }
.file-tab { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 10px; border-radius: 6px 6px 0 0;
  background: #e2e8f0; color: #475569; font-size: 13px; cursor: pointer; white-space: nowrap; user-select: none; }
.file-tab:hover { background: #d9e2ec; }
.file-tab.active { background: #fff; color: #0f172a; font-weight: 600; box-shadow: inset 0 -2px 0 #2563eb; }
.file-tab .ft-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.file-tab-close { font-size: 14px; line-height: 1; padding: 0 2px; border-radius: 4px; color: #94a3b8; }
.file-tab-close:hover { color: #ef4444; background: #fee2e2; }
.file-tab.add { background: transparent; color: #2563eb; font-weight: 600; padding: 5px 10px; }
.file-tab.add:hover { background: #dbeafe; }
#editor { width: 100%; height: 100%; flex: 1 1 auto; min-height: 0; }

.bottom-pane {
  display: grid;
  /* 第 5 行是运行产物栏，隐藏时 display:none 不占高度 */
  grid-template-rows: auto 70px auto 1fr auto;
  background: #fff;
  min-height: 0;
}
.pane-header {
  background: #eef2ff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  color: #4338ca;
}
#stdin {
  border: none;
  border-bottom: 1px solid #e5e7eb;
  resize: none;
  padding: 6px 10px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  outline: none;
}
#terminal {
  background: #0b1021;
  padding: 6px 8px;
  height: 150px;
}

/* AI 助教浮动按钮（PC 端主入口；手机端隐藏，改用「更多」菜单） */
.ai-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 88;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.ai-fab-subs {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}
.ai-fab.open .ai-fab-subs { opacity: 1; visibility: visible; transform: translateY(0); }
.ai-fab-main {
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 18px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 20px rgba(79,70,229,0.35);
}
.ai-fab-icon { font-size: 18px; }
.ai-fab-sub {
  padding: 8px 14px; border: 1px solid #c7d2fe; border-radius: 999px;
  background: #fff; color: #4338ca; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(15,23,42,0.14); white-space: nowrap;
}
.ai-fab-sub:hover { background: #eef2ff; }
.ai-fab-main:hover { filter: brightness(1.06); }
.ai-fab-main:active { transform: scale(0.97); }

/* PC 端左侧固定边栏：我的项目 + 设置 */
body { padding-left: 56px; }
.left-bar {
  position: fixed; left: 0; top: 52px; bottom: 0; width: 56px; z-index: 100;
  background: #fff; border-right: 1px solid #e2e8eb;
  display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 14px;
}
.left-bar-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 48px; padding: 8px 0; border: none; border-radius: 8px;
  background: transparent; color: #475569; font-size: 11px; cursor: pointer;
}
.left-bar-btn:hover { background: #eef2ff; }
.left-bar-btn.active { background: #e0e7ff; color: #4338ca; }
.left-bar-icon { font-size: 20px; }

/* 设置面板：PC 端从左侧滑出 */
.settings-panel {
  position: fixed; left: -280px; top: 52px; bottom: 0; width: 260px;
  background: #fff; border-right: 1px solid #c7d2fe;
  box-shadow: 2px 0 14px rgba(0,0,0,0.12);
  z-index: 90; transition: left 0.2s ease;
  display: flex; flex-direction: column;
}
.settings-panel.open { left: 56px; }
.settings-head { background: #4f46e5; color: #fff; }
.settings-body { flex: 1; overflow: auto; padding: 10px; }

/* AI 助教面板 */
.ai-panel {
  position: fixed; top: 0; right: -440px; width: 420px; height: 100%;
  background: #fff; box-shadow: -2px 0 14px rgba(0,0,0,0.18);
  transition: right 0.2s ease; z-index: 90; display: flex; flex-direction: column;
}
.ai-panel.open { right: 0; }
.ai-meta { padding: 10px 14px; font-size: 12px; color: #64748b; border-bottom: 1px solid #e5e7eb; }
.ai-output { flex: 1; overflow: auto; padding: 14px; color: #1f2937; font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.ai-output .ai-error { color: #b91c1c; }
.ai-output .ai-cursor { display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px; background: #4f46e5; animation: ai-blink 1s step-end infinite; }
@keyframes ai-blink { 50% { opacity: 0; } }

/* 我的项目面板：PC 端从左侧滑出，手机端从右侧滑出 */
.proj-name-tag { font-size: 12px; color: #e0e7ff; margin-left: 4px; }
.lsp-status { font-size: 12px; margin-left: 8px; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,0.12); color: #e0e7ff; white-space: nowrap; }
.lsp-status.on { background: rgba(34,197,94,0.22); color: #bbf7d0; }
.lsp-status.off { background: rgba(239,68,68,0.22); color: #fecaca; }
/* 身份徽章：未登录显示「临时空间」（琥珀色），已登录显示「已登录」（绿色） */
.identity-badge {
  font-size: 11.5px; margin-left: 8px; padding: 2px 9px; border-radius: 10px;
  white-space: nowrap; font-weight: 600;
}
.identity-badge.anon { background: rgba(245,158,11,0.22); color: #fde68a; }
.identity-badge.user { background: rgba(34,197,94,0.22); color: #bbf7d0; }
.proj-panel {
  position: fixed; top: 0; left: -380px; width: 320px; height: 100%;
  background: #fff; box-shadow: 2px 0 14px rgba(0,0,0,0.18);
  transition: left 0.2s ease; z-index: 50; display: flex; flex-direction: column;
}
.proj-panel.open { left: 56px; }
.proj-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: #4f46e5; color: #fff; font-weight: 600;
}
.proj-x { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; line-height: 1; }
.proj-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid #e5e7eb; }
.proj-search { padding: 8px 14px; border-bottom: 1px solid #e5e7eb; }
.proj-search input { width: 100%; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; box-sizing: border-box; }
.btn.small { font-size: 12px; padding: 5px 10px; border: none; border-radius: 6px; background: #e5e7eb; color: #1f2937; cursor: pointer; }
.btn.small.primary { background: #22c55e; color: #fff; font-weight: 600; }
/* 项目面板顶部的「临时空间」提示：未登录时提醒数据不会永久保留 */
.anon-notice {
  margin: 0; padding: 9px 14px; font-size: 12px; line-height: 1.6;
  color: #92400e; background: #fffbeb; border-bottom: 1px solid #fde68a;
}
.anon-notice.hidden { display: none; }
.anon-notice .anon-login { margin-top: 7px; background: #f59e0b; color: #fff; font-weight: 600; }
.anon-notice .anon-login.hidden { display: none; }
.proj-list { flex: 1; overflow: auto; padding: 8px 14px; }
.proj-item { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid #f1f5f9; }
.proj-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-btn { font-size: 12px; padding: 3px 9px; border: none; border-radius: 5px; background: #eef2ff; color: #4338ca; cursor: pointer; }
.proj-btn.danger { background: #fee2e2; color: #b91c1c; }
.proj-empty { font-size: 12px; color: #94a3b8; padding: 12px 0; }

/* 图形预览浮层 */
.preview-wrap {
  /* bottom 抬高：给右下角 AI 助教浮动按钮让位，避免两个浮层重叠 */
  position: fixed; right: 16px; bottom: 84px; width: 440px; max-width: 46vw;
  background: #0b1021; border: 2px solid #4f46e5; border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45); z-index: 60; overflow: hidden;
}
.preview-wrap.hidden { display: none; }
.preview-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: #4f46e5; color: #fff; font-size: 13px; font-weight: 600;
}
.preview-img { display: block; width: 100%; background: #000; min-height: 240px; }
.preview-hint { color: #94a3b8; font-size: 12px; padding: 14px; text-align: center; }

/* 手机端固定操作栏：桌面端不占空间 */
.mobile-action-bar { display: none; }

/* PC 端用左下角浮动按钮作 AI 主入口，「更多」菜单里不再重复 */
.ai-menu-group { display: none; }

@media (max-width: 700px) {
  .ai-fab { display: none; }
  :root { --mobile-bar-height: 68px; }
  html, body { min-height: 100%; height: 100%; overflow: hidden; }
  body { padding-left: 0; padding-bottom: calc(var(--mobile-bar-height) + env(safe-area-inset-bottom)); }
  .left-bar { display: none; }
  .topbar {
    flex: 0 0 auto; display: block; padding: 8px 12px; height: auto;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .brand { min-width: 0; gap: 6px; margin-bottom: 7px; }
  .logo { font-size: 19px; }
  .title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .subtitle { display: none; }
  .toolbar { gap: 6px; flex-wrap: nowrap; width: 100%; }
  .toolbar > #runBtn { flex: 1 1 0; min-width: 0; }
  .toolbar > .proj-name-tag, .toolbar > .status { display: none; }
  .toolbar .btn, .toolbar select { min-height: 38px; padding: 8px 10px; font-size: 14px; }
  .settings-panel {
    left: 0; right: 0; top: auto; bottom: -100vh;
    width: auto; height: auto; max-height: 72vh;
    border-right: none; border-top: 1px solid #c7d2fe; border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 16px rgba(15,23,42,0.12);
    transition: bottom 0.2s ease;
  }
  .settings-panel.open { left: 0; right: 0; bottom: calc(var(--mobile-bar-height) + env(safe-area-inset-bottom)); }
  .settings-body { padding: 14px; overflow-y: auto; }
  .proj-panel { left: auto; right: -100vw; transition: right 0.2s ease; }
  .proj-panel.open { left: auto; right: 0; }
  .more-field { font-size: 13px; margin-bottom: 12px; }
  .more-field select { min-height: 42px; font-size: 15px; padding: 8px; }
  .more-action { min-height: 42px !important; margin-top: 6px; }
  .ai-menu-group { display: block; }
  .workspace {
    min-height: 0; height: auto;
    grid-template-rows: minmax(0, 1fr) minmax(190px, 34dvh);
  }
  .editor-pane { border-bottom: 2px solid #dbeafe; }
  #editor { touch-action: pan-x pan-y; }
  .bottom-pane { grid-template-rows: auto 64px auto minmax(0, 1fr); }
  .pane-header { font-size: 13px; padding: 7px 10px; }
  #stdin { font-size: 15px; padding: 8px 10px; }
  #terminal { min-height: 0; height: auto; padding: 8px 10px; }
  #terminal pre { font-size: 14px !important; line-height: 1.5; }
  .mobile-action-bar {
    position: fixed; z-index: 80; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
    min-height: var(--mobile-bar-height); padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    background: rgba(255,255,255,0.97); border-top: 1px solid #cbd5e1; box-shadow: 0 -4px 16px rgba(15,23,42,0.12);
  }
  .mobile-action {
    border: none; border-radius: 10px; background: transparent; color: #475569; font-size: 20px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  }
  .mobile-action span { font-size: 12px; line-height: 1; }
  .mobile-action.primary { color: #15803d; background: #f0fdf4; }
  .mobile-action:active { transform: scale(0.96); background: #e0e7ff; }
  .ai-panel { width: min(92vw, 420px); right: -100vw; }
  .ai-panel.open { right: 0; }
  .proj-panel { width: min(92vw, 360px); right: -100vw; }
  .proj-panel.open { right: 0; }
  .proj-head { padding-top: max(12px, env(safe-area-inset-top)); }
  .preview-wrap {
    left: 8px; right: 8px; bottom: calc(var(--mobile-bar-height) + env(safe-area-inset-bottom) + 8px);
    width: auto; max-width: none; border-radius: 12px;
  }
  .preview-img { max-height: 62dvh; min-height: 0; object-fit: contain; }
  .preview-head { min-height: 42px; padding: 8px 10px; font-size: 14px; }
}

@media (max-width: 380px) {
  .toolbar .btn { padding-left: 7px; padding-right: 7px; font-size: 13px; }
  .workspace { grid-template-rows: minmax(0, 1fr) minmax(180px, 36dvh); }
}

@media (prefers-reduced-motion: reduce) {
  .proj-panel { transition: none; }
  .mobile-action:active { transform: none; }
}

/* ==========================================================
   使用教程浮层（入口：PC 左侧边栏「教程」/ 手机端「更多」）
   ========================================================== */
.tut-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.tut-mask[hidden] { display: none; }

.tut-modal {
  width: min(1000px, 100%);
  height: min(86vh, 760px); max-height: 100%;
  background: #ffffff; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  display: flex; flex-direction: column; overflow: hidden;
}

.tut-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-size: 16px; font-weight: 600; color: #1e293b;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border-bottom: 1px solid #e2e8f0;
}

.tut-body { flex: 1 1 auto; display: flex; min-height: 0; }

.tut-nav {
  flex: 0 0 190px; width: 190px; overflow-y: auto;
  padding: 12px 10px; background: #f8fafc; border-right: 1px solid #e2e8f0;
}
.tut-nav-item {
  display: block; padding: 9px 12px; margin-bottom: 4px;
  border-radius: 8px; font-size: 13px; color: #475569;
  text-decoration: none; line-height: 1.4;
}
.tut-nav-item:hover { background: #eef2ff; color: #3730a3; }
.tut-nav-item.active { background: #e0e7ff; color: #3730a3; font-weight: 600; }

.tut-content {
  flex: 1 1 auto; overflow-y: auto; padding: 22px 26px 60px;
  position: relative; scroll-behavior: smooth;
}

.tut-chapter { margin-bottom: 8px; }
.tut-chapter:last-child { margin-bottom: 0; }

.tut-h2 {
  font-size: 19px; font-weight: 600; color: #312e81;
  margin: 6px 0 14px; padding-bottom: 8px; border-bottom: 2px solid #e0e7ff;
}
.tut-h3 {
  font-size: 15px; font-weight: 600; color: #3730a3;
  margin: 22px 0 10px;
}
.tut-p {
  font-size: 14px; line-height: 1.85; color: #334155; margin: 0 0 12px;
}

.tut-ul { margin: 0 0 14px; padding-left: 22px; }
.tut-ul li {
  font-size: 14px; line-height: 1.8; color: #334155; margin-bottom: 7px;
}
.tut-ul li::marker { color: #818cf8; }

.tut-note {
  position: relative; margin: 0 0 14px; padding: 12px 14px 12px 62px;
  background: #eff6ff; border-left: 3px solid #3b82f6; border-radius: 8px;
  font-size: 13px; line-height: 1.75; color: #1e40af;
}
.tut-note-tag {
  position: absolute; left: 12px; top: 12px;
  background: #3b82f6; color: #ffffff; font-size: 11px;
  padding: 2px 7px; border-radius: 4px; line-height: 1.5;
}

.tut-table-wrap { overflow-x: auto; margin: 0 0 16px; }
.tut-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tut-table th {
  background: #eef2ff; color: #3730a3; font-weight: 600; text-align: left;
  padding: 9px 12px; border: 1px solid #e2e8f0; white-space: nowrap;
}
.tut-table td {
  padding: 9px 12px; border: 1px solid #e2e8f0;
  color: #334155; line-height: 1.7; vertical-align: top;
}
.tut-table tbody tr:nth-child(even) { background: #f8fafc; }

.tut-code-wrap {
  margin: 0 0 16px; border: 1px solid #e2e8f0;
  border-radius: 8px; overflow: hidden;
}
.tut-code-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: #f1f5f9; border-bottom: 1px solid #e2e8f0;
}
.tut-code-bar > span {
  font-size: 11px; color: #64748b; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tut-try {
  border: none; border-radius: 6px; padding: 4px 12px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #ffffff;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}
.tut-try:hover { filter: brightness(1.08); }
.tut-try:active { transform: scale(0.96); }

.tut-code {
  margin: 0; padding: 13px 15px; background: #f8fafc;
  overflow-x: auto; font-size: 13px; line-height: 1.7; color: #334155;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  tab-size: 4;
}

.tut-term {
  margin: 0 0 16px; padding: 13px 15px; background: #0f172a;
  border-radius: 8px; overflow-x: auto;
  font-size: 12.5px; line-height: 1.7; color: #e2e8f0;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
}
.tut-err { color: #fca5a5; font-weight: 600; }

/* 教程按钮只在手机端的设置面板里出现（PC 端用左侧边栏入口） */
.mobile-only { display: none; }

body.tut-open { overflow: hidden; }

@media (max-width: 700px) {
  .mobile-only { display: block; }
  .tut-mask { padding: 0; }
  .tut-modal {
    width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; box-shadow: none;
  }
  .tut-head { padding: 12px 14px; font-size: 15px; }
  .tut-body { flex-direction: column; }
  .tut-nav {
    flex: 0 0 auto; width: 100%; max-height: 48px;
    display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden;
    padding: 8px 10px; border-right: none; border-bottom: 1px solid #e2e8f0;
  }
  .tut-nav-item {
    flex: 0 0 auto; white-space: nowrap; margin-bottom: 0;
    padding: 6px 12px; font-size: 12.5px; background: #ffffff;
    border: 1px solid #e2e8f0;
  }
  .tut-content { padding: 16px 16px 60px; }
  .tut-h2 { font-size: 17px; }
  .tut-p, .tut-ul li { font-size: 13.5px; }
  .tut-note { padding-left: 14px; padding-top: 34px; }
}

/* ==========================================================
   素材面板（全局共享：属于账号，不属于某个项目）
   ========================================================== */
.asset-panel {
  position: fixed; top: 0; left: -380px; width: 320px; max-width: 92vw;
  height: 100%; background: #ffffff; z-index: 90;
  border-right: 1px solid #c7d2fe;
  box-shadow: 6px 0 24px rgba(15, 23, 42, 0.18);
  display: flex; flex-direction: column;
  transition: left 0.2s ease;
}
.asset-panel.open { left: 56px; }

.asset-body { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px 24px; }

.asset-drop {
  border: 2px dashed #c7d2fe; border-radius: 10px;
  padding: 16px 12px; text-align: center; background: #f8fafc;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.asset-drop.hover { background: #eef2ff; border-color: #6366f1; }
.asset-drop .btn { margin-bottom: 6px; }
.asset-hint { display: block; font-size: 12px; color: #64748b; }

.asset-link-row { display: flex; gap: 6px; margin: 10px 0 8px; }
.asset-link-row input {
  flex: 1 1 auto; min-width: 0; padding: 7px 9px; font-size: 13px;
  border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: #1e293b;
}
.asset-link-row .btn { padding: 7px 12px; font-size: 13px; }

.asset-usage { font-size: 12px; color: #64748b; margin-bottom: 8px; min-height: 16px; }

.asset-list { display: flex; flex-direction: column; gap: 6px; }
.asset-empty {
  font-size: 13px; color: #94a3b8; line-height: 1.7;
  padding: 18px 8px; text-align: center;
}

.asset-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff;
}
.asset-item:hover { background: #f8fafc; border-color: #cbd5e1; }
.asset-thumb-wrap {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 8px;
  background: #f1f5f9; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.asset-thumb { width: 100%; height: 100%; object-fit: cover; }
.asset-icon { font-size: 19px; }

.asset-info { flex: 1 1 auto; min-width: 0; }
.asset-name {
  font-size: 13px; color: #1e293b; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset-meta { font-size: 11.5px; color: #94a3b8; margin-top: 2px; }

.asset-del {
  flex: 0 0 auto; border: none; background: transparent; cursor: pointer;
  color: #94a3b8; font-size: 14px; padding: 4px 6px; border-radius: 6px;
}
.asset-del:hover { background: #fee2e2; color: #dc2626; }

.asset-section-title {
  font-size: 12.5px; font-weight: 700; color: #475569;
  margin: 14px 0 6px; padding-top: 10px; border-top: 1px dashed #e2e8f0;
  /* 标题与「管理员上传」按钮分列两端 */
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
/* 管理员上传内置素材按钮：默认隐藏，由 /api/builtin-assets 的 isAdmin 决定显示 */
.builtin-admin-btn {
  flex: 0 0 auto; font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 6px; border: 1px solid #c7d2fe; background: #eef2ff; color: #4f46e5;
}
.builtin-admin-btn:hover { background: #e0e7ff; border-color: #818cf8; }
.builtin-admin-btn.hidden { display: none; }
/* 内置素材的删除按钮：比「我的素材」的删除更醒目（琥珀色），避免误删全站素材 */
.asset-del.builtin-del { color: #f59e0b; }
.asset-del.builtin-del:hover { background: #fef3c7; color: #b45309; }
.asset-sub { font-weight: 400; color: #94a3b8; font-size: 11px; }
.asset-add {
  flex: 0 0 auto; border: 1px solid #e2e8f0; background: #fff; cursor: pointer;
  color: #16a34a; font-size: 16px; font-weight: 700; width: 30px; height: 30px;
  border-radius: 8px; line-height: 1;
}
.asset-add:hover { background: #ecfdf5; border-color: #16a34a; }
.asset-add:disabled { color: #16a34a; cursor: default; background: #ecfdf5; }

@media (max-width: 700px) {
  .asset-panel {
    left: auto; right: -100vw; top: 0; width: min(92vw, 360px);
    transition: right 0.2s ease;
    padding-top: max(0px, env(safe-area-inset-top));
  }
  .asset-panel.open { left: auto; right: 0; }
  .asset-drop { padding: 14px 10px; }
}

/* ==========================================================
   运行 / 停止 按钮状态（珠子 A）
   ========================================================== */
.hidden { display: none !important; }

.btn.stop {
  background: #ef4444; font-weight: 600; color: #fff;
  animation: stopPulse 1.2s ease-in-out infinite;
}
@keyframes stopPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
@media (prefers-reduced-motion: reduce) {
  .btn.stop { animation: none; }
}

/* 手机端底部运行按钮：图标与文字拆成两个 span，运行时切成「■ 停止」 */
.mobile-action .ma-icon { font-size: 20px; line-height: 1; }
.mobile-action.stopping { color: #b91c1c; background: #fef2f2; }

/* ==========================================================
   运行产物栏（珠子 B）：程序跑出来的文件可直接下载
   配色跟终端一致（深色），位置在终端下方
   ========================================================== */
.artifact-bar {
  background: #0b1021;
  border-top: 1px solid #1e293b;
  padding: 8px 10px 10px;
}
.artifact-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: #94a3b8; margin-bottom: 8px;
}
.artifact-head .proj-x { font-size: 13px; padding: 0 4px; background: transparent; color: #94a3b8; }
.artifact-items { display: flex; flex-wrap: wrap; gap: 8px; }
.artifact-item {
  display: flex; align-items: center; gap: 8px;
  background: #131a30; border: 1px solid #27324f; border-radius: 8px;
  padding: 6px 8px; max-width: 100%;
}
.artifact-thumb {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 6px;
  background: #1e293b; display: flex; align-items: center; justify-content: center;
  font-size: 18px; overflow: hidden;
}
.artifact-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.artifact-meta { min-width: 0; flex: 1 1 auto; }
.art-name {
  font-size: 12.5px; color: #e2e8f0; font-weight: 600;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.art-size { font-size: 11.5px; color: #94a3b8; margin-top: 2px; }
.artifact-dl {
  flex: 0 0 auto; border: none; border-radius: 6px; cursor: pointer;
  background: #2563eb; color: #fff; font-size: 12px; padding: 6px 11px;
}
.artifact-dl:hover { background: #1d4ed8; }

/* 作业检测面板 */
.check-panel {
  position: fixed; top: 0; left: -480px; width: 420px; max-width: 92vw; height: 100%;
  background: #fff; box-shadow: 2px 0 14px rgba(0,0,0,0.18);
  transition: left 0.2s ease; z-index: 50; display: flex; flex-direction: column;
}
.check-panel.open { left: 56px; }
.check-tabs { display: flex; border-bottom: 1px solid #e5e7eb; }
.check-tab {
  flex: 1; padding: 10px; border: none; background: #f8fafc; color: #475569;
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.check-tab.active { background: #fff; color: #4f46e5; border-bottom: 2px solid #4f46e5; }
.check-body { flex: 1; overflow: auto; padding: 12px 14px; }
.check-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.case-list { display: flex; flex-direction: column; gap: 10px; }
.case-item { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px; background: #fafbff; }
.case-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.case-name { flex: 1; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; box-sizing: border-box; }
.case-points { width: 70px; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; box-sizing: border-box; }
.case-del { border: none; background: #fee2e2; color: #b91c1c; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.case-field label { display: block; font-size: 11px; color: #64748b; margin: 4px 0 2px; }
.case-field textarea {
  width: 100%; min-height: 46px; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 12px; font-family: monospace; box-sizing: border-box; resize: vertical;
}
.grade-summary { margin: 12px 0; padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.grade-summary.ok { background: #dcfce7; color: #166534; }
.grade-summary.partial { background: #fef9c3; color: #854d0e; }
.grade-summary.fail { background: #fee2e2; color: #b91c1c; }
.grade-results { display: flex; flex-direction: column; gap: 8px; }
.grade-case { border: 1px solid #e5e7eb; border-radius: 10px; padding: 9px 11px; font-size: 13px; }
.grade-case.pass { border-left: 4px solid #22c55e; background: #f0fdf4; }
.grade-case.fail { border-left: 4px solid #ef4444; background: #fef2f2; }
.grade-case-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.grade-case-name { font-weight: 600; }
.grade-case.pass .grade-case-badge { background: #22c55e; color: #fff; }
.grade-case.fail .grade-case-badge { background: #ef4444; color: #fff; }
.grade-case-badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; }
.grade-diff { margin-top: 5px; font-family: monospace; font-size: 12px; white-space: pre-wrap; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 6px; padding: 6px 8px; }
.grade-diff .exp { color: #475569; }
.grade-diff .got { color: #b91c1c; }
.lint-list { display: flex; flex-direction: column; gap: 8px; }
.lint-item { border: 1px solid #e5e7eb; border-radius: 10px; padding: 9px 11px; font-size: 13px; cursor: pointer; }
.lint-item.warn { border-left: 4px solid #f59e0b; background: #fffbeb; }
.lint-item.tip { border-left: 4px solid #38bdf8; background: #f0f9ff; }
.lint-item .lint-line { font-weight: 600; color: #475569; font-size: 12px; }
.lint-item .lint-msg { margin-top: 2px; }

/* 分享弹窗 */
.share-mask { position: fixed; inset: 0; background: rgba(15,23,42,0.45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.share-mask[hidden] { display: none; }
.share-modal { width: min(92vw, 440px); background: #fff; border-radius: 14px; box-shadow: 0 18px 50px rgba(15,23,42,0.28); overflow: hidden; }
.share-head { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); color: #fff; }
.share-body { padding: 18px 18px 16px; }
.share-status { font-size: 13px; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.share-status.off { background: #f1f5f9; color: #64748b; }
.share-status.on { background: #ecfdf5; color: #047857; }
.share-link-row { display: flex; gap: 8px; margin-bottom: 12px; }
.share-link-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 12px; color: #334155; background: #f8fafc; }
.share-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.share-hint { font-size: 12px; color: #94a3b8; line-height: 1.5; }
.proj-shared-tag { font-size: 12px; margin-left: 2px; }

@media (max-width: 700px) {
  .check-panel { left: auto; right: -100vw; transition: right 0.2s ease; width: min(92vw, 400px); }
  .check-panel.open { left: auto; right: 0; }
}

/* ==========================================================
   单步断点调试（珠子 K）
   顶栏「🐞 调试」按钮 + 调试控制条 + 右侧调试面板 + Monaco 断点槽/当前行
   ========================================================== */
.btn.debug { background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%); color: #fff; font-weight: 600; }
.btn.debug:hover { filter: brightness(1.05); }
/* 编译选项按钮 + 弹层 */
.btn.compile-opts-btn { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; font-weight: 600; }
.btn.compile-opts-btn:hover { background: #e2e8f0; }
.compile-opts-pop {
  position: fixed; top: 56px; right: 12px; z-index: 1200;
  width: 260px; padding: 14px 16px; border-radius: 12px;
  background: #fff; box-shadow: 0 12px 36px rgba(15, 23, 42, 0.22);
  border: 1px solid #e2e8f0;
}
.compile-opts-pop .co-head { font-weight: 700; font-size: 14px; color: #1e293b; margin-bottom: 10px; }
.compile-opts-pop .co-field {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px;
  font-size: 12.5px; color: #475569;
}
.compile-opts-pop .co-field select {
  width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid #cbd5e1;
  background: #f8fafc; font-size: 13px; color: #1e293b;
}
.compile-opts-pop .co-hint { font-size: 11px; color: #94a3b8; line-height: 1.5; margin-top: 2px; }
.debug-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.dbg-btn {
  border: none; border-radius: 6px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  padding: 5px 9px; background: #ede9fe; color: #5b21b6; white-space: nowrap;
}
.dbg-btn:hover { background: #ddd6fe; }
.dbg-btn.stop { background: #fee2e2; color: #b91c1c; }
.dbg-btn.stop:hover { background: #fecaca; }
.dbg-status { font-size: 12px; color: #475569; margin-left: 4px; padding: 2px 6px; border-radius: 4px; background: #f1f5f9; }
.dbg-status.pause { color: #b45309; background: #fef3c7; }
.dbg-status.run { color: #15803d; background: #dcfce7; }
.dbg-status.err { color: #b91c1c; background: #fee2e2; }

/* 调试面板：右侧固定，镜像 check-panel 但靠右 */
.debug-panel {
  position: fixed; top: 0; right: -480px; width: 380px; max-width: 92vw; height: 100%;
  background: #fff; box-shadow: -2px 0 14px rgba(0,0,0,0.18);
  transition: right 0.2s ease; z-index: 50; display: flex; flex-direction: column;
}
.debug-panel:not(.hidden) { right: 0; }
.dbg-tabs { display: flex; border-bottom: 1px solid #e5e7eb; }
.dbg-tab {
  flex: 1; padding: 10px; border: none; background: #f8fafc; color: #475569;
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.dbg-tab.active { background: #fff; color: #7c3aed; border-bottom: 2px solid #7c3aed; }
.dbg-body { flex: 1; overflow: auto; padding: 12px 14px; }
.dbg-var-list, .dbg-stack-list, .dbg-bp-list { display: flex; flex-direction: column; gap: 6px; }
.dbg-empty { font-size: 12.5px; color: #94a3b8; padding: 8px 2px; }
.dbg-var {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name val" "type val";
  gap: 0 10px; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 6px; padding: 7px 10px;
}
.dbg-var-name { grid-area: name; font-weight: 700; color: #4338ca; font-family: Consolas, monospace; font-size: 13px; }
.dbg-var-type { grid-area: type; font-size: 11px; color: #94a3b8; font-family: Consolas, monospace; }
.dbg-var-val { grid-area: val; align-self: center; font-family: Consolas, monospace; font-size: 13px; color: #0f172a; word-break: break-all; text-align: right; }
.dbg-stack { display: flex; gap: 8px; align-items: baseline; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 6px; padding: 7px 10px; font-size: 12.5px; }
.dbg-stack-lvl { color: #7c3aed; font-weight: 700; font-family: Consolas, monospace; }
.dbg-stack-func { color: #1f2937; font-weight: 600; font-family: Consolas, monospace; }
.dbg-stack-loc { color: #94a3b8; font-family: Consolas, monospace; margin-left: auto; }
.dbg-bp { display: flex; align-items: center; gap: 8px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; padding: 6px 10px; font-size: 12.5px; }
.dbg-bp-label { flex: 1; font-family: Consolas, monospace; color: #991b1b; }
.dbg-bp-del { border: none; background: #fee2e2; color: #b91c1c; border-radius: 4px; cursor: pointer; font-size: 11px; padding: 2px 7px; }
.dbg-bp-del:hover { background: #fecaca; }

/* Monaco 断点槽：点击事件由 debug.js 处理，这里只画红点 */
.debug-bp { cursor: pointer; }
.debug-bp::after {
  content: ''; display: block; width: 11px; height: 11px; margin: 3px auto 0;
  background: #ef4444; border-radius: 50%; box-shadow: 0 0 0 2px rgba(239,68,68,0.25);
}
/* 当前执行行高亮 */
.debug-current-line { background: rgba(250, 204, 21, 0.22); }
.debug-current-glyph {
  background: #facc15; width: 3px !important; margin-left: 3px;
}

@media (max-width: 700px) {
  .debug-panel { right: -100vw; transition: right 0.2s ease; width: min(92vw, 380px); }
  .debug-panel:not(.hidden) { right: 0; }
  .debug-bar { width: 100%; }
}
