:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1a2233;
  --ink-2: #45506a;
  --muted: #6b7793;
  --line: #e3e8f2;
  --primary: #2f6ff5;
  --primary-dark: #1e55d0;
  --accent: #ffd43b;
  --green: #10b981;
  --red: #ef4444;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC",
          system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; }

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 276px 1fr;
  grid-template-rows: 64px auto minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "tabs tabs"
    "sidebar main";
  overflow: hidden;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px -6px rgba(37, 99, 235, .8);
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.top-progress {
  margin-left: auto;
  width: 190px;
}

.progress-text {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 5px;
  text-align: right;
}

.progress-text strong {
  color: var(--primary);
  font-size: 13px;
}

.progress-track {
  height: 6px;
  background: #edf1f9;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #2f6ff5);
  transition: width .45s cubic-bezier(.2, .8, .3, 1);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #3d4a66;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: .18s;
  white-space: nowrap;
}

.ghost-btn:hover {
  border-color: #c9d6f5;
  background: #f7faff;
  color: var(--primary);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  color: #4a5670;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn:hover { background: #f5f8ff; }

.menu-btn { display: none; }

/* ---------------- 移动端标签 ---------------- */
.mobile-tabs {
  grid-area: tabs;
  display: none;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.mobile-tab {
  flex: 1;
  border: none;
  background: #f2f5fc;
  color: #5b6784;
  font-size: 13px;
  font-weight: 600;
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
}

.mobile-tab.is-active {
  background: #e6eeff;
  color: var(--primary);
}

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  grid-area: sidebar;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px 10px 16px;
  z-index: 30;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #8a95ac;
  letter-spacing: .08em;
}

.sidebar-close { display: none; }

.chapter { margin-bottom: 4px; }

.chapter-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 8px 8px;
}

.chapter-index {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chapter-name {
  min-width: 0;
  flex: 1;
}

.chapter-name strong {
  display: block;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.chapter-name span {
  display: block;
  font-size: 10.5px;
  color: #94a0b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-count {
  font-size: 10.5px;
  color: #94a0b8;
  font-family: var(--mono);
}

.chapter-progress {
  height: 3px;
  background: #eef2f9;
  border-radius: 999px;
  margin: 0 8px 8px 45px;
  overflow: hidden;
}

.chapter-progress i {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width .4s;
}

.chapter-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.problem-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #3d4862;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: .15s;
}

.problem-item:hover { background: #f3f6fd; }

.problem-item.is-active {
  background: #e8efff;
  color: var(--primary-dark);
  font-weight: 600;
}

.item-no {
  width: 17px;
  text-align: center;
  font-size: 10.5px;
  color: #a2adc2;
  font-family: var(--mono);
  flex-shrink: 0;
}

.problem-item.is-active .item-no { color: var(--primary); }

.item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-check {
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
  width: 12px;
}

.sidebar-foot {
  margin-top: 12px;
  padding: 10px 8px;
  font-size: 10.5px;
  color: #a2adc2;
  border-top: 1px dashed var(--line);
  line-height: 1.6;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
  z-index: 25;
}

.scrim.is-on {
  opacity: 1;
  pointer-events: auto;
}

/* ---------------- 主区域 ---------------- */
.main {
  grid-area: main;
  display: grid;
  grid-template-columns: minmax(330px, 41%) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.problem-pane {
  min-height: 0;
  display: flex;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.problem-scroll {
  width: 100%;
  overflow-y: auto;
  padding: 24px 26px 60px;
  scroll-behavior: smooth;
}

.crumb {
  font-size: 11.5px;
  color: #97a2b8;
  letter-spacing: .05em;
  font-weight: 600;
}

.crumb span {
  font-family: var(--mono);
  font-weight: 700;
}

.problem-title {
  margin: 7px 0 11px;
  font-size: 25px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f2f5fb;
  color: #5b6784;
  line-height: 1.5;
}

.pill-source {
  background: #eef4ff;
  color: #2f6ff5;
}

.pill-star {
  color: #f59e0b;
  letter-spacing: 1.5px;
  background: #fffaeb;
}

.pill-tag {
  font-family: var(--mono);
  font-size: 10.5px;
}

.pill-video {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e8f7ef;
  color: #0d8a5c;
  border: 1px solid #b9e6d2;
  cursor: pointer;
  font-weight: 700;
  font-size: 11.5px;
  padding: 4px 10px;
  transition: .16s;
}

.pill-video:hover {
  background: #d6f2e3;
  transform: translateY(-1px);
}

.pill-video .play-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #0d8a5c;
  color: #fff;
  font-size: 7px;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* ---------------- 题解视频弹窗 ---------------- */
.video-modal {
  background: rgba(4, 8, 16, .78);
}

.video-card {
  width: min(1080px, 100%);
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .9);
}

.video-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}

.video-head-text h3 {
  margin: 0;
  font-size: 15px;
  color: #e6edf7;
}

.video-head-text p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: #7d8ea8;
}

.video-head .icon-btn {
  background: transparent;
  border-color: #243049;
  color: #c5d2e6;
}

.video-stage {
  aspect-ratio: 16 / 9;
  background: #000;
}

.video-stage video {
  display: block;
  width: 100%;
  height: 100%;
}

.video-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #0f172a;
  border-top: 1px solid #1e293b;
  font-size: 11.5px;
  color: #8fa0b8;
  line-height: 1.6;
}

.video-foot .text-btn {
  color: #7dd3fc;
  white-space: nowrap;
}

.story {
  font-size: 14.5px;
  line-height: 1.9;
  color: #2c3548;
  margin: 0 0 4px;
}

.block-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 24px 0 9px;
  color: #101828;
}

.block-title::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--primary);
}

.block-title .muted {
  font-weight: 400;
  font-size: 11px;
  color: #9aa5bd;
}

.block-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
}

.sample-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  margin-bottom: 10px;
  background: #fbfcff;
}

.sample-label {
  font-size: 10.5px;
  color: #97a2b8;
  margin-bottom: 8px;
  letter-spacing: .05em;
}

.sample-io {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.io-box {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.io-label {
  font-size: 10px;
  color: #9aa5bd;
  letter-spacing: .08em;
  margin-bottom: 3px;
}

.io-box pre,
.case-data pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}

.io-arrow {
  display: grid;
  place-items: center;
  color: #c3ccde;
  font-size: 13px;
}

.sample-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: #6b7793;
  line-height: 1.7;
}

.case-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.case-preview-item + .case-preview-item {
  border-top: 1px solid var(--line);
}

.case-preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: none;
  font-size: 12.5px;
  color: #3b465e;
  cursor: pointer;
  text-align: left;
}

.case-preview-head:hover { background: #f8faff; }

.case-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e3;
}

.case-eye {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--primary);
}

.case-preview-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px 12px 12px;
  background: #fbfcff;
}

.case-data pre {
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  max-height: 150px;
  overflow: auto;
}

.hint-area { margin-top: 16px; }

.hint-box {
  border-left: 3px solid var(--accent);
  background: #fffdf3;
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
  animation: fade-up .25s ease;
}

.hint-title {
  font-size: 12px;
  font-weight: 700;
  color: #8a6d00;
  margin-bottom: 8px;
}

.hint-line {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.8;
  color: #4a4225;
  margin-bottom: 6px;
}

.hint-no {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffe9a3;
  color: #8a6d00;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 3px;
}

.hint-more {
  font-size: 11.5px;
  color: #b08b1a;
  margin-top: 4px;
}

/* ---------------- 工作区 ---------------- */
.work-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
  background: #f5f7fd;
}

.work-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #4a5670;
  background: #fff;
  border: 1px solid var(--line);
  padding: 5px 11px;
  border-radius: 8px;
}

.file-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}

.toolbar-actions {
  display: flex;
  gap: 2px;
}

.text-btn {
  border: none;
  background: transparent;
  color: #5b6784;
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: .15s;
}

.text-btn:hover { background: #e9eefb; color: var(--primary); }

.text-btn.is-locked { color: #a2adc2; }

/* ---------------- 编辑器 ---------------- */
.editor {
  flex: 1 1 0;
  min-height: 180px;
  display: flex;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 40px -30px rgba(15, 23, 42, .9);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 22px;
}

.editor-gutter {
  width: 44px;
  flex-shrink: 0;
  padding: 12px 0;
  background: #0b1220;
  overflow: hidden;
  user-select: none;
}

.gutter-inner {
  padding-right: 10px;
  will-change: transform;
}

.gutter-line {
  height: 22px;
  line-height: 22px;
  font-size: 11px;
  text-align: right;
  color: #46536e;
}

.gutter-line.is-error {
  color: #fca5a5;
  background: rgba(248, 113, 113, .12);
  box-shadow: inset -2px 0 0 #ef4444;
}

.editor-main {
  position: relative;
  flex: 1;
  min-width: 0;
}

.editor-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px 14px;
  overflow: hidden;
  pointer-events: none;
  color: #dbe4f5;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 22px;
  white-space: pre;
  tab-size: 4;
}

.editor-highlight code {
  font: inherit;
  white-space: inherit;
}

.editor-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 12px 14px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: #7dd3fc;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 22px;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.editor-input::selection {
  background: rgba(59, 130, 246, .35);
}

.editor-input::placeholder { color: #64748b; }

.editor:focus-within {
  border-color: #3b5bdb;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .18), 0 18px 40px -30px rgba(15, 23, 42, .9);
}

.tok-kw { color: #ff7ab2; }
.tok-bi { color: #7dd3fc; }
.tok-fn { color: #a5b4fc; }
.tok-str { color: #a3e635; }
.tok-num { color: #fbbf24; }
.tok-com { color: #64748b; font-style: italic; }
.tok-op { color: #f472b6; }

/* ---------------- 运行栏 ---------------- */
.runner-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  flex-wrap: wrap;
}

.runner-state {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #66738f;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c3ccdd;
  flex-shrink: 0;
}

.status-dot.is-ready { background: var(--green); }
.status-dot.is-ok { background: var(--green); }
.status-dot.is-busy { background: #f59e0b; animation: pulse 1s infinite; }
.status-dot.is-err { background: var(--red); }

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

.btn {
  border: 1px solid transparent;
  padding: 9px 20px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: .18s;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px -9px rgba(47, 111, 245, .95);
}

.btn.primary:hover { background: var(--primary-dark); }

.btn.ghost {
  background: #fff;
  border-color: var(--line);
  color: #3d4a66;
}

.btn.ghost:hover { border-color: #c9d6f5; color: var(--primary); }

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------------- 结果面板 ---------------- */
.result-panel {
  flex: 0 1 auto;
  max-height: 38%;
  min-height: 86px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.result-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  color: #7b879f;
}

.result-empty-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eef3ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
}

.result-empty strong {
  display: block;
  font-size: 13px;
  color: #45506a;
}

.result-empty p {
  margin: 3px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 10px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 9px;
  flex-wrap: wrap;
}

.result-head-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.result-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.result-head.is-pass .result-mark { background: #dcfce7; color: #15803d; }
.result-head.is-fail .result-mark { background: #fef3c7; color: #b45309; }
.result-head.is-error .result-mark { background: #fee2e2; color: #b91c1c; }

.result-head-meta {
  font-size: 11px;
  color: #8b96ad;
}

.case-list {
  display: grid;
  gap: 6px;
}

.case-item {
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}

.case-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  font-size: 12.5px;
  color: #3b465e;
  cursor: pointer;
  text-align: left;
}

.case-item-head:hover { background: #f8faff; }

.case-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.case-item.is-pass .case-badge { background: #dcfce7; color: #15803d; }
.case-item.is-fail .case-badge,
.case-item.is-runtime-error .case-badge,
.case-item.is-compile-error .case-badge,
.case-item.is-timeout .case-badge { background: #fee2e2; color: #b91c1c; }
.case-item.is-skipped .case-badge { background: #eef2f9; color: #98a3b9; }

.case-status {
  font-size: 11.5px;
  color: #7b879f;
}

.case-ms {
  margin-left: auto;
  font-size: 10.5px;
  color: #a2adc2;
  font-family: var(--mono);
}

.case-expand {
  font-size: 11.5px;
  color: var(--primary);
}

.case-item-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  padding: 4px 10px 10px;
  background: #fbfcff;
}

.case-col pre {
  margin: 4px 0 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 130px;
  overflow: auto;
  color: #1f2937;
}

.case-col pre.is-diff {
  border-color: #fca5a5;
  background: #fff5f5;
}

.case-tip {
  grid-column: 1 / -1;
  font-size: 11.5px;
  line-height: 1.7;
  color: #8a6d00;
  background: #fffbeb;
  border-radius: 6px;
  padding: 8px 10px;
}

.case-tip.is-error {
  color: #b91c1c;
  background: #fef2f2;
}

.error-card {
  border: 1px solid #fecaca;
  background: #fef2f2;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 9px;
}

.error-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #b91c1c;
  margin-bottom: 6px;
}

.error-msg {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: #7f1d1d;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.7;
  color: #92400e;
  background: #fffbeb;
  padding: 8px 10px;
  border-radius: 6px;
}

.error-card.is-warn {
  border-color: #fde68a;
  background: #fffbeb;
}

.error-card.is-warn .error-title { color: #92400e; }
.error-card.is-warn .error-msg { color: #78350f; }

.result-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  font-size: 13px;
  color: #66738f;
}

/* ---------------- 加载 / 弹窗 / Toast ---------------- */
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #dbe4f8;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.spinner.small {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 120;
}

.loading-mask[hidden] { display: none; }

.loading-card {
  background: #fff;
  border-radius: 16px;
  padding: 26px 34px;
  text-align: center;
  box-shadow: 0 30px 60px -30px rgba(15, 23, 42, .5);
}

.loading-card .spinner { margin: 0 auto; }

.loading-title {
  font-size: 14px;
  font-weight: 700;
  margin-top: 14px;
}

.loading-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 110;
}

.modal[hidden] { display: none; }

.modal-card {
  background: #fff;
  border-radius: 16px;
  width: min(780px, 100%);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 80px -40px rgba(15, 23, 42, .6);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 15px;
}

.modal-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
}

.modal-note {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.modal-card.is-wide {
  width: min(940px, 100%);
}

.modal-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.modal-head-left h3 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-btn {
  flex-shrink: 0;
  border: none;
  background: #f2f5fc;
  color: #2f6ff5;
  font-size: 15px;
}

.back-btn:hover {
  background: #e6eeff;
}

.modal-note {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

/* ---------------- 语法速查 ---------------- */
.cheat-lead {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

.cheat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.cheat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
  padding: 14px;
  cursor: pointer;
  transition: transform .16s, border-color .16s, box-shadow .16s, background .16s;
}

.cheat-card:hover {
  background: #fff;
  border-color: #c6d8f8;
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -20px rgba(47, 111, 245, .7);
}

.cheat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cheat-icon {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: #eaf1ff;
  border-radius: 7px;
  padding: 4px 8px;
  line-height: 1.3;
}

.cheat-icon.is-large {
  font-size: 17px;
  padding: 11px 14px;
  border-radius: 10px;
}

.cheat-tag {
  font-size: 10px;
  color: #8b96ad;
  background: #f1f4fa;
  border-radius: 999px;
  padding: 2px 8px;
}

.cheat-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.cheat-card-desc {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  color: #7b879f;
}

.cheat-card-more {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
}

.cheat-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cheat-detail-head h4 {
  margin: 0;
  font-size: 16px;
  color: var(--ink);
}

.cheat-detail-head p {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: #8b96ad;
  font-family: var(--mono);
}

.cheat-intro {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
}

.cheat-sec {
  margin-top: 18px;
}

.cheat-sec h5 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--ink);
}

.cheat-sec-no {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--primary);
  background: #eaf1ff;
  border-radius: 6px;
  padding: 2px 6px;
}

.cheat-sec p {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink-2);
}

.cheat-sec code,
.cheat-pitfalls code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: #eef2fb;
  color: #2f4a7a;
  border-radius: 4px;
  padding: 1px 5px;
}

.cheat-code {
  margin: 0;
  background: #0f172a;
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
}

.cheat-code code {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.75;
  color: #dbe4f5;
  white-space: pre;
  background: transparent;
  padding: 0;
}

.cheat-pitfalls {
  margin-top: 20px;
  border-left: 3px solid var(--accent);
  background: #fffdf3;
  border-radius: 0 10px 10px 0;
  padding: 12px 14px;
}

.cheat-pitfalls h5 {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: #8a6d00;
}

.cheat-pitfalls ul {
  margin: 0;
  padding-left: 18px;
}

.cheat-pitfalls li {
  font-size: 12.5px;
  line-height: 1.8;
  color: #5a5133;
  margin-bottom: 4px;
}

.cheat-related {
  margin-top: 20px;
}

.cheat-related h5 {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--primary);
}

.cheat-related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cheat-problem {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #cfe0ff;
  background: #f2f7ff;
  color: var(--primary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: .15s;
}

.cheat-problem:hover {
  background: #e2edff;
  border-color: #a9c6fb;
}

.solution-code {
  margin: 0;
  background: #0f172a;
  color: #dbe4f5;
  border-radius: 10px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  overflow-x: auto;
}

.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #fff;
  font-size: 12.5px;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 18px 30px -18px rgba(15, 23, 42, .8);
  animation: toast-in .25s cubic-bezier(.2, .8, .3, 1);
  transition: opacity .4s, transform .4s;
  max-width: 320px;
  line-height: 1.6;
}

.toast.is-ok { background: #15803d; }
.toast.is-warn { background: #b45309; }
.toast.is-out { opacity: 0; transform: translateY(8px); }

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 150;
}

.confetti-layer i {
  position: absolute;
  top: -14px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* ---------------- 动画 ---------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes confetti-fall {
  to { transform: translateY(104vh) rotate(720deg); opacity: .85; }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .main { grid-template-columns: minmax(300px, 45%) minmax(0, 1fr); }
  .top-progress { width: 150px; }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "tabs"
      "main";
  }

  .topbar { padding: 0 12px; gap: 10px; }
  .menu-btn { display: grid; }
  .brand-mark { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
  .brand-text h1 { font-size: 14px; }
  .brand-text p { display: none; }
  .top-progress { width: 92px; }
  .progress-text { font-size: 10.5px; margin-bottom: 4px; }
  .ghost-btn { padding: 7px 10px; font-size: 11.5px; }

  .mobile-tabs { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 286px;
    transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.2, .8, .3, 1);
    box-shadow: 0 0 40px rgba(15, 23, 42, .18);
  }

  .sidebar.is-open { transform: none; }
  .sidebar-close { display: grid; }

  .main { grid-template-columns: 1fr; }

  .problem-pane { border-right: none; }
  .problem-scroll { padding: 16px 16px 40px; }
  .problem-title { font-size: 21px; }

  body[data-view="problem"] .work-pane { display: none; }
  body[data-view="code"] .problem-pane { display: none; }

  .work-pane { padding: 10px 10px 12px; gap: 8px; }

  .editor { min-height: 210px; }

  .result-panel {
    max-height: none;
    flex: 1 1 auto;
  }

  .case-preview-body { grid-template-columns: 1fr; }
  .cheat-grid { grid-template-columns: 1fr; }
  .cheat-code { padding: 10px 12px; }
  .cheat-code code { font-size: 11px; }
  .cheat-sec p { font-size: 12.5px; }
  .cheat-card-desc { font-size: 10.5px; }
  .modal-card.is-wide { width: 100%; }
  .runner-actions .btn { padding: 9px 16px; }
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }

  .video-modal { padding: 8px; }
  .video-foot { font-size: 10.5px; padding: 8px 12px; }
  .video-head { padding: 10px 12px; }
}

@media (max-width: 400px) {
  .brand-text h1 { font-size: 13px; }
  .top-progress { width: 72px; }
  .ghost-btn { padding: 6px 8px; font-size: 11px; }
  .brand { gap: 7px; }
  .topbar { gap: 7px; }
}
