:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #0f766e;
  --accent-2: #b45309;
  --accent-3: #2563eb;
  --soft: #e7f5f3;
  --shadow: 0 18px 44px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(15, 118, 110, 0.08), transparent 30%),
    radial-gradient(circle at 82% 6%, rgba(37, 99, 235, 0.08), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(251, 252, 254, 0.94);
  padding: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.brand p,
.visual-head p,
.eyebrow,
.progress-top,
.list-head span,
.meta-pill,
.step-caption {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.progress-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 18px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-top strong {
  color: var(--ink);
}

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

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  transition: width 250ms ease;
}

.progress-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.category-progress {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.category-progress-item {
  display: grid;
  gap: 5px;
}

.category-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.category-progress-top strong {
  color: var(--ink);
  font-weight: 700;
}

.mini-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef5;
}

.mini-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.text-button:hover {
  border-color: #a7b5c8;
}

.text-button.danger {
  color: #b42318;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.category-button:hover,
.problem-item:hover,
.icon-button:hover,
.done-button:hover {
  border-color: #a7b5c8;
}

.category-button span:first-child {
  overflow-wrap: anywhere;
}

.category-button span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.category-button.active {
  border-color: #9bd4cd;
  background: var(--soft);
  color: #0f4f49;
  font-weight: 700;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 248, 251, 0.92);
  backdrop-filter: blur(12px);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(620px, 100%);
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0 12px;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.top-actions,
.visual-actions,
.meta-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 3px;
}

.filter-button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.filter-button.active {
  background: var(--ink);
  color: #fff;
}

.icon-button,
.done-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-size: 22px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.done-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.status-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 34px 0 12px;
  font-weight: 700;
}

.done-button.done {
  border-color: #8fd5a6;
  background: #e8f7ee;
  color: #166534;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 22px;
  padding: 24px;
  align-items: start;
}

.problem-column,
.visual-panel,
.list-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.problem-column {
  padding: 24px;
}

.problem-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.problem-head h2 {
  margin: 5px 0 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.meta-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #f8fafc;
}

.meta-link {
  color: #1d4ed8;
  font-weight: 700;
  text-decoration: none;
}

.meta-link:hover {
  text-decoration: underline;
}

.solution-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.solution-tab {
  display: grid;
  gap: 4px;
  min-height: 62px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  text-align: left;
}

.solution-tab:hover {
  border-color: #a7b5c8;
}

.solution-tab.active {
  border-color: #93c5fd;
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--accent-3);
}

.solution-tab span {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.solution-tab small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.difficulty-简单 {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.difficulty-中等 {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.difficulty-困难 {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.category-guide-panel {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  border-block: 1px solid var(--line);
  background: #fbfdff;
  padding: 18px 0;
}

.category-guide-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.category-guide-head h3 {
  margin: 0;
  font-size: 17px;
}

.category-guide-head p,
.category-guide-summary,
.template-card span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.category-guide-summary {
  line-height: 1.75;
  color: #344054;
}

.category-signal-list {
  margin-top: -2px;
}

.category-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.template-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.template-card div {
  display: grid;
  gap: 4px;
}

.template-card strong {
  font-size: 14px;
}

.template-card pre {
  max-height: 180px;
  padding: 12px;
  font-size: 12px;
}

.content-section {
  margin-top: 28px;
}

.content-section h3,
.visual-head h3,
.list-head h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.content-section p {
  margin: 0;
  color: #344054;
  line-height: 1.8;
}

.guide-list {
  margin: 0;
  padding-left: 22px;
  color: #344054;
  line-height: 1.75;
}

.trace-box {
  display: grid;
  gap: 10px;
}

.trace-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  color: #344054;
  line-height: 1.6;
}

.trace-step strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
}

.note-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.note-head h3 {
  margin: 0;
}

.note-head span {
  color: var(--muted);
  font-size: 13px;
}

.note-input {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  line-height: 1.7;
  outline: 0;
}

.note-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.26);
}

pre {
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: #101828;
  color: #e6edf7;
  padding: 16px;
  line-height: 1.55;
}

.visual-column {
  min-width: 0;
  display: grid;
  gap: 18px;
  position: sticky;
  top: 88px;
}

.visual-panel,
.list-panel {
  padding: 16px;
}

.visual-head,
.list-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.animation-stage {
  display: grid;
  align-content: center;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(#eef3f8 1px, transparent 1px),
    linear-gradient(90deg, #eef3f8 1px, transparent 1px),
    #fbfdff;
  background-size: 24px 24px;
  padding: 18px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.array-row,
.node-row,
.grid-board,
.matrix-board,
.bit-stack,
.heap-tree,
.tree-board,
.choice-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cell,
.node,
.grid-cell,
.matrix-cell,
.heap-node,
.tree-node,
.choice-node {
  display: grid;
  place-items: center;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  transition:
    transform 220ms ease,
    background 220ms ease,
    border-color 220ms ease;
}

.cell {
  width: 46px;
  height: 46px;
  border-radius: 8px;
}

.node {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  position: relative;
}

.node:not(:last-child)::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 2px;
  background: #94a3b8;
  right: -18px;
}

.grid-board {
  display: grid;
  grid-template-columns: repeat(4, 46px);
  gap: 7px;
  margin: 0 auto;
}

.matrix-board {
  display: grid;
  grid-template-columns: repeat(var(--matrix-columns, 3), 54px);
  gap: 7px;
  margin: 0 auto;
}

.grid-cell {
  width: 46px;
  height: 46px;
  border-radius: 6px;
}

.matrix-cell {
  width: 54px;
  height: 54px;
  border-radius: 6px;
}

.animation-card {
  display: grid;
  gap: 16px;
  width: 100%;
}

.animation-context {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.animation-context div {
  display: grid;
  gap: 3px;
}

.animation-context strong {
  color: var(--ink);
  font-size: 15px;
}

.animation-context span {
  font-size: 13px;
}

.animation-context em {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-style: normal;
  font-size: 13px;
  font-weight: 800;
}

.animation-visual {
  display: grid;
  min-height: 96px;
  align-content: center;
}

.state-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.state-row span {
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.cell.active,
.node.active,
.grid-cell.active,
.matrix-cell.active,
.heap-node.active,
.tree-node.active,
.bit-row.active,
.choice-node.active {
  transform: translateY(-6px);
  border-color: var(--accent-3);
  background: #dbeafe;
}

.cell.match,
.node.match,
.grid-cell.match,
.matrix-cell.match,
.tree-node.match,
.bit-row.match,
.choice-node.match {
  border-color: var(--accent);
  background: #ccfbf1;
}

.cell.warn,
.grid-cell.warn,
.matrix-cell.warn {
  border-color: var(--accent-2);
  background: #fef3c7;
}

.bit-stack {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.bit-row {
  min-width: 128px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  padding: 8px 14px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
  transition:
    transform 220ms ease,
    background 220ms ease,
    border-color 220ms ease;
}

.heap-tree,
.tree-board {
  display: grid;
  grid-template-columns: repeat(4, 48px);
  grid-auto-rows: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.heap-node,
.tree-node {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-weight: 800;
  transition:
    transform 220ms ease,
    background 220ms ease,
    border-color 220ms ease;
}

.heap-node:first-child,
.tree-node:first-child {
  grid-column: 2 / span 2;
  justify-self: center;
}

.choice-row {
  max-width: 260px;
  margin: 0 auto;
}

.choice-node {
  min-width: 58px;
  min-height: 42px;
  border-radius: 8px;
  padding: 6px 10px;
  text-align: center;
  transition:
    transform 220ms ease,
    background 220ms ease,
    border-color 220ms ease;
}

.hash-box {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hash-item {
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.step-caption {
  min-height: 40px;
  margin-top: 12px;
  line-height: 1.5;
}

.step-track {
  display: grid;
  grid-template-columns: repeat(var(--step-count, 3), minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.step-track span {
  height: 5px;
  border-radius: 999px;
  background: #dbe3ee;
  transition:
    background 180ms ease,
    transform 180ms ease;
}

.step-track span.active {
  background: var(--accent-3);
  transform: scaleY(1.35);
}

.problem-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.empty-state {
  border: 1px dashed #b8c4d3;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  line-height: 1.6;
}

.problem-item {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
  text-align: left;
}

.problem-item strong {
  overflow-wrap: anywhere;
}

.problem-item small {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
}

.problem-item small span {
  border-radius: 999px;
  background: #f1f5f9;
  padding: 2px 7px;
  font-size: 12px;
}

.problem-item.active {
  border-color: #93c5fd;
  background: #eff6ff;
}

.problem-item.status-done strong::after {
  content: " ✓";
  color: #15803d;
}

.problem-item.status-learning {
  border-left: 4px solid #2563eb;
}

.problem-item.status-review {
  border-left: 4px solid #d97706;
}

.problem-item.status-wrong {
  border-left: 4px solid #dc2626;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .category-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .visual-column {
    position: static;
  }
}

@media (max-width: 680px) {
  .topbar,
  .problem-head,
  .visual-head,
  .list-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .visual-actions {
    justify-content: flex-end;
  }

  .status-filter {
    width: 100%;
  }

  .filter-button {
    flex: 1;
  }

  .search-wrap {
    width: 100%;
  }

  .status-controls,
  .done-button,
  .status-select {
    width: 100%;
  }

  .workbench,
  .topbar,
  .sidebar {
    padding: 14px;
  }

  .problem-column {
    padding: 16px;
  }

  .category-list {
    grid-template-columns: 1fr;
  }

  .cell,
  .grid-cell {
    width: 38px;
    height: 38px;
  }

  .grid-board {
    grid-template-columns: repeat(4, 38px);
  }
}
