:root {
  --ink: #172033;
  --muted: #64748b;
  --paper: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e2ef;
  --blue: #1d4ed8;
  --blue-soft: #e8f0ff;
  --teal: #0f766e;
  --teal-soft: #e6f6f4;
  --amber: #a16207;
  --rose: #be123c;
  --code: #0f172a;
  --code-soft: #111827;
  --green: #22c55e;
  --shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(232, 240, 255, 0.88) 0, rgba(244, 247, 251, 0) 320px),
    linear-gradient(90deg, rgba(230, 246, 244, 0.75), transparent 44%),
    var(--paper);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr minmax(260px, 440px);
  gap: 20px;
  align-items: center;
  padding: 18px clamp(16px, 2vw, 36px);
  border-bottom: 1px solid rgba(217, 226, 239, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(29, 78, 216, 0.2);
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  max-width: 740px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 15px;
}

.search-wrap {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.search-wrap input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 15px;
  outline: none;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.search-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}

.shell {
  display: grid;
  grid-template-columns: 230px minmax(520px, 1fr) minmax(360px, 560px);
  gap: 20px;
  width: min(1840px, calc(100% - 32px));
  margin: 22px auto;
  align-items: start;
}

.sidebar,
.panel,
.hero-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 100px;
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  background: var(--panel-soft);
}

.section-tabs {
  display: grid;
  padding: 8px;
}

.tab-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.tab-btn:hover,
.tab-btn.active {
  color: var(--ink);
  background: var(--blue-soft);
}

.tab-btn.active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.tab-btn strong {
  color: inherit;
  font-size: 13px;
}

.content {
  display: grid;
  gap: 18px;
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(232, 240, 255, 0.86), rgba(230, 246, 244, 0.54)),
    #fff;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-panel h2 {
  max-width: 680px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.12;
  letter-spacing: 0;
}

.stats {
  display: grid;
  gap: 10px;
  min-width: 150px;
}

.stats span {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.76);
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.topic-card {
  display: grid;
  gap: 12px;
  min-height: 172px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.topic-card:hover,
.topic-card.active {
  transform: translateY(-3px);
  border-color: rgba(29, 78, 216, 0.38);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.1);
}

.topic-card.active {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.topic-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 700;
}

.difficulty {
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
}

.topic-card h3 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.topic-card p {
  color: var(--muted);
  line-height: 1.5;
}

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

.tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
}

.workspace {
  position: sticky;
  top: 100px;
  display: grid;
  gap: 14px;
}

.panel {
  overflow: hidden;
  background: #fff;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #dbeafe;
  background: var(--code-soft);
  font-size: 14px;
}

.output-panel .panel-head {
  color: var(--ink);
  border-bottom-color: var(--line);
  background: var(--panel-soft);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 999px;
}

.red { background: #f87171; }
.yellow { background: #fbbf24; }
.green { background: #34d399; }

.code-panel pre,
.output-panel pre {
  margin: 0;
  min-height: 310px;
  max-height: 54vh;
  overflow: auto;
  padding: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-panel pre {
  color: #e5edf8;
  background: var(--code);
  font-size: 14px;
  line-height: 1.6;
}

.output-panel pre {
  min-height: 150px;
  color: #d1fae5;
  background: #111827;
  font-size: 14px;
  line-height: 1.55;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--green);
  animation: blink 800ms steps(2, start) infinite;
}

#copyBtn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  color: var(--blue);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

#copyBtn:hover {
  background: var(--blue-soft);
}

.tips {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.tips strong {
  color: var(--rose);
}

.tips p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.82);
}

.footer {
  width: min(1840px, calc(100% - 32px));
  margin: 0 auto 26px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

@keyframes blink {
  50% { opacity: 0; }
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .workspace {
    grid-column: 1 / -1;
    position: static;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .topbar,
  .shell,
  .workspace,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    gap: 16px;
  }

  .sidebar {
    position: static;
  }

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

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

  .hero-panel {
    display: grid;
    padding: 20px;
  }

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

@media (max-width: 520px) {
  .shell,
  .footer {
    width: min(100% - 22px, 1500px);
  }

  .brand {
    align-items: flex-start;
  }

  .brand p {
    font-size: 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .section-tabs,
  .stats {
    grid-template-columns: 1fr;
  }

  .topic-card {
    min-height: 0;
    padding: 14px;
  }

  .code-panel pre,
  .output-panel pre {
    max-height: none;
    min-height: 210px;
    font-size: 13px;
  }
}
