.algorithm-page {
  padding-top: 56px;
}

.algorithm-hero {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 28px;
  align-items: stretch;
  padding: 56px 0 28px;
}

.algorithm-hero-copy,
.algorithm-demo-shell,
.algorithm-side-panel {
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), transparent),
    rgba(255, 253, 249, 0.82);
  box-shadow: var(--shadow);
}

.algorithm-hero-copy {
  padding: 34px;
}

.algorithm-hero-copy h1 {
  margin: 0;
  font-family: "Noto Serif SC", serif;
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  line-height: 1.12;
}

.algorithm-hero-copy p,
.algorithm-side-panel p,
.algorithm-step-list li {
  color: var(--muted);
  line-height: 1.8;
}

.algorithm-hero-copy p {
  margin: 18px 0 0;
  font-size: 1.04rem;
}

.algorithm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  margin: 24px 0 0;
  list-style: none;
}

.algorithm-tags li {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(37, 72, 61, 0.1);
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 700;
}

.algorithm-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.algorithm-list-page .algorithm-hero {
  display: block;
}

.algorithm-list-page .algorithm-hero-copy {
  margin-bottom: 24px;
}

.algorithm-list-page .algorithm-demo-shell .algorithm-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.algorithm-card {
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent),
    rgba(255, 253, 249, 0.84);
}

.algorithm-card span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(37, 72, 61, 0.1);
  color: var(--bg-deep);
  font-size: 0.88rem;
  font-weight: 700;
}

.algorithm-card h3 {
  margin: 18px 0 12px;
  font-size: 1.3rem;
}

.algorithm-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.algorithm-card[href] {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.algorithm-card[href]:hover,
.algorithm-card[href]:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(217, 123, 45, 0.34);
  box-shadow: 0 18px 46px rgba(35, 29, 18, 0.12);
}

.algorithm-card footer {
  margin-top: 18px;
  color: var(--accent-deep);
  font-weight: 700;
}

.algorithm-demo-shell {
  min-height: 420px;
  padding: 26px;
}

.algorithm-demo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.algorithm-demo-header h2,
.algorithm-side-panel h2 {
  margin: 0;
  font-size: 1.5rem;
}

.algorithm-demo-header p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.demo-controls button,
.demo-controls select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.demo-controls button {
  padding: 0 16px;
  cursor: pointer;
}

.demo-controls select {
  padding: 0 36px 0 14px;
}

.demo-controls button:hover,
.demo-controls button:focus-visible {
  background: var(--accent-soft);
}

.demo-status {
  min-height: 32px;
  margin: 0 0 16px;
  color: var(--green);
  font-weight: 700;
  line-height: 1.55;
}

.demo-stage {
  display: grid;
  gap: 18px;
}

.bar-stage {
  display: grid;
  grid-template-columns: repeat(var(--bar-count, 10), minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 240px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 32, 0.06);
}

.bar {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  height: calc(var(--value) * 8px);
  min-height: 34px;
  padding-bottom: 8px;
  border-radius: 10px 10px 6px 6px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  transition: height 220ms ease, background-color 220ms ease, transform 220ms ease;
}

.bar.is-done {
  background: #3b7a58;
}

.bar.is-active {
  background: var(--accent);
  transform: translateY(-6px);
}

.grid-stage {
  display: grid;
  grid-template-columns: repeat(5, minmax(42px, 1fr));
  gap: 8px;
  max-width: 430px;
}

.grid-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid rgba(15, 23, 32, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-weight: 800;
}

.grid-cell.is-wall {
  background: rgba(15, 23, 32, 0.82);
  color: #fff;
}

.grid-cell.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.grid-cell.is-path {
  background: #cde8d5;
  color: var(--green);
}

.graph-stage {
  position: relative;
  min-height: 360px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 32, 0.06);
  overflow: hidden;
}

.graph-stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.graph-edge {
  stroke: rgba(15, 23, 32, 0.28);
  stroke-width: 3;
}

.graph-edge.is-active {
  stroke: var(--accent);
  stroke-width: 5;
}

.graph-node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  transform: translate(-50%, -50%);
  box-shadow: 0 12px 24px rgba(15, 23, 32, 0.18);
}

.graph-node.is-active {
  background: var(--accent);
}

.graph-node small {
  position: absolute;
  top: 58px;
  color: var(--text);
  white-space: nowrap;
}

.algorithm-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  margin: 26px 0 64px;
}

.algorithm-side-panel {
  padding: 26px;
}

.code-window {
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, #121922 0%, #0d131a 100%);
}

.code-toolbar {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-toolbar span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
}

.code-toolbar span:nth-child(1) {
  background: #f47f6b;
}

.code-toolbar span:nth-child(2) {
  background: #f2c15c;
}

.code-toolbar span:nth-child(3) {
  background: #58c38c;
}

.code-window pre {
  margin: 0;
  padding: 24px;
  max-width: 100%;
  overflow-x: auto;
}

.code-window code {
  display: block;
  color: #d8e4f1;
  font-size: 0.96rem;
  line-height: 1.75;
  font-family: Consolas, "SFMono-Regular", monospace;
}

.algorithm-code-panel {
  margin: 0 0 64px;
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), transparent),
    rgba(255, 253, 249, 0.82);
  box-shadow: var(--shadow);
}

.algorithm-code-panel .code-window {
  margin-top: 18px;
}

.algorithm-code-panel pre {
  max-height: 620px;
  overflow: auto;
}

.algorithm-step-list {
  display: grid;
  gap: 12px;
  padding-left: 20px;
  margin: 18px 0 0;
}

.algorithm-track {
  margin-top: 24px;
  padding: 24px 28px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(37, 72, 61, 0.16);
  background:
    radial-gradient(circle at left top, rgba(37, 72, 61, 0.14), transparent 30%),
    rgba(247, 252, 248, 0.9);
}

.algorithm-track strong {
  display: block;
  font-size: 1.22rem;
  color: var(--bg-deep);
}

.algorithm-track p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

@media (max-width: 980px) {
  .algorithm-hero,
  .algorithm-layout {
    grid-template-columns: 1fr;
  }

  .algorithm-list-page .algorithm-demo-shell .algorithm-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .algorithm-hero {
    padding-top: 34px;
  }

  .algorithm-hero-copy,
  .algorithm-demo-shell,
  .algorithm-side-panel {
    padding: 22px;
  }

  .algorithm-demo-header {
    flex-direction: column;
  }

  .algorithm-demo-header .button {
    width: 100%;
  }

  .algorithm-hero-copy h1 {
    font-size: 2.35rem;
  }

  .algorithm-track,
  .faq-list details {
    padding: 22px;
  }
}


