:root {
  --ink: #14110e;
  --paper: #efe6d6;
  --paper-2: #e8dcc8;
  --copper: #c46a32;
  --mute: #8a7d6c;
  --line: rgba(20, 17, 14, 0.12);
  --code: #1c1814;
  --ok: #2c6b4a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 600px at 10% -20%, #2a221c 0%, transparent 55%),
    var(--ink);
}

a { color: var(--copper); }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  color: var(--paper);
  border-bottom: 1px solid rgba(239, 230, 214, 0.12);
}

.brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  color: var(--paper);
  text-decoration: none;
}

.brand span { color: var(--copper); }

.top nav { display: flex; gap: 18px; font-size: 14px; }
.top nav a { color: var(--paper); text-decoration: none; }
.top nav a:hover, .top nav a.is-here { color: var(--copper); }

.wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  max-width: 1120px;
  margin: 24px auto 48px;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

aside.lessons {
  padding: 28px 18px;
  background: rgba(20, 17, 14, 0.04);
  border-right: 1px solid var(--line);
}

.lessons-title {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 12px;
}

aside.lessons a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 14px;
}

aside.lessons a:hover { background: rgba(196, 106, 50, 0.1); }
aside.lessons a.is-active {
  background: var(--ink);
  color: var(--paper);
}

article.lesson { padding: 36px 40px 44px; }

.kicker {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 8px;
}

h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 420;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.05;
  margin-bottom: 16px;
}

h2 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 620;
  font-size: 22px;
  margin: 28px 0 10px;
}

.lead, article.lesson p { line-height: 1.6; margin-bottom: 12px; max-width: 62ch; }
.lead { font-size: 18px; color: #3a322a; }

code, kbd {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.92em;
  background: rgba(20, 17, 14, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.example {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 18px 0 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.example-code, .example-view { padding: 14px 16px; }
.example-code {
  background: var(--code);
  color: #f3e6d0;
  overflow: auto;
}
.example-code pre {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.example-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 8px;
}
.example-code .example-label { color: #b7a48c; }
.example-view { background: #fffdf8; }
.example-view .demo h1,
.example-view .demo h2,
.example-view .demo h3 { font-family: inherit; margin: 0 0 8px; }
.example-view .demo p { margin: 0 0 8px; }

.note {
  border-left: 3px solid var(--copper);
  padding: 10px 14px;
  background: rgba(196, 106, 50, 0.08);
  margin: 16px 0 22px;
  max-width: 62ch;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.pager a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--copper);
}
.pager a:hover { color: var(--copper); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 18px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.7);
}
.card:hover { border-color: var(--copper); }
.card strong { display: block; font-size: 12px; color: var(--copper); margin-bottom: 6px; }
.card span { font-family: Fraunces, Georgia, serif; font-size: 20px; }

.hero {
  padding: 36px 40px 28px;
}

.try-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: calc(100vh - 64px);
}

.try-edit, .try-view { display: flex; flex-direction: column; min-height: 0; }
.try-edit { background: var(--code); }
.try-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  color: #d7c7b2;
  font-size: 13px;
}
button.run {
  font: inherit;
  background: var(--copper);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
}
button.run:hover { background: #d8894a; }

#code {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  padding: 16px;
  background: var(--code);
  color: #f3e6d0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
}

.try-view { background: #fff; }
.try-view .try-bar {
  color: var(--ink);
  background: #f4ead8;
  border-bottom: 1px solid var(--line);
}
.try-view iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

@media (max-width: 800px) {
  .wrap { grid-template-columns: 1fr; margin: 0; border-radius: 0; }
  aside.lessons { border-right: 0; border-bottom: 1px solid var(--line); }
  article.lesson, .hero { padding: 28px 20px 36px; }
  .example, .try-layout { grid-template-columns: 1fr; }
  .try-layout { min-height: auto; }
  #code { min-height: 280px; }
  .try-view iframe { min-height: 280px; }
}
