:root {
  --bg: #fff7e6;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --brand: #d97706;
  --brand2: #f59e0b;
  --brand3: #fff2d6;
  --border: #eadcc5;
  --shadow: 0 18px 40px rgba(31, 41, 55, 0.14);
  --soft-shadow: 0 10px 22px rgba(31, 41, 55, 0.08);
  --codebg: #0b1220;
  --codeink: #e5e7eb;
  --ok: #166534;
  --warn: #92400e;
  --danger: #b91c1c;
  --focus: rgba(245, 158, 11, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(245, 158, 11, 0.22), transparent 60%),
    radial-gradient(900px 600px at 90% 0%, rgba(217, 119, 6, 0.18), transparent 55%),
    var(--bg);
  color: var(--ink);
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 14px; }
.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--codebg);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  z-index: 2000;
}
.skip-link:focus { left: 8px; }

.site-header, .site-footer {
  background: rgba(255, 255, 255, 0.62);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.site-footer { border-top: 1px solid var(--border); border-bottom: 0; margin-top: 24px; }
.site-header-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.site-link { color: var(--brand); font-weight: 900; text-decoration: none; }
.site-footer p { margin: 6px 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 247, 230, 0.90);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.logo {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: radial-gradient(circle at 30% 30%, #fff, #ffe7bf 45%, #ffd59a 100%);
  border: 1px solid var(--border);
  box-shadow: var(--soft-shadow);
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 1000;
}
.brand-small { font-size: 14px; color: var(--muted); font-weight: 800; }
.brand-title { font-size: 16px; }
.nav { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

button, textarea, select { font: inherit; }
.chip, .btn, .xbtn {
  cursor: pointer;
  user-select: none;
  border-radius: 999px;
  font-weight: 850;
}
.chip {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--soft-shadow);
  color: var(--ink);
}
.btn {
  appearance: none;
  border: 0;
  background: linear-gradient(180deg, var(--brand2), var(--brand));
  color: white;
  padding: 10px 13px;
  border-radius: 14px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(217, 119, 6, 0.24);
}
.btn.secondary, .xbtn {
  background: rgba(255, 255, 255, 0.94);
  color: var(--brand);
  border: 1px solid var(--border);
  box-shadow: var(--soft-shadow);
}
button:active { transform: translateY(1px); }
button:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 14px;
}
.eyebrow { margin: 0 0 4px; color: var(--brand); font-weight: 950; letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(26px, 4vw, 48px); max-width: 760px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.hero-text { color: var(--muted); line-height: 1.65; max-width: 760px; margin: 10px 0 0; }
.hero-actions, .button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: 1.32fr 0.68fr; gap: 14px; align-items: start; margin-top: 14px; }
.side-stack { display: grid; gap: 14px; }
.section-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.section-top.compact { margin-bottom: 8px; }
.muted { color: var(--muted); }
.section-top p, .callout p { margin: 6px 0 0; line-height: 1.55; }
.mouse-box {
  border: 1px solid var(--border);
  background: rgba(255, 247, 230, 0.86);
  color: var(--brand);
  border-radius: 14px;
  padding: 8px 10px;
  font-weight: 900;
  white-space: nowrap;
}

canvas {
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff;
  display: block;
}
.canvas-figure { margin: 0; }
figcaption { color: var(--muted); font-size: 13px; margin-top: 7px; line-height: 1.5; }

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--soft-shadow);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #fffdf8;
  color: var(--ink);
}

.hud { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.hud .box {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--soft-shadow);
  font-weight: 750;
  color: var(--ink);
}
.status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed rgba(217, 119, 6, 0.35);
  background: rgba(245, 158, 11, 0.1);
  color: #7c2d12;
  font-weight: 850;
  line-height: 1.6;
}
.status.good { color: var(--ok); border-color: rgba(22, 101, 52, 0.35); background: rgba(22, 101, 52, 0.08); }
.status.bad { color: var(--danger); border-color: rgba(185, 28, 28, 0.35); background: rgba(185, 28, 28, 0.08); }
.status.warn { color: var(--warn); border-color: rgba(146, 64, 14, 0.35); background: rgba(146, 64, 14, 0.08); }

.kbd, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.kbd {
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(11, 18, 32, 0.96);
  color: #e5e7eb;
}
.callout {
  border-left: 6px solid var(--brand2);
  background: rgba(245, 158, 11, 0.1);
  padding: 10px 12px;
  border-radius: 14px;
  margin-top: 10px;
}
.warn-callout { border-left-color: var(--warn); }
.callout ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; }
pre {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--codebg);
  color: var(--codeink);
  border-radius: 16px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
pre code { color: inherit; }

.lesson { margin-top: 14px; }
.lesson-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mini-card {
  border: 1px solid var(--border);
  background: rgba(255, 247, 230, 0.56);
  border-radius: 18px;
  padding: 12px;
}
.mini-card p { color: var(--muted); line-height: 1.6; margin: 8px 0 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(2, 6, 23, 0.52);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.35);
  padding: 14px;
}
.modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.98);
  padding: 10px;
  border-bottom: 1px solid var(--border);
  border-radius: 18px;
  z-index: 2;
}
.xbtn { padding: 8px 10px; border-radius: 14px; font-weight: 900; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
}
th, td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: rgba(255, 247, 230, 0.86); text-align: left; }
tr:last-child td { border-bottom: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1050px) {
  .grid { grid-template-columns: 1fr; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .lesson-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .topbar-inner, .hero, .section-top { align-items: stretch; flex-direction: column; }
  .hud, .lesson-grid { grid-template-columns: 1fr; }
  .nav, .hero-actions, .button-row { width: 100%; }
  .chip, .btn { flex: 1 1 auto; }
}
