/* ============================================================
   Java 基础 · 章节笔记 + 练习页样式（在 note.css 基础上扩展）
   ============================================================ */

.java-hero {
  padding: 42px 0 10px;
}

.java-hero h1 {
  font-size: clamp(26px, 4vw, 40px);
}

.java-hero p {
  color: var(--text-secondary);
  margin-top: 10px;
}

.java-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  padding: 26px 0 80px;
}

.java-card {
  display: block;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

.java-card:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.3);
}

.java-card .jc-title {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.45;
}

.java-card .jc-meta {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.java-card .jc-bar {
  margin-top: 12px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.java-card .jc-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}

.java-card .jc-pct {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---------- 练习区 ---------- */
.block-title {
  margin: 34px 0 4px;
  padding-left: 12px;
  border-left: 4px solid var(--accent-1);
  font-size: 20px;
}

.practice-group-title {
  margin: 22px 0 12px;
  font-size: 16px;
  color: var(--text-secondary);
}

.jq-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.jq-card.done {
  border-color: rgba(99, 102, 241, 0.35);
}

.jq-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.jq-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.jq-tag {
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 10px;
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
}

.jq-tag.fill {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.jq-tag.code {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
}

.jq-stem {
  font-size: 15px;
  line-height: 1.75;
  margin-bottom: 12px;
}

.jq-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jq-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.jq-opt:hover:not(:disabled) {
  border-color: rgba(99, 102, 241, 0.55);
}

.jq-opt:disabled {
  cursor: default;
  opacity: 0.85;
}

.jq-opt .k {
  font-weight: 700;
  color: var(--accent-1);
}

.jq-opt.correct {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.12);
}

.jq-opt.wrong-opt {
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(239, 68, 68, 0.12);
}

.jq-judge {
  display: flex;
  gap: 10px;
}

.jq-judge button {
  min-width: 84px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
}

.jq-judge button:hover:not(:disabled) {
  border-color: rgba(99, 102, 241, 0.55);
}

.jq-judge button.correct {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.12);
}

.jq-judge button.wrong-opt {
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(239, 68, 68, 0.12);
}

.jq-fill {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.jq-fill input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-family);
  outline: none;
}

.jq-fill input:focus {
  border-color: rgba(99, 102, 241, 0.6);
}

.jq-fill input.correct {
  border-color: rgba(34, 197, 94, 0.7);
}

.jq-fill input.wrong {
  border-color: rgba(239, 68, 68, 0.7);
}

.jq-feedback {
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 700;
  display: none;
}

.jq-feedback.show { display: block; }
.jq-feedback.ok { color: var(--green); }
.jq-feedback.bad { color: var(--red); }

.jq-answer {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.06);
  border-left: 3px solid rgba(251, 191, 36, 0.55);
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.8;
  display: none;
  white-space: pre-wrap;
}

.jq-answer.show { display: block; }

/* ---------- 代码题 ---------- */
.code-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.code-hint {
  font-size: 13px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.07);
  border: 1px dashed rgba(251, 191, 36, 0.4);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 10px 0;
  line-height: 1.7;
}

.code-box .CodeMirror {
  height: auto;
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  background: #0a0a10;
  color: #e2e8f0;
}

.code-box .CodeMirror-gutters {
  background: #0a0a10;
  border-right: 1px solid var(--border);
}

.code-box .CodeMirror-linenumber { color: #52525b; }
.code-box .CodeMirror-cursor { border-left: 2px solid #fafafa !important; }
.code-box .CodeMirror-selected { background: rgba(99, 102, 241, 0.25); }
.code-box .cm-keyword { color: #c792ea; }
.code-box .cm-string { color: #a5d6a7; }
.code-box .cm-comment { color: #6b7280; }
.code-box .cm-number { color: #f0abfc; }

/* 去掉选中行的白色光条，只保留字符光标 */
.CodeMirror-activeline-background {
  background: transparent !important;
}

.code-box .CodeMirror-line::selection,
.code-box .CodeMirror-line > span::selection {
  background: rgba(99, 102, 241, 0.35);
}

/* ---------- 文中跟练：左（示例代码）右（空跟练框） ---------- */
.try-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.try-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.pane-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.code-box .code-source {
  width: 100%;
  min-height: 200px;
  display: none; /* 由 CodeMirror 接管 */
}

.try-pane .CodeMirror {
  min-height: 220px;
}

/* 左侧示例代码：只读，稍暗，提示这是参考 */
.try-pane .CodeMirror-readonly,
.try-pane .CodeMirror[readonly] {
  background: rgba(255, 255, 255, 0.02);
}

@media (max-width: 900px) {
  .try-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- 左侧目录可收起 ---------- */
.note-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.note-sidebar-head .note-sidebar-title {
  border-bottom: none;
  margin: 0;
  padding: 4px 6px 0;
  flex: 1;
  min-width: 0;
}

.sidebar-toggle {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-toggle:hover {
  color: #fff;
  border-color: rgba(99, 102, 241, 0.6);
  background: rgba(99, 102, 241, 0.14);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}

.note-article {
  position: relative;
}

.sidebar-toggle-float {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  background: var(--bg-card);
}

.note-layout.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.note-layout.sidebar-collapsed .note-sidebar {
  display: none;
}

.note-layout.sidebar-collapsed .note-article {
  padding-top: 60px;
}

.code-box textarea.code-input {
  width: 100%;
  min-height: 200px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0a10;
  color: #e2e8f0;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
  outline: none;
}

.code-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.code-status {
  font-size: 13px;
  color: var(--text-muted);
}

.run-result {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0a0a10;
}

.run-result.success { border-color: rgba(34, 197, 94, 0.5); }
.run-result.error { border-color: rgba(239, 68, 68, 0.5); }

.run-result-head {
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.run-output {
  margin: 0;
  padding: 12px 14px;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  color: #e2e8f0;
  white-space: pre-wrap;
  min-height: 44px;
}

.ref-code {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0a10;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  color: #e2e8f0;
  white-space: pre-wrap;
  overflow-x: auto;
}

.practice-summary {
  margin: 14px 0 4px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.practice-summary b { color: #fde68a; }

@media (max-width: 760px) {
  .java-grid { grid-template-columns: 1fr; }
  .code-box .CodeMirror { min-height: 170px; }
}
