/* ==========================================================================
   题目页 · LeetCode 风格全屏 IDE
   --------------------------------------------------------------------------
   两条硬规则：
   1) 铺满：页面不再有外边距 / 圆角卡片，题面与编辑器各占一栏，撑满 100vh。
   2) 光标对齐：透明 textarea 与底下着色层必须共用同一套字体度量
      （--code-font / --code-size / --code-lh / --code-pad-*），
      且 <code> 必须 font: inherit —— 浏览器 UA 会给 code 塞 monospace，
      一旦它和 textarea 的字体不同，字符宽度就差几像素，光标就会错位。
   ========================================================================== */

:root {
  --lc-ink: #262626;
  --lc-sub: #8c8c8c;
  --lc-line: #e3e6eb;
  --lc-line-soft: #eff1f6;
  --lc-hover: #f7f8fa;
  --lc-green: #2cbb5d;
  --lc-green-h: #27a851;
  --lc-blue: #1a73e8;
  --lc-easy: #00af9b;
  --lc-med: #ffb800;
  --lc-hard: #ff2d55;
  --nav-h: 46px;
  --side: 46%;

  /* ↓↓↓ 代码区唯一一份字体度量，textarea 与着色层都引用它 ↓↓↓ */
  --code-font: "Cascadia Mono", "Consolas", "SF Mono", Menlo, ui-monospace, "Liberation Mono", "Courier New", monospace;
  --code-size: 13.5px;
  --code-lh: 21px;
  --code-pad-x: 16px;
  --code-pad-y: 12px;
  --code-bg: #fbfcfe;
  --code-ink: #1f2328;
}

/* ---------------- 让出整块屏幕 ---------------- */

body.lc-body { background: #fff; overflow: hidden; }

.lc-body .sidebar { background: #fff; backdrop-filter: none; border-right: 1px solid var(--lc-line); }
.lc-body .footer { display: none; }

.lc-body .container-wide {
  flex: none;
  width: 100%; max-width: none; margin: 0; padding: 0;
  height: 100vh;
  height: 100dvh;
  display: flex; flex-direction: column;
}

/* ---------------- 页面骨架 ---------------- */

.lc {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background: #fff; color: var(--lc-ink);
}

.lc-error {
  flex: 0 0 auto; padding: 8px 14px;
  background: #fff1f0; color: #cf1322;
  border-bottom: 1px solid #ffccc7; font-size: 13px;
}

.lc-main { flex: 1; min-height: 0; display: flex; }

/* ---------------- 左：题面 ---------------- */

.lc-side {
  flex: 0 0 auto; width: var(--side); min-width: 300px; max-width: 74%;
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--lc-line);
}

.lc-side-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 8px;
  min-height: 44px;
}
.lc-back {
  flex: 0 0 auto;
  width: 26px; height: 26px; line-height: 24px; text-align: center;
  border: 1px solid var(--lc-line); border-radius: 6px;
  color: var(--lc-sub); font-size: 14px; text-decoration: none;
}
.lc-back:hover { background: var(--lc-hover); color: var(--lc-ink); text-decoration: none; }
.lc-ptitle {
  font-size: 16px; font-weight: 600; letter-spacing: -.1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lc-diff { flex: 0 0 auto; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 4px; }
.lc-diff.easy { color: var(--lc-easy); background: rgba(0, 175, 155, .1); }
.lc-diff.medium { color: #b98200; background: rgba(255, 184, 0, .14); }
.lc-diff.hard { color: var(--lc-hard); background: rgba(255, 45, 85, .1); }
.lc-passed {
  flex: 0 0 auto; font-size: 12px; color: var(--lc-green);
  display: inline-flex; align-items: center; gap: 3px;
}
.lc-side-head .spacer { flex: 1; }

.lc-tabs {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid var(--lc-line);
}
.lc-tab {
  position: relative;
  border: 0; background: transparent; cursor: pointer;
  height: 36px; padding: 0 10px;
  font: inherit; font-size: 13.5px; color: var(--lc-sub);
}
.lc-tab:hover { color: var(--lc-ink); }
.lc-tab.on { color: var(--lc-ink); font-weight: 600; }
.lc-tab.on::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0; background: var(--lc-ink);
}
.lc-tabs .spacer { flex: 1; }
.lc-tabs .lc-tabmeta { font-size: 12px; color: var(--lc-sub); padding-right: 4px; }

.lc-side-body { flex: 1; min-height: 0; position: relative; }
.lc-pane {
  position: absolute; inset: 0;
  display: none; overflow: auto;
  padding: 16px 20px 48px;
}
.lc-pane.on { display: block; }

.lc-pane::-webkit-scrollbar,
.lc-side-body::-webkit-scrollbar { width: 10px; height: 10px; }
.lc-pane::-webkit-scrollbar-thumb,
.lc-side-body::-webkit-scrollbar-thumb { background: #d5d9e0; border-radius: 6px; border: 2px solid #fff; }
.lc-pane::-webkit-scrollbar-thumb:hover { background: #bfc5d0; }

/* 题面正文 */
.lc-h1 { font-size: 17px; font-weight: 700; margin: 0 0 10px; }
.lc-tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; }
.lc-tagrow .tag-mini { background: #eef4ff; color: #2b6cb0; }
.lc-desc { font-size: 14px; line-height: 1.75; color: #333; white-space: pre-wrap; word-break: break-word; }
.lc-desc code, .lc-sec code {
  font-family: var(--code-font); font-size: 12.5px;
  background: var(--lc-hover); border: 1px solid var(--lc-line-soft);
  border-radius: 4px; padding: 0 4px;
}
.lc-sec { margin-top: 20px; }
.lc-sec > .h { font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--lc-ink); }

.lc-sample { margin-bottom: 14px; }
.lc-sample:last-child { margin-bottom: 0; }
.lc-sample .k { font-size: 12.5px; color: var(--lc-sub); margin: 8px 0 4px; }
.lc-sample pre {
  margin: 0; padding: 10px 12px;
  background: var(--lc-hover); border-radius: 8px; border-left: 3px solid var(--lc-line);
  font-family: var(--code-font); font-size: 13px; line-height: 1.6;
  color: #333; white-space: pre-wrap; word-break: break-word;
}
.lc-sample .fill {
  float: right; margin-left: 8px;
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--lc-blue);
  padding: 0 2px;
}
.lc-sample .fill:hover { text-decoration: underline; }

.lc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lc-table th, .lc-table td { padding: 8px 10px; border-bottom: 1px solid var(--lc-line-soft); text-align: left; }
.lc-table th { font-size: 12px; color: var(--lc-sub); font-weight: 500; background: var(--lc-hover); }
.lc-table td.num, .lc-table th.num { text-align: right; }
.lc-table tr:hover td { background: #fafbfd; }

/* ---------------- 分栏拖拽条 ---------------- */

.lc-splitter {
  flex: 0 0 5px; width: 5px; margin-left: -5px;
  cursor: col-resize; position: relative; z-index: 5;
}
.lc-splitter::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 2px; width: 1px;
  background: transparent; transition: background .12s;
}
.lc-splitter:hover::after, .lc-splitter.dragging::after { background: var(--lc-blue); }
body.lc-resizing { cursor: col-resize; user-select: none; }
body.lc-resizing .editor-input { pointer-events: none; }

/* ---------------- 右：编辑器 ---------------- */

.lc-editor-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.lc-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.lc-toolbar {
  flex: 0 0 auto; height: 42px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--lc-line);
  background: #fff;
}
.lc-toolbar .spacer { flex: 1; }

.lc-select {
  width: auto; min-width: 118px; height: 30px;
  padding: 3px 26px 3px 9px; margin: 0;
  border: 1px solid var(--lc-line); border-radius: 6px;
  background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238c8c8c' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 9px center;
  -webkit-appearance: none; appearance: none;
  font: inherit; font-size: 13px; color: var(--lc-ink); cursor: pointer;
}
.lc-select:focus { border-color: var(--lc-blue); outline: none; }

.lc-btn {
  height: 30px; padding: 0 14px;
  border: 1px solid var(--lc-line); border-radius: 6px;
  background: #fff; color: var(--lc-ink);
  font: inherit; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.lc-btn:hover { background: var(--lc-hover); }
.lc-btn.soft { background: #eff1f6; border-color: transparent; }
.lc-btn.soft:hover { background: #e6e9ef; }
.lc-btn.primary {
  background: var(--lc-green); border-color: var(--lc-green); color: #fff; font-weight: 600;
}
.lc-btn.primary:hover { background: var(--lc-green-h); border-color: var(--lc-green-h); }
.lc-btn:disabled { opacity: .55; cursor: default; }
.lc-btn.sm { height: 26px; padding: 0 10px; font-size: 12.5px; }

.lc-draft { font-size: 11.5px; color: var(--lc-sub); min-width: 0; }

.lc-kbd {
  font-family: var(--code-font); font-size: 10.5px; line-height: 16px;
  color: var(--lc-sub); border: 1px solid var(--lc-line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; background: #fff;
}

/* 编辑器（textarea 与着色层共用度量） */
.editor {
  position: relative; flex: 1; min-height: 0;
  display: flex; overflow: hidden;
  background: var(--code-bg);
}

.editor-gutter {
  flex: 0 0 52px; width: 52px;
  padding: var(--code-pad-y) 10px var(--code-pad-y) 0;
  text-align: right; overflow: hidden;
  color: #b6bcc6; background: #f6f8fb;
  border-right: 1px solid var(--lc-line-soft);
  font-family: var(--code-font); font-size: var(--code-size); line-height: var(--code-lh);
  font-variant-ligatures: none; white-space: pre;
  user-select: none;
}
.editor-gutter .editor-lines { will-change: transform; }

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

/* 当前行高亮，纯装饰；跟着光标走 */
.editor-activeline {
  position: absolute; left: 0; right: 0;
  top: var(--code-pad-y); height: var(--code-lh);
  background: #f0f3f8; pointer-events: none;
  opacity: 0; transition: opacity .1s;
  will-change: transform;
}

.editor-paint {
  position: absolute; inset: 0; z-index: 1;
  margin: 0; border: 0;
  padding: var(--code-pad-y) calc(var(--code-pad-x) + 12px) var(--code-pad-y) var(--code-pad-x);
  overflow: hidden; pointer-events: none;
  color: var(--code-ink); background: transparent;
  font-family: var(--code-font); font-size: var(--code-size); line-height: var(--code-lh);
  font-variant-ligatures: none; letter-spacing: normal; word-spacing: normal;
  white-space: pre; tab-size: 4; -moz-tab-size: 4;
  will-change: transform;
}
/* 关键：<code> 必须完全继承，不能保留 UA 的 monospace */
.editor-paint code {
  display: block; font: inherit; line-height: inherit;
  white-space: inherit; tab-size: inherit; letter-spacing: inherit;
}

.editor-input {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%;
  margin: 0; border: 0; border-radius: 0; box-shadow: none;
  padding: var(--code-pad-y) var(--code-pad-x);
  background: transparent; resize: none; outline: none;
  color: var(--code-ink); caret-color: #1f2328;
  font-family: var(--code-font); font-size: var(--code-size); line-height: var(--code-lh);
  font-variant-ligatures: none;
  letter-spacing: normal; word-spacing: normal;
  white-space: pre; word-break: normal; overflow-wrap: normal;
  overflow: auto; tab-size: 4; -moz-tab-size: 4;
}
/* 只有着色层真的画出来了，才把 textarea 的字变透明（脚本挂了代码依然可见） */
.editor.is-ready .editor-input { color: transparent; }
.editor-input::selection { background: rgba(86, 132, 240, .24); }
.editor-input:focus { outline: none; border: 0; box-shadow: none; }
.editor-input::placeholder { color: #aab0ba; }
.editor-error {
  text-decoration: underline wavy #c62828;
  text-underline-offset: 3px;
}
.editor-error-tooltip {
  position: fixed;
  z-index: 20;
  max-width: min(520px, calc(100vw - 16px));
  max-height: 45vh;
  overflow: hidden;
  padding: 7px 10px;
  border: 1px solid #e0a6a6;
  border-radius: 6px;
  background: #fff7f7;
  color: #6e1b1b;
  box-shadow: 0 4px 14px #0002;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.editor-input::-webkit-scrollbar { width: 10px; height: 10px; }
.editor-input::-webkit-scrollbar-thumb { background: #d8dce3; border-radius: 6px; border: 2px solid var(--code-bg); }
.editor-input::-webkit-scrollbar-thumb:hover { background: #c3c9d3; }
.editor-input::-webkit-scrollbar-corner { background: transparent; }

/* VSCode light 配色，和力扣的浅色主题接近 */
.tk-kw  { color: #0000ff; }
.tk-ty  { color: #267f99; }
.tk-str { color: #a31515; }
.tk-num { color: #098658; }
.tk-com { color: #008000; font-style: italic; }
.tk-pre { color: #af00db; }
.tk-fn  { color: #795e26; }

/* ---------------- 右下：测试 / 结果 ---------------- */

.lc-console {
  flex: 0 0 auto; height: 212px;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--lc-line); background: #fff;
}
.lc-ctabs {
  flex: 0 0 auto; height: 38px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px;
  background: var(--lc-hover); border-bottom: 1px solid var(--lc-line);
}
.lc-ctab {
  border: 0; background: transparent; cursor: pointer;
  height: 26px; padding: 0 10px; border-radius: 6px;
  font: inherit; font-size: 12.5px; color: var(--lc-sub);
}
.lc-ctab:hover { color: var(--lc-ink); }
.lc-ctab.on { background: #fff; color: var(--lc-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.lc-ctabs .spacer { flex: 1; }
.lc-ctabs .hint { font-size: 11.5px; color: var(--lc-sub); padding-right: 4px; }

.lc-cbody { flex: 1; min-height: 0; position: relative; }
.lc-cpane { position: absolute; inset: 0; display: none; flex-direction: column; }
.lc-cpane.on { display: flex; }

.lc-cpane .chips {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-bottom: 1px solid var(--lc-line-soft);
  background: #fff; overflow-x: auto;
}
.chip {
  flex: 0 0 auto;
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--lc-line); background: #fff; color: var(--lc-sub);
  cursor: pointer; white-space: nowrap;
}
.chip:hover { color: var(--lc-blue); border-color: #bcd3f7; background: #f5f9ff; }

.lc-cpane textarea {
  flex: 1; min-height: 0; width: 100%;
  border: 0; border-radius: 0; box-shadow: none; outline: none;
  padding: 10px 12px; resize: none;
  background: #fff; color: var(--lc-ink);
  font-family: var(--code-font); font-size: 13px; line-height: 1.6;
  white-space: pre; overflow: auto;
}
.lc-cpane textarea:focus { border: 0; outline: none; box-shadow: none; }

.lc-out-tools {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; font-size: 12px; color: var(--lc-sub);
  border-bottom: 1px solid var(--lc-line-soft);
}
.lc-out {
  flex: 1; min-height: 0; overflow: auto; margin: 0;
  padding: 10px 12px;
  font-family: var(--code-font); font-size: 13px; line-height: 1.65;
  color: var(--lc-ink); white-space: pre-wrap; word-break: break-word;
}
.lc-out-empty { padding: 16px 12px; font-size: 12.5px; color: var(--lc-sub); }

/* 判定结果 */
.lc-verdict { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; }
.lc-verdict-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lc-verdict-top .big { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.lc-verdict-top .big.AC { color: var(--lc-green); }
.lc-verdict-top .big.WA, .lc-verdict-top .big.RE { color: #f5222d; }
.lc-verdict-top .big.TLE { color: #d48806; }
.lc-verdict-top .big.CE { color: #595959; }
.lc-verdict-meta { font-size: 12.5px; color: var(--lc-sub); }
.lc-verdict-meta a { color: var(--lc-blue); }

.lc-cases { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.lc-case {
  font-family: var(--code-font); font-size: 11.5px;
  padding: 3px 9px; border-radius: 4px; border: 1px solid transparent;
}
.lc-case.AC { background: rgba(44, 187, 93, .1); color: #1f9d4d; border-color: rgba(44, 187, 93, .22); }
.lc-case.WA, .lc-case.RE { background: rgba(245, 34, 45, .07); color: #d32029; border-color: rgba(245, 34, 45, .18); }
.lc-case.TLE { background: rgba(212, 136, 6, .09); color: #ad6800; border-color: rgba(212, 136, 6, .2); }
.lc-case.CE { background: #f5f5f5; color: #595959; border-color: #e8e8e8; }

.lc-verdict pre {
  margin: 0; padding: 10px 12px;
  background: var(--lc-hover); border-radius: 8px;
  font-family: var(--code-font); font-size: 12.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; color: #333;
}
.lc-verdict .muted { font-size: 12.5px; color: var(--lc-sub); }

.busy { opacity: .6; pointer-events: none; }
.spin {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: lc-spin .7s linear infinite; vertical-align: -1px;
}
@keyframes lc-spin { to { transform: rotate(360deg); } }

/* ---------------- 窄屏：上下堆叠 ---------------- */

@media (max-width: 900px) {
  body.lc-body { overflow: auto; }
  .lc-body .container-wide { height: auto; }
  .lc-main { flex-direction: column; }
  .lc-side {
    width: auto !important; max-width: none; min-width: 0;
    max-height: 48vh; border-right: 0; border-bottom: 1px solid var(--lc-line);
  }
  .lc-splitter { display: none; }
  .lc-editor-col { height: 82vh; }
  .lc-toolbar .lc-draft { display: none; }
  .lc-console { height: 190px; }
}

/* ---------------- 考场内嵌模式：藏侧边栏、占满外壳 ---------------- */

.embed-body .sidebar { display: none; }
.embed-body .app { margin: 0; }
.embed-body .container-wide { max-width: none; padding: 10px 16px 24px; }
.embed-body .footer { display: none; }

/* ---------------- 竞赛答题模式：题号切换条 ---------------- */

.lc-contest-nav {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--lc-hover);
  border-bottom: 1px solid var(--lc-line);
}
.lc-contest-tab {
  padding: 4px 14px; border-radius: 6px;
  border: 1px solid var(--lc-line); background: #fff;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--lc-sub);
  text-decoration: none; cursor: pointer;
}
.lc-contest-tab:hover { color: var(--lc-blue); border-color: #bcd3f7; }
.lc-contest-tab.on { background: var(--lc-blue); border-color: var(--lc-blue); color: #fff; }

/* ---------------- 竞赛自动监考：切出警告横幅 ---------------- */

.guard-banner {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 9999; max-width: 86vw;
  padding: 10px 18px; border-radius: 8px;
  border: 1px solid #e6c700; background: #fffbe6; color: #7a5b00;
  font-size: 14px; line-height: 1.5; text-align: center;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .18);
}
.guard-banner.ending { border-color: #d48806; background: #fff7e6; color: #8a5a00; }
.guard-banner.ended { border-color: #c62828; background: #fdecea; color: #8e1a1a; }

