:root {
  --bg: #fbfaff; --fg: #17151f; --muted: #5d5a6b; --line: #e6e3f0;
  --card: #ffffff; --accent: #6b4cf5; --accent-2: #0f8f70;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0e15; --fg: #ecebf3; --muted: #a29fb3; --line: #26243a;
          --card: #17151f; --accent: #9d86ff; --accent-2: #2dd4a7; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg);
       font: 18px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.wrap { max-width: 52rem; margin: 0 auto; padding: 0 16px; }

header.top { border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; justify-content: space-between;
                   gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg);
         text-decoration: none; font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
header.top nav a { color: var(--muted); text-decoration: none; margin-left: 18px; font-size: 16px; }
header.top nav a:hover, header.top nav a[aria-current] { color: var(--fg); }

.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); font-size: 20px; }

.posts { list-style: none; margin: 16px 0 48px; padding: 0; display: grid; gap: 16px; }
.posts li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.posts h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.3; }
.posts h2 a { color: var(--fg); text-decoration: none; }
.posts h2 a:hover { color: var(--accent); }
.posts p { margin: 0; color: var(--muted); }
.meta { color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.tag { display: inline-block; font-size: 13px; color: var(--accent-2); font-weight: 600;
       text-transform: uppercase; letter-spacing: .04em; margin-right: 8px; }

article { padding: 40px 0 32px; }
article h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); line-height: 1.2; margin: 0 0 8px; letter-spacing: -.02em; }
article h2 { font-size: 24px; margin: 36px 0 8px; line-height: 1.3; }
article h3 { font-size: 20px; margin: 28px 0 6px; }
article p, article ul, article ol { margin: 0 0 16px; }
article li { margin-bottom: 6px; }
article blockquote { margin: 0 0 16px; padding: 12px 16px; border-left: 3px solid var(--accent);
                     background: var(--card); border-radius: 0 10px 10px 0; color: var(--muted); }
.lead { font-size: 20px; color: var(--muted); }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; margin: 0 0 16px; }
.box p:last-child, .box ul:last-child { margin-bottom: 0; }
.next { border-top: 1px solid var(--line); padding: 24px 0 48px; }

/* The stages on the front page */
.stage { margin: 40px 0 8px; scroll-margin-top: 16px; }
.stage h2 { display: flex; align-items: center; gap: 12px; font-size: 24px; margin: 0 0 4px; }
.stage .num { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
              border-radius: 50%; background: var(--accent); color: #fff; font-size: 16px; }
.stage .posts { margin: 12px 0 0; gap: 10px; }
.stage .posts li { padding: 0; }
.stage .posts a { display: block; padding: 14px 18px; color: var(--fg); text-decoration: none; }
.stage .posts a:hover b { color: var(--accent); }
.stage .posts b { display: block; font-size: 19px; line-height: 1.35; margin-bottom: 2px; }
.stage .posts span { color: var(--muted); font-size: 16px; }
a.tag { text-decoration: none; }
.crumbs { margin-bottom: 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* Pictures, videos, code */
figure { margin: 24px 0; }
figure img { display: block; width: 100%; height: auto; border-radius: 12px;
             border: 1px solid var(--line); background: var(--card); }
figure.wide { margin: 8px 0 16px; }
a.zoom { display: block; cursor: zoom-in; }
figcaption { color: var(--muted); font-size: 15px; margin-top: 8px; }
code { font: .9em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
       background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }
pre { margin: 0 0 16px; padding: 14px 16px; overflow-x: auto; background: var(--card);
      border: 1px solid var(--line); border-radius: 12px; }
pre code { border: 0; padding: 0; background: none; font-size: 15px; }
table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 16px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

/* An article's way into the practice room (/practice). */
.practice-cta { display: flex; align-items: center; gap: 14px; margin: 0 0 24px; padding: 12px 20px 12px 12px;
                background: var(--card); border: 1px solid var(--line); border-radius: 16px; color: var(--fg);
                text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.practice-cta:hover, .practice-cta:focus-visible { border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(15,143,112,.15); outline: none; }
.practice-cta-icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px;
                     background: var(--accent-2); color: #fff; }
.practice-cta-text { display: grid; gap: 2px; min-width: 0; }
.practice-cta-text b { font-size: 18px; line-height: 1.3; }
.practice-cta-text span { font-size: 15px; line-height: 1.4; color: var(--muted); }
.practice-note { margin: -12px 0 24px; padding: 12px 16px; border-radius: 12px; font-size: 15px; line-height: 1.5;
                 background: var(--card); border: 1px solid var(--accent-2); color: var(--fg); }

/* The questions box: the button at the bottom right of every page (media/qa.js). */
.qa-open, .qa-go { font: inherit; font-weight: 600; border: 0; cursor: pointer; background: var(--accent); color: #fff; }
.qa-open { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border-radius: 50%; box-shadow: 0 6px 20px rgba(107,76,245,.35); }
.qa-panel { position: fixed; right: 16px; bottom: 76px; z-index: 30; width: min(440px, calc(100vw - 32px));
            max-height: min(70vh, 640px); overflow-y: auto; background: var(--card); color: var(--fg);
            border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.qa-panel[hidden] { display: none; }
.qa-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.qa-close { display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer;
             width: 44px; height: 44px; margin: -12px -12px -12px 0; border-radius: 10px; }
.qa-close:hover { color: var(--fg); }
.qa-form { display: flex; gap: 8px; }
.qa-input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px;
            border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.qa-mic { flex: none; display: grid; place-items: center; width: 44px; border-radius: 10px; cursor: pointer;
          border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.qa-mic:hover { border-color: var(--accent); color: var(--accent); }
.qa-mic.on { border-color: var(--accent); color: #fff; background: var(--accent); box-shadow: 0 0 0 3px rgba(107,76,245,.25); }
.qa-go { padding: 0 16px; font-size: 15px; border-radius: 10px; }
.qa-status { margin: 10px 0 0; }
.qa-status:empty { display: none; }
.qa-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qa-chip, .qa-tag { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--bg); color: var(--fg);
                    border-radius: 999px; line-height: 1.2; }
.qa-chip { font-size: 14px; padding: 7px 12px; }
.qa-tag { font-size: 12px; padding: 4px 9px; color: var(--muted); }
.qa-chip:hover, .qa-tag:hover { border-color: var(--accent); color: var(--accent); }
.qa-card .qa-chips { margin-top: 10px; }
.qa-card mark { background: rgba(107,76,245,.22); color: inherit; border-radius: 3px; padding: 0 2px; }
.qa-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.qa-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg); }
.qa-card p { margin: 8px 0 0; font-size: 15px; line-height: 1.5; color: var(--fg); white-space: pre-line; }
.qa-head { display: flex; gap: 10px; align-items: flex-start; }
.qa-head a { display: block; text-decoration: none; color: var(--fg); line-height: 1.3; }
.qa-head a b { display: block; font-size: 15px; }
.qa-head a span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.qa-head a:hover b { color: var(--accent); }
@media (max-width: 560px) { .qa-panel { bottom: 72px; right: 8px; width: calc(100vw - 16px); } }
@media (pointer: coarse) { .qa-go { min-height: 44px; } .qa-input { min-height: 44px; } }

/* Previous and next article */
.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid var(--line); padding: 24px 0 48px; }
.steps a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px;
           background: var(--card); color: var(--fg); text-decoration: none; line-height: 1.35; }
.steps a:hover { border-color: var(--accent); }
.steps .meta { display: block; margin-bottom: 4px; }
.steps .nextp { grid-column: 2; text-align: right; }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } .steps .nextp { grid-column: 1; } }

.center { text-align: center; padding: 96px 0; }
.center h1 { margin: 0 0 8px; }

footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
footer .wrap { padding-top: 20px; padding-bottom: 28px; display: flex; flex-wrap: wrap;
               gap: 8px 20px; justify-content: space-between; }
footer a { color: var(--muted); }

@media (max-width: 560px) {
  body { font-size: 17px; }
  header.top nav a { margin-left: 12px; }
  .hero { padding-top: 32px; }
}

/* The author's offer at the end of an article: a mock interview, in Telegram. */
.mentor { display: grid; grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "photo text" "photo go"; align-items: start; gap: 12px 20px; margin: 40px 0 8px; padding: 20px 22px;
          border-radius: 18px; border: 1px solid var(--line);
          background: linear-gradient(135deg, rgba(107,76,245,.10), rgba(15,143,112,.10)), var(--card); }
.mentor-text { grid-area: text; display: grid; gap: 4px; }
.mentor-text b { font-size: 19px; line-height: 1.3; }
.mentor-text span { font-size: 16px; line-height: 1.5; color: var(--muted); }
.mentor-text .mentor-name { color: var(--fg); font-weight: 600; font-size: 16px; }
.mentor-photo { grid-area: photo; width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--card); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.mentor-go { grid-area: go; justify-self: start; display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 999px;
             background: #229ed9; color: #fff; font-weight: 600; text-decoration: none; }
.mentor-go:hover { filter: brightness(1.08); }

/* On the front page the trainer sits under the questions box. */
.practice-cta.home { margin: 28px 0 0; }
.hero .mentor { margin-top: 12px; }

/* A stage's heading on the front page leads to the stage's own page. */
.stage h2 a { color: inherit; text-decoration: none; }
.stage h2 a:hover { text-decoration: underline; text-decoration-color: var(--accent); }

/* The way to the livecoding board, lit in the header. */
header.top nav a.accent { color: var(--accent-2); font-weight: 600; }
header.top nav a.accent:hover { text-decoration-color: var(--accent-2); }

/* The stages: a map of links that scroll to their sections. */
html { scroll-behavior: smooth; }
.map { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 36px; padding: 16px;
       border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.map a { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 10px 14px; border-radius: 14px;
         border: 1px solid var(--line); background: var(--bg); color: var(--fg); text-decoration: none; font-weight: 600; font-size: 15px; line-height: 1.25; text-align: center;
         transition: border-color .15s, transform .1s; }
.map a:hover { border-color: var(--accent); transform: translateY(-1px); }
.map a .num { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 17px; }
.map a.last { border-color: var(--accent-2); }
.map a.last .num { background: var(--accent-2); }
@media (max-width: 640px) { .map { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; } }
@media (max-width: 560px) { .mentor { grid-template-columns: 72px minmax(0, 1fr); gap: 10px 14px; padding: 16px; } .mentor-photo { width: 72px; height: 72px; } }
