:root {
  /* Tell the browser which way round we are. Without this the UA picks from
     the OS preference, not from data-theme, so choosing Dark on a light
     machine left native scrollbars, form controls and the canvas painted
     light: a white scrollbar down the side of the dark code editor. */
  color-scheme: light;
  /* PyWebLib palette: indigo chrome, amber accents, light surfaces. */
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #586079;
  --border: #e3e8f2;
  --primary: #4f46e5;       /* indigo */
  --primary-dark: #4338ca;  /* darker indigo */
  --accent: #ffd43b;        /* python yellow */
  --accent-ink: #1e1b4b;    /* text colour over yellow */
  --highlight: #9900ff;
  --success: #1f9d55;
  --success-bg: #e4f6ec;
  --danger: #d23c3c;
  --danger-bg: #fbe6e6;
  
  /* ⭐ 浅色模式下：编辑器背景和文字 */
  --code-bg: #ffffff;
  --code-text: #1e293b;
  
  --shadow-sm: 0 1px 2px rgba(20, 22, 50, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 22, 50, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --code-font-size: 0.95rem; /* 默认编辑器字号 */
}

/* ===== Dark theme =================================================== =====
   data-theme is set by an inline script in <head> before this file paints, so
   there is no flash. Only the shell flips: the code panels, console, game
   canvas and card thumbnails are already dark in the light theme and stay
   exactly as they are, which is why this is six tokens and not fifty.
   ------------------------------------------------------------------------ */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #151b30;
  --text: #e7eaf6;
  --muted: #99a3c0;
  --border: #28324e;
  --success-bg: #12301f;
  --danger-bg: #3a1c1c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
  
  /* ⭐ 深色模式下：编辑器背景和文字 */
  --code-bg: #0f1226;
  --code-text: #e6e7ef;
}

/* The light surfaces that were written as literals rather than tokens. Each of
   these is a pale panel that would stay white in dark mode. */
[data-theme="dark"] .callout { background: #241f0f; border-color: #4a3d12; }
[data-theme="dark"] .callout code { background: #33290f; color: #f0e2c0; }
[data-theme="dark"] .key-points li { background: #141a2c; }
[data-theme="dark"] .guide :not(pre) > code { background: #1c2440; color: #dbe3ff; }
[data-theme="dark"] .community-notice { background: #241f0f; border-color: #4a3d12; }
[data-theme="dark"] .community-card.is-draft { background: #241d10; border-color: #4a3a17; }
[data-theme="dark"] .community-card.is-featured { border-color: #b9902f; box-shadow: 0 0 0 3px rgba(232, 196, 106, 0.13), var(--shadow-md); }
[data-theme="dark"] .cc-btn.cc-feat { color: #e8c46a; }
[data-theme="dark"] .pwl-cap-note { background: #2a2210; }
[data-theme="dark"] .indent-hint { background: #241f0f; border-color: #4a3d12; }
[data-theme="dark"] .lb-top-2 .lb-rank { color: #b9c2d4; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}
.logo-mark {
  width: 32px;
  height: 32px;
  display: inline-block;
  vertical-align: middle;
}
.header-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.header-link:hover { color: var(--text); background: var(--bg); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface); border-color: var(--muted); }

/* Sections */
.section { padding: 60px 0; }
.section-top { padding-top: 28px; }

/* Present to a screen reader and to a crawler, invisible on screen. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Page hero */
.page-hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 48px 0 36px;
}

.page-hero-tuck { padding: 0; }
.hero-tuck { padding: 11px 0; }
.hero-tuck[open] { padding: 32px 0 30px; }
.hero-tuck > summary {
  display: block;
  width: 32px; height: 32px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--muted);
  font-size: 0.95rem; font-weight: 800; line-height: 30px; text-align: center;
  cursor: pointer; user-select: none;
  transition: color .12s, border-color .12s;
}
.hero-tuck > summary::-webkit-details-marker { display: none; }
.hero-tuck > summary::marker { content: ""; }
.hero-tuck > summary:hover, .hero-tuck > summary:focus-visible {
  color: var(--primary); border-color: var(--primary);
}
.hero-tuck[open] > summary { margin-bottom: 16px; }
.hero-tuck > .eyebrow { margin-top: 0; }
.community-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 0 14px; }
.community-strip > .hero-tuck { flex: none; }
.community-strip > .hero-tuck > summary { margin: 0; }
.community-strip > .hero-tuck[open] { flex-basis: 100%; padding-bottom: 0; }
.community-search { flex: 1; min-width: 0; display: flex; gap: 8px; padding: 10px 0; }
.hero-tuck[open] + .community-search { padding-bottom: 22px; }
.community-search input {
  flex: 1; min-width: 0; font: inherit; color: inherit;
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg);
}
.community-search input:focus { outline: none; border-color: var(--primary); }
.community-search .btn { padding: 7px 18px; border-radius: 999px; }
.page-hero h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  margin: 8px 0 12px;
  letter-spacing: -0.02em;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}
.lead {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 52ch;
  margin: 0 0 24px;
}

/* ===== Live Python sandbox ===== */
.sandbox-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.sandbox-editor,
.sandbox-output {
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  min-width: 0;
  box-shadow: var(--shadow-md);
  transition: background 0.3s, color 0.3s;
}
.sandbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(127, 127, 127, 0.05);
  border-bottom: 1px solid var(--border);
  color: var(--code-text);
}
.sandbox-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  opacity: 0.85;
}

/* ================= 行号样式 ================= */
.has-gutter-host { position: relative; }
.sandbox-gutter {
  position: absolute;
  left: 0;
  width: 44px;
  padding: 14px 8px 14px 0;
  box-sizing: border-box;
  color: var(--muted);
  background: var(--code-bg);
  border-right: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
  transition: background 0.3s, border-color 0.3s;
}
.sandbox-gutter-inner {
  text-align: right;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--code-font-size, 0.95rem);
  line-height: 1.55;
  will-change: transform;
}
.sandbox-code.has-linenums { padding-left: 56px; }

/* ================= 编辑器与代码高亮 ================= */
.sandbox-code {
  display: block;
  flex: 1;
  background: transparent;
  color: var(--code-text);
  padding: 14px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--code-font-size, 0.95rem);
  line-height: 1.55;
  outline: none;
  overflow: auto;
  tab-size: 4;
  -moz-tab-size: 4;
  caret-color: var(--primary);
  min-height: 280px;
  word-break: normal;
}
.sandbox-code:focus { outline: none; }

/* 浅色模式的语法高亮 */
.sandbox-code .token.keyword, .sandbox-code .token.class-name      { color: #a626a4; }
.sandbox-code .token.string, .sandbox-code .token.attr-value       { color: #50a14f; }
.sandbox-code .token.number, .sandbox-code .token.boolean          { color: #986801; }
.sandbox-code .token.comment                                       { color: #a0a1a7; font-style: italic; }
.sandbox-code .token.operator, .sandbox-code .token.punctuation    { color: #0184bc; }
.sandbox-code .token.function, .sandbox-code .token.builtin        { color: #4078f2; }
.sandbox-code .token.decorator                                     { color: #c18401; }
.sandbox-code .token.namespace                                     { opacity: 0.7; }

/* 深色模式覆盖语法高亮 */
[data-theme="dark"] .sandbox-code .token.keyword, [data-theme="dark"] .sandbox-code .token.class-name      { color: #c792ea; }
[data-theme="dark"] .sandbox-code .token.string, [data-theme="dark"] .sandbox-code .token.attr-value       { color: #c3e88d; }
[data-theme="dark"] .sandbox-code .token.number, [data-theme="dark"] .sandbox-code .token.boolean          { color: #f78c6c; }
[data-theme="dark"] .sandbox-code .token.comment                                                           { color: #8b92b0; }
[data-theme="dark"] .sandbox-code .token.operator, [data-theme="dark"] .sandbox-code .token.punctuation    { color: #89ddff; }
[data-theme="dark"] .sandbox-code .token.function, [data-theme="dark"] .sandbox-code .token.builtin        { color: #82aaff; }
[data-theme="dark"] .sandbox-code .token.decorator                                                         { color: #ffcb6b; }

.sandbox-out-body {
  flex: 1;
  margin: 0;
  padding: 14px 18px;
  color: var(--code-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--code-font-size, 0.95rem);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
}
.sandbox-run[disabled] { opacity: 0.55; cursor: not-allowed; }
.sandbox-run.is-busy { position: relative; }

.btn.btn-danger {
  background: var(--danger);
  color: white;
  border: 1px solid var(--danger);
}
.btn.btn-danger:hover { background: #b32d2d; border-color: #b32d2d; }
.btn.btn-danger:active { transform: translateY(1px); }

.sandbox-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sandbox-bar .btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 8px;
}
.sandbox-bar .btn-ghost {
  background: rgba(127, 127, 127, 0.1);
  color: var(--code-text);
  border: 1px solid rgba(127, 127, 127, 0.3);
}
.sandbox-bar .btn-ghost:hover {
  background: rgba(127, 127, 127, 0.2);
  border-color: rgba(127, 127, 127, 0.5);
  color: var(--code-text);
}

.sandbox-out-body .out-stdout { color: var(--code-text); }
.sandbox-out-body .out-stderr { color: #ff8a8a; }
.sandbox-out-body .out-info   { color: var(--muted); font-style: italic; }

.sandbox-out-body .out-stdin { color: var(--primary); }
.sandbox-stdin {
  font: inherit;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
  border: 0;
  border-radius: 3px;
  outline: none;
  padding: 0 2px;
  margin: 0;
  min-width: 1ch;
  caret-color: transparent;
  vertical-align: baseline;
}
.sandbox-stdin:focus { background: rgba(79, 70, 229, 0.2); }
.sandbox-cursor {
  display: inline-block;
  width: 0.55ch;
  height: 1.15em;
  margin-left: -2px;
  background: var(--primary);
  vertical-align: text-bottom;
  animation: sandbox-cursor-blink 1.06s steps(1, end) infinite;
}
@keyframes sandbox-cursor-blink {
  0%, 50%      { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sandbox-cursor { animation: none; }
}

.sandbox-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.sandbox-hint kbd {
  display: inline-block;
  padding: 1px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text);
}

/* Click-to-load snippet cards at the bottom of the page. */
.sandbox-examples {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1.5px solid var(--border);
}
.sandbox-examples-heading {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  user-select: none;
}
.sandbox-examples-heading::-webkit-details-marker { display: none; }
.sandbox-examples-heading::marker { content: ""; }
.sandbox-examples-heading::before {
  content: "";
  width: 0; height: 0;
  border-left: 7px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform .15s ease;
  flex: none;
}
.sandbox-examples-drawer[open] > .sandbox-examples-heading { margin-bottom: 8px; }
.sandbox-examples-drawer[open] > .sandbox-examples-heading::before { transform: rotate(90deg); }
.sandbox-examples-heading:hover { color: var(--primary); }
.sandbox-examples-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}
.sandbox-examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.sandbox-example-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
}
.sandbox-example-card:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.sandbox-example-card:active { transform: translateY(0); }
.sandbox-example-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--primary-dark);
}
.sandbox-example-desc {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 100px);
  background: var(--primary-dark);
  color: white;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(20, 22, 50, 0.25);
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.22s ease-out;
  max-width: calc(100vw - 32px);
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
.toast-msg {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-action {
  background: var(--accent);
  color: var(--primary-dark);
  border: 0;
  padding: 5px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.12s, transform 0.06s;
}
.toast-action:hover { background: white; }
.toast-action:active { transform: translateY(1px); }

/* Responsive */
@media (max-width: 760px) {
  .sandbox-shell { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0;
  margin-top: 40px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}
.site-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }

/* Header nav */
.site-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.header-link.active { color: var(--text); background: var(--bg); }

/* Docs dropdown in the header nav */
.nav-dd { position: relative; display: inline-flex; align-items: center; }
.nav-dd > .header-link { display: inline-flex; align-items: center; }
.nav-caret { width: 9px; height: 9px; margin-left: 5px; opacity: 0.7; }
.nav-dd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 168px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 18, 38, 0.16); padding: 6px; display: none; z-index: 60;
}
.nav-dd:hover .nav-dd-menu, .nav-dd:focus-within .nav-dd-menu, .nav-dd.open .nav-dd-menu { display: block; }
.nav-dd-menu::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 6px; }
.nav-dd-trigger { background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav-caret { transition: transform 0.15s ease; }
.nav-dd.open .nav-caret { transform: rotate(180deg); }
.nav-dd-menu a {
  display: block; padding: 8px 10px; border-radius: 7px; color: var(--text);
  text-decoration: none; font-weight: 600; font-size: 0.9rem; white-space: nowrap;
}
.nav-dd-menu a:hover { background: var(--bg); }
.nav-dd-menu a.active { color: var(--primary); }

/* Guide landing: one big card per library */
.guide-cards { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 720px) { .guide-cards { grid-template-columns: 1fr 1fr; } }
.guide-lib-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.guide-lib-media { background: #0b1020; aspect-ratio: 16 / 10; overflow: hidden; }
.guide-lib-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.guide-lib-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.guide-lib-body h2 { margin: 0; }
.guide-lib-body p { margin: 0; color: var(--muted); }
.guide-lib-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* Inline code in prose (hints, hero). */
.sandbox-hint code,
.lead code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 5px;
}

/* ===== Right column: turtle + game windows stacked beside the output ===== */
.sandbox-right {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.turtle-panel,
.game-panel { min-height: 0; }
.turtle-panel[hidden],
.game-panel[hidden] { display: none; }

.turtle-stage {
  position: relative;
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: center;
}
.turtle-stage canvas {
  display: block;
  width: 100%;
  height: auto;
}
.turtle-stage canvas + canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 3D window */
.game3d-panel[hidden] { display: none; }
.game3d-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
}
.game3d-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #8ec5f0;
  outline: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.game3d-stage canvas:focus-visible { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.55); }

/* Game window */
.game-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
}
.game-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
}
.game-stage canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #0b1020;
  outline: none;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.game-stage canvas:focus-visible {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.55);
}

/* Fullscreen game */
.game-stage { position: relative; }
.game-fs-btn { padding: 6px 9px; }
.game-fs-btn svg { display: block; }
.game-fs-exit { display: none; }
body.pwl-game-fs { overflow: hidden; }
body.pwl-game-fs .game-stage,
body.pwl-game-fs .turtle-stage,
body.pwl-game-fs .game3d-stage {
  position: fixed;
  inset: 0;
  z-index: 500;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.pwl-game-fs .game-stage canvas,
body.pwl-game-fs .game3d-stage canvas {
  max-width: none;
  height: auto;
  border-radius: 0;
}
body.pwl-game-fs .turtle-stage canvas {
  max-width: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
}
body.pwl-game-fs .game-fs-exit {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 510;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* ===== Snippet categories ===== */
.sandbox-example-groups { display: flex; flex-direction: column; gap: 10px; }
.sandbox-example-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.sandbox-example-group > summary {
  cursor: pointer;
  padding: 11px 14px;
  font-weight: 700;
  color: var(--primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.sandbox-example-group > summary::-webkit-details-marker { display: none; }
.sandbox-example-group > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
  flex: none;
}
.sandbox-example-group[open] > summary::before { transform: rotate(90deg); }
.sandbox-example-group > summary:hover { color: var(--primary-dark); }
.sandbox-example-count {
  margin-left: auto;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 9px;
}
.sandbox-example-group .sandbox-examples-grid { padding: 0 14px 14px; }

/* Outer snippet sections */
.sandbox-example-section > summary {
  cursor: pointer;
  padding: 4px 2px 10px;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.sandbox-example-section > summary::-webkit-details-marker { display: none; }
.sandbox-example-section > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 7px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  transition: transform 0.15s ease;
  flex: none;
}
.sandbox-example-section[open] > summary::before { transform: rotate(90deg); }
.sandbox-example-section > summary:hover { color: var(--primary); }
.sandbox-example-section > .sandbox-example-group { margin: 0 0 10px 18px; }
.sandbox-example-section + .sandbox-example-section { margin-top: 6px; }

/* ===== Documentation page ===== */
.docs-searchbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.docs-search-input {
  flex: 1;
  padding: 12px 18px;
  font: inherit;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
}
.docs-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.docs-count { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.docs-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.docs-chip {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  text-decoration: none;
}
.docs-chip:hover { border-color: var(--primary); background: var(--bg); }

[data-fam]         { --sec: var(--primary); }
[data-fam="core"]  { --sec: #4e8cff; }
[data-fam="data"]  { --sec: #17a673; }
[data-fam="lib"]   { --sec: #9061e8; }
[data-fam="draw"]  { --sec: #e05a9b; }
[data-fam="error"] { --sec: #e0503f; }
[data-theme="dark"] [data-fam="core"]  { --sec: #6fa6ff; }
[data-theme="dark"] [data-fam="data"]  { --sec: #2fd39a; }
[data-theme="dark"] [data-fam="lib"]   { --sec: #b08cff; }
[data-theme="dark"] [data-fam="draw"]  { --sec: #ff86bd; }
[data-theme="dark"] [data-fam="error"] { --sec: #ff7d6d; }

.docs-chip[data-fam] {
  border-color: color-mix(in srgb, var(--sec) 55%, transparent);
  background: color-mix(in srgb, var(--sec) 12%, var(--surface));
}
.docs-chip[data-fam]:hover {
  border-color: var(--sec);
  background: color-mix(in srgb, var(--sec) 24%, var(--surface));
}
[data-theme="dark"] .docs-chip[data-fam] { color: var(--sec); }
.docs-section { margin: 0 0 30px; scroll-margin-top: 84px; }
.docs-section[hidden] { display: none; }
.docs-section-title {
  margin: 0 0 4px; color: var(--primary-dark);
  border-left: 5px solid var(--sec); padding-left: 11px;
}
.docs-section-blurb { padding-left: 16px; margin: 0 0 14px; color: var(--muted); }
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.docs-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sec);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.docs-item[hidden] { display: none; }
.docs-sig {
  align-self: flex-start;
  max-width: 100%;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.docs-desc { margin: 0; font-size: 0.92rem; line-height: 1.45; }
.docs-ex {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}
.docs-empty { color: var(--muted); font-style: italic; }

/* ===== Maximise the code editor ===== */
.sandbox-max { padding: 6px 10px; }
.sandbox-max svg { display: block; }
.sandbox-max .i-compress { display: none; }
.sandbox-editor.is-max .sandbox-max .i-expand { display: none; }
.sandbox-editor.is-max .sandbox-max .i-compress { display: block; }
.sandbox-editor.is-max {
  position: fixed;
  inset: 0;
  z-index: 200;
  margin: 0;
  min-height: 0;
  border-radius: 0;
}
.sandbox-editor.is-max .sandbox-code { max-height: none; }
body.sandbox-maxed { overflow: hidden; }

/* ===== Collapsible code ===== */
.sandbox-editor:not(.is-max):not(.is-expanded) .sandbox-code {
  max-height: var(--code-cap, 420px);
}
.sandbox-expand-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 88px;
  background: linear-gradient(to bottom, rgba(11, 16, 32, 0), var(--code-bg) 82%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 2;
}
.sandbox-editor.can-expand:not(.is-expanded):not(.scrolled-end) .sandbox-expand-fade {
  opacity: 1;
}
.sandbox-expand {
  position: absolute;
  left: 50%; bottom: 10px;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--code-text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  font: 600 0.8rem ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  z-index: 3;
  transition: background 0.12s ease;
}
.sandbox-editor.can-expand .sandbox-expand { display: inline-flex; }
.sandbox-expand:hover { background: rgba(255, 255, 255, 0.2); }
.sandbox-expand-chev { display: block; transition: transform 0.15s ease; }
.sandbox-editor.is-expanded .sandbox-expand-chev { transform: rotate(180deg); }
.sandbox-shell.editor-expanded { align-items: start; }
.sandbox-editor.is-max .sandbox-expand,
.sandbox-editor.is-max .sandbox-expand-fade { display: none; }

/* ===== Editor helpers ===== */
.sandbox-editor { position: relative; }
.indent-hint {
  padding: 6px 12px;
  background: #fff3cd;
  color: #6b5200;
  font-size: 0.84rem;
  border-top: 1px solid #e6d9a8;
}
.indent-flag {
  position: absolute;
  pointer-events: none;
  background: rgba(255, 82, 82, 0.14);
  border-left: 3px solid rgba(255, 82, 82, 0.65);
  border-radius: 2px;
  z-index: 2;
}
.name-flag {
  position: absolute;
  pointer-events: none;
  background: rgba(255, 82, 82, 0.16);
  border-bottom: 2px solid #e53935;
  border-radius: 2px;
  z-index: 2;
}

/* ============================ Community layer ============================ */
.pwl-account { display: inline-flex; align-items: center; }
.btn-google {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: #3c4043; border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; font-family: inherit;
}
.btn-google:hover { background: var(--bg); border-color: var(--muted); }
.g-icon { flex: none; }
.pwl-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--primary); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700;
  position: relative; overflow: hidden;
}
.pwl-avatar.sm { width: 22px; height: 22px; font-size: 0.7rem; }
.pwl-avatar-person { position: absolute; inset: 0; width: 100%; height: 100%; fill: rgba(255, 255, 255, 0.92); }
.pwl-avatar-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.pwl-acct { position: relative; }
.pwl-acct-btn {
  display: inline-flex; align-items: center; gap: 8px; background: transparent;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 4px;
  cursor: pointer; font-family: inherit; font-weight: 600; color: var(--text); font-size: 0.9rem;
}
.pwl-acct-btn:hover { background: var(--bg); }
.pwl-acct-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pwl-acct-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 160px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md); padding: 6px; display: none; z-index: 50;
}
.pwl-acct[data-open="true"] .pwl-acct-menu { display: block; }
.pwl-acct-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0;
  background: transparent; border-radius: 7px; cursor: pointer; font: inherit;
  color: var(--text); text-decoration: none;
}
.pwl-acct-item:hover { background: var(--bg); }

.pwl-share { margin-top: 18px; }
.share-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(120deg, rgba(79,70,229,0.08), rgba(255,212,59,0.10));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px;
}
.share-cta h2 { margin: 0 0 2px; font-size: 1.1rem; }
.share-cta p { margin: 0; color: var(--muted); font-size: 0.92rem; max-width: 46ch; }
.share-cta-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-arrow { width: 15px; height: 15px; margin-left: 6px; vertical-align: -2px; }

.community-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.community-tabs { display: inline-flex; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.community-mine-title { margin: 0; font-size: 1.4rem; }
.community-tab { border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 700; color: var(--muted); }
.community-tab.active { background: var(--primary); color: #fff; }
.community-notice { background: #fff3cd; color: #6b5200; border: 1px solid #e6d9a8; border-radius: var(--radius); padding: 14px 16px; }
.community-empty { color: var(--muted); padding: 24px 2px; }
.asset-grid .community-empty,
.community-grid .community-empty { grid-column: 1 / -1; text-align: center; }
.community-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.cc-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 24px 0 4px; flex-wrap: wrap; }
.cc-page-btn { padding: 8px 15px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.cc-page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.cc-page-btn:disabled { opacity: 0.45; cursor: default; }
.cc-page-info { font-size: 0.9rem; color: var(--muted); }
.community-card { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; }
.cc-head { display: flex; align-items: center; gap: 10px; }
.cc-title { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.cc-desc { margin: 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.cc-author { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.82rem; }
.cc-views, .pg-views { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cc-views svg, .pg-views svg { display: block; opacity: 0.85; }
.cc-kind { flex: none; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; color: #fff; background: var(--muted); }
.cc-kind-python { background: #3b82f6; }
.cc-kind-turtle { background: #22b45e; }
.cc-kind-game { background: #a855f7; }
.cc-kind-game3d { background: var(--primary); }
.cc-kind.cc-draft { background: #b45309; }
.community-card.is-draft { border: 1.5px dashed #d9861f; background: #fff8ee; box-shadow: 0 1px 0 #f1ddbf, var(--shadow-sm); }
.community-card.is-draft .cc-thumb { opacity: 0.92; }
.cc-kind.cc-featured { background: linear-gradient(180deg, #e8c46a, #c99a2e); color: #2b2109; }
.community-card.is-featured {
  border: 1.5px solid #e0b64a;
  box-shadow: 0 0 0 3px rgba(232, 196, 106, 0.22), var(--shadow-md);
  background: linear-gradient(180deg, rgba(232, 196, 106, 0.12), rgba(232, 196, 106, 0) 140px), var(--surface);
}
.cc-btn.cc-feat { border-color: #c99a2e; color: #a87c17; font-weight: 700; }
.cc-btn.cc-feat:hover { background: rgba(232, 196, 106, 0.18); }
.cc-btn.cc-feat.on { background: #e8c46a; border-color: #c99a2e; color: #2b2109; }
.cc-btn.cc-publish, .btn.pwl-publish-alt { border-color: #a855f7; color: #a855f7; font-weight: 700; }
.cc-btn.cc-publish:hover, .btn.pwl-publish-alt:hover { background: #a855f7; color: #fff; }
.cc-btn.cc-publish.armed { background: #a855f7; border-color: #a855f7; color: #fff; }
.cc-btn.cc-mod { border-color: var(--danger); color: var(--danger); font-weight: 700; }
.cc-btn.cc-mod:hover { background: var(--danger-bg); }
.cc-btn.cc-mod-del.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.share-cta.share-cta-draft { border-left: 3px solid #d9861f; padding-left: 15px; }
.cc-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.cc-vote { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; font-weight: 700; color: var(--muted); }
.cc-vote:hover { border-color: var(--primary); color: var(--primary); }
.cc-vote.voted { background: var(--primary); border-color: var(--primary); color: #fff; }
.cc-arrow { font-size: 0.7rem; }
.cc-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: 0.82rem; color: var(--text); }
.cc-btn:hover { border-color: var(--primary); }

.pwl-modal-back { position: fixed; inset: 0; background: rgba(15,18,38,0.5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 200; overflow-y: auto; }
.pwl-modal { position: relative; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 24px 26px; width: 100%; max-width: 560px; }
.pwl-modal-x { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); }
.pwl-modal-title { margin: 0 0 6px; padding-right: 24px; }
.pwl-modal-desc { color: var(--muted); margin: 8px 0; overflow-wrap: anywhere; }
.pwl-modal-code { background: var(--code-bg); color: var(--code-text); border-radius: 8px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; line-height: 1.5; overflow: auto; max-height: 240px; white-space: pre; margin: 10px 0; }
.pwl-modal-actions { display: flex; gap: 10px; }

.pwl-signin-tabs { display: flex; gap: 4px; margin: 14px 0 16px; border-bottom: 1px solid var(--border); }
.pwl-signin-tab {
  font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 8px 14px; margin-bottom: -1px;
}
.pwl-signin-tab:hover { color: var(--text); }
.pwl-signin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.pwl-signin-google { width: 100%; justify-content: center; padding: 11px 14px; }
.pwl-signin-or {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0 4px; color: var(--muted); font-size: 0.85rem;
}
.pwl-signin-or::before, .pwl-signin-or::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.pwl-signin-swap { color: var(--muted); font-size: 0.88rem; margin: 4px 0 0; }
.pwl-linkbtn {
  font: inherit; font-weight: 600; color: var(--primary);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
}

.pwl-signin-row { display: flex; gap: 10px; align-items: flex-start; }
.pwl-signin-row > label { flex: 1; }
.pwl-signin-row > .pwl-signin-pin { flex: 0 0 88px; }
#pwl-code-form input[name="code"], #pwl-code-form input[name="pin"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em; text-transform: uppercase; width: 100%;
}
#pwl-code-form input[name="pin"] { text-align: center; letter-spacing: 0.25em; }
#pwl-code-form input::placeholder { letter-spacing: normal; text-transform: none; }

.pwl-share-form { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.pwl-share-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.88rem; }
.pwl-share-form input, .pwl-share-form textarea, .pwl-share-form select { font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); resize: vertical; }
.pwl-share-form select { cursor: pointer; }
.pwl-cap-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: #fef3c7; color: #92400e; font-size: 0.85rem; font-weight: 600; }

.pwl-myprograms:not(:empty) { margin-top: 12px; }
.pwl-mine { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px 14px; }
.pwl-mine-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; padding: 2px 0; cursor: pointer;
  font: inherit; color: var(--text); text-align: left;
}
.pwl-mine-head:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 6px; }
.pwl-mine-title { font-weight: 700; font-size: 0.92rem; }
.pwl-mine-count {
  background: var(--primary); color: #fff; font-size: 0.74rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.pwl-mine-chev { width: 12px; height: 8px; flex: none; color: var(--muted); transition: transform 0.18s ease; }
.pwl-mine[data-open="false"] .pwl-mine-chev { transform: rotate(180deg); }
.pwl-mine[data-open="false"] .pwl-mine-grid { display: none; }

.pwl-mine-grid {
  display: grid; gap: 10px; margin-top: 12px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.pwl-mine-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; cursor: pointer; font: inherit; color: var(--text);
  transition: border-color 0.15s ease, transform 0.06s ease;
}
.pwl-mine-card:hover { border-color: var(--primary); }
.pwl-mine-card:active { transform: translateY(1px); }
.pwl-mine-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pwl-mine-name {
  font-weight: 700; font-size: 0.9rem; display: flex; align-items: center; gap: 7px;
  overflow-wrap: anywhere;
}
.pwl-mine-draft {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--border); color: var(--muted); padding: 1px 6px; border-radius: 4px;
  flex: none; white-space: nowrap; align-self: flex-start;
}
.pwl-mine-meta {
  font-size: 0.78rem; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pwl-mine-dot { font-family: inherit; }
@media (prefers-reduced-motion: reduce) {
  .pwl-mine-chev, .pwl-mine-card { transition: none; }
}
.pwl-share-form input:focus, .pwl-share-form textarea:focus, .pwl-share-form select:focus { outline: none; border-color: var(--primary); }

/* Comments */
.pwl-comments-h { margin: 18px 0 8px; font-size: 1rem; border-top: 1px solid var(--border); padding-top: 16px; }
.pwl-comments { display: flex; flex-direction: column; gap: 12px; }
.pwl-comments-empty { color: var(--muted); font-size: 0.9rem; }
.pwl-comment { display: flex; gap: 9px; align-items: flex-start; }
.pwl-comment-body { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.pwl-comment-name { font-weight: 700; font-size: 0.85rem; }
.pwl-comment-when { color: var(--muted); font-weight: 400; font-size: 0.78rem; margin-left: 4px; }
.pwl-comment-text { font-size: 0.92rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.pwl-comment-text a { color: var(--primary); text-decoration: underline; overflow-wrap: anywhere; }
.pwl-comment-del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; }
.pwl-comment-del:hover { color: var(--danger); }
.pwl-comment-form { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.pwl-comment-form textarea { flex: 1; font: inherit; color: inherit; line-height: 1.4; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); resize: none; max-height: 10em; overflow-y: auto; box-sizing: border-box; }
.pwl-comment-form textarea:focus { outline: none; border-color: var(--primary); }
.pwl-comment-signin { color: var(--muted); font-size: 0.88rem; margin-top: 12px; }

/* Leaderboard */
.leaderboard { display: flex; flex-direction: column; gap: 8px; max-width: 620px; }
.lb-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow-sm); }
.lb-rank { font-weight: 800; color: var(--muted); width: 1.6em; text-align: center; font-size: 1.05rem; }
.lb-top-1 .lb-rank { color: #e0a92e; }
.lb-top-2 .lb-rank { color: #9aa3b2; }
.lb-top-3 .lb-rank { color: #c8894e; }
.lb-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stats { color: var(--muted); font-size: 0.85rem; text-align: right; }
.lb-stats strong { color: var(--text); }

@media (max-width: 640px) {
  .pwl-acct-name { display: none; }
  .community-grid { grid-template-columns: 1fr; }
}

/* ============================ Game guide ============================ */
.guide { max-width: 760px; margin: 0 auto; }
.guide-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; }
.guide-jump a {
  font-size: 0.82rem; font-weight: 700; color: var(--primary);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; text-decoration: none;
}
.guide-jump a:hover { border-color: var(--primary); background: var(--bg); }
.guide section { margin: 0 0 34px; scroll-margin-top: 80px; }
.guide h2 {
  font-size: 1.5rem; margin: 0 0 12px; letter-spacing: -0.01em;
  border-bottom: 2px solid var(--border); padding-bottom: 8px;
}
.guide h3 { font-size: 1.1rem; margin: 22px 0 8px; }
.guide p { margin: 0 0 14px; line-height: 1.6; }
.guide a:not(.btn) { color: var(--primary); font-weight: 600; }
.guide :not(pre) > code {
  background: #eef0fb; color: #2a2d4a; padding: 2px 6px; border-radius: 5px;
  font-size: 0.9em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.guide kbd {
  display: inline-block; padding: 1px 7px; background: var(--surface);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem; color: var(--text);
}
.guide-code {
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem; line-height: 1.55; overflow-x: auto; white-space: pre;
}
.guide-code .token.keyword, .guide-code .token.class-name,
.docs-ex .token.keyword, .docs-ex .token.class-name,
.docs-sig .token.keyword, .docs-sig .token.class-name       { color: #c792ea; }
.guide-code .token.string, .guide-code .token.attr-value,
.docs-ex .token.string, .docs-ex .token.attr-value,
.docs-sig .token.string, .docs-sig .token.attr-value        { color: #c3e88d; }
.guide-code .token.number, .guide-code .token.boolean,
.docs-ex .token.number, .docs-ex .token.boolean,
.docs-sig .token.number, .docs-sig .token.boolean           { color: #f78c6c; }
.guide-code .token.comment,
.docs-ex .token.comment,
.docs-sig .token.comment                    { color: #8b92b0; font-style: italic; }
.guide-code .token.operator, .guide-code .token.punctuation,
.docs-ex .token.operator, .docs-ex .token.punctuation,
.docs-sig .token.operator, .docs-sig .token.punctuation     { color: #89ddff; }
.guide-code .token.function, .guide-code .token.builtin,
.docs-ex .token.function, .docs-ex .token.builtin,
.docs-sig .token.function, .docs-sig .token.builtin         { color: #82aaff; }

.fn-crumbs { font-size: 0.85rem; font-weight: 700; margin: 0 0 6px; }
.fn-crumbs a { color: var(--primary); text-decoration: none; }
.fn-crumbs a:hover { text-decoration: underline; }
.fn-sig {
  display: block; background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem; overflow-x: auto; white-space: pre;
}
.fn-params { margin: 0 0 18px; display: grid; gap: 10px; }
.fn-params > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.fn-params dt { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; margin: 0 0 4px; }
.fn-params dd { margin: 0; color: var(--muted); line-height: 1.55; }
.fn-related { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.fn-related a {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem; font-weight: 700; color: var(--primary);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; text-decoration: none;
}
.fn-related a:hover { border-color: var(--primary); }
.docs-more { display: inline-block; margin-top: 8px; font-size: 0.85rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.docs-more:hover { text-decoration: underline; }

.callout {
  background: #fff7e8; border-left: 4px solid #ffbe0b;
  padding: 12px 16px; border-radius: var(--radius-sm); margin: 12px 0 18px; font-size: 0.97rem;
}
.callout code { background: #fdeccb; }
.key-points { list-style: none; padding: 0; margin: 8px 0 16px; display: grid; gap: 8px; }
.key-points li {
  background: #f6f8fc; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.95rem;
}

.sprite-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}
.sprite-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.sprite-cell-pic { width: 52px; height: 52px; }
.sprite-cell-pic svg { width: 100%; height: 100%; display: block; }
.sprite-cell-name { font-size: 0.82rem; color: var(--text); }
.sprite-cell-num {
  position: absolute; top: 6px; left: 9px;
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
}

.pwl-share-form textarea.pwl-code-edit {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem; line-height: 1.5;
  background: var(--code-bg); color: var(--code-text);
  border-color: var(--border); min-height: 220px; white-space: pre; tab-size: 4; -moz-tab-size: 4;
}
.cc-edit { margin-left: auto; }

.community-card { overflow: hidden; }
.cc-thumb-wrap {
  position: relative;
  margin: -16px -18px 12px;
  background: #0b1020;
  border-bottom: 1px solid var(--border);
  aspect-ratio: 320 / 180;
  overflow: hidden;
}
.cc-thumb-wrap .cc-featured {
  position: absolute;
  top: 8px;
  left: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.cc-thumb { display: block; width: 100%; height: 100%; }
.cc-arrow { display: inline-flex; }
.cc-arrow svg, .cc-comment-btn svg { display: block; }
.cc-comment-btn { display: inline-flex; align-items: center; gap: 5px; }
.pwl-share-preview-wrap { margin: 8px 0 2px; border-radius: var(--radius-sm); overflow: hidden; background: #0b1020; border: 1px solid var(--border); aspect-ratio: 320 / 180; max-width: 360px; }
.pwl-share-preview { display: block; width: 100%; height: 100%; }
.pwl-share-runfirst {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  margin: 8px 0 4px; padding: 8px 10px;
  background: rgba(255, 212, 59, 0.14);
  border: 1px solid rgba(255, 212, 59, 0.45);
  border-radius: var(--radius-sm);
}
.pwl-share-runfirst span { color: var(--text); font-size: 0.82rem; }
.pwl-share-runfirst .pwl-runfirst-btn { flex: none; white-space: nowrap; padding: 5px 12px; font-size: 0.82rem; }
.pwl-share-runfirst.bypassed { opacity: 0.5; }
.pwl-publish-anyway {
  display: block; margin: 2px 0 4px; padding: 0;
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 0.78rem; text-decoration: underline;
}
.pwl-publish-anyway:hover { color: var(--text); }
.pwl-modal-actions .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cc-title { flex: 1; }
.cc-play { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--primary); font-weight: 700; font-size: 0.82rem; cursor: pointer; }
.cc-play:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.cc-play svg { width: 10px; height: 10px; }

.pwl-player-modal { max-width: 640px; }
.pwl-player { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.pwl-player-bar { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.pwl-player-hint { color: var(--muted); font-size: 0.8rem; }
.pwl-player-run { margin-left: auto; }
.pwl-player-stage { display: flex; justify-content: center; background: #0b1020; border-radius: var(--radius-sm); padding: 10px; overflow: hidden; }
.pwl-player-stage .turtle-stage, .pwl-player-stage .game-stage { margin: 0; max-width: 100%; }

.game-stage[hidden], .turtle-stage[hidden] { display: none; }
.pwl-player-is-python .pwl-player-stage { display: none; }
.pwl-player-is-python .pwl-player-out { max-height: min(62vh, 460px); }
.pwl-player-out {
  max-height: 140px;
  overflow: auto;
  margin: 0;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.pwl-player-out:empty { display: none; }

.pg-view { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.pg-title { margin: 0; font-size: 1.5rem; overflow-wrap: anywhere; }
.pg-desc { margin: 0; overflow-wrap: anywhere; }
.pg-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pg-h { margin: 6px 0 0; font-size: 1.05rem; }
.pg-poster { position: relative; display: inline-block; max-width: 480px; width: 100%; border-radius: var(--radius-sm); overflow: hidden; background: #0b1020; }
.pg-poster-canvas { display: block; width: 100%; height: auto; }
.pg-play-btn { position: absolute; inset: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(11, 16, 32, 0.28); color: #fff; border: 0; font-size: 1.3rem; font-weight: 800; cursor: pointer; }
.pg-play-btn svg { width: 24px; height: 24px; }
.pg-play-btn:hover { background: rgba(79, 70, 229, 0.42); }
.pg-code { max-height: 320px; }
.pg-code-wrap { margin: 2px 0; }
.pg-code-summary { cursor: pointer; font-size: 1.05rem; font-weight: 700; margin: 6px 0; list-style: none; display: inline-flex; align-items: center; gap: 8px; user-select: none; }
.pg-code-summary::-webkit-details-marker { display: none; }
.pg-code-summary::before { content: "\25B6"; font-size: 0.62rem; color: var(--muted); transition: transform 0.15s ease; }
.pg-code-wrap[open] .pg-code-summary::before { transform: rotate(90deg); }
.pg-code-wrap .pg-code { margin-top: 8px; }
.pg-stage { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.pg-stage .pg-play { flex: 1 1 320px; min-width: 0; }
.pg-leaderboard { flex: 0 0 210px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.pg-lb-title { margin: 0 0 8px; font-size: 1rem; }
.pg-lb-body { display: flex; flex-direction: column; gap: 3px; }
.pg-lb-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 7px; font-size: 0.88rem; }
.pg-lb-row.me { background: rgba(79, 70, 229, 0.1); font-weight: 700; }
.pg-lb-rank { width: 18px; text-align: right; color: var(--muted); font-weight: 700; }
.pg-lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-lb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.pg-lb-empty, .pg-lb-signin { color: var(--muted); font-size: 0.82rem; margin: 6px 0 0; }

/* ===== Asset studio ===== */
.asset-studio {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 210px;
  gap: 18px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 820px) { .asset-studio { grid-template-columns: 1fr; } }
.asset-tools { display: flex; flex-direction: column; gap: 12px; }
.asset-tool-row { display: flex; flex-wrap: wrap; gap: 6px; }
.asset-tool {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); cursor: pointer;
}
.asset-tool.is-on { background: var(--primary); color: #fff; border-color: var(--primary); }
.asset-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; max-width: 172px; }
.asset-swatch { width: 100%; aspect-ratio: 1; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.18); cursor: pointer; padding: 0; }
.asset-custom-color { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--muted); }
.asset-custom-color input { width: 42px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.asset-line-width { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--muted); }
.asset-line-width input { flex: 1; min-width: 88px; cursor: pointer; }
.asset-edit-actions .btn { padding: 6px 10px; font-size: 0.82rem; }
.asset-stage-wrap { display: flex; justify-content: center; }
.asset-stage {
  width: 100%; max-width: 360px; aspect-ratio: 1 / 1;
  background-color: #fbfbfe;
  background-image:
    linear-gradient(rgba(79, 70, 229, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 70, 229, 0.09) 1px, transparent 1px);
  background-size: 12.5% 12.5%;
  border: 1px solid var(--border); border-radius: 12px; touch-action: none; cursor: crosshair;
}
.asset-side { display: flex; flex-direction: column; gap: 12px; }
.asset-preview { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: #0b1020; }
.asset-preview-title { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #8aa0d0; margin-bottom: 8px; }
.asset-preview-row { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.asset-name-label { display: flex; flex-direction: column; gap: 4px; font-size: 0.84rem; color: var(--muted); }
.asset-name-label input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.asset-msg { margin: 0; font-size: 0.84rem; overflow-wrap: anywhere; }
.asset-msg.is-ok { color: #1f7a4a; }
.asset-msg.is-err { color: #c0392b; }
.asset-ctx {
  position: fixed; z-index: 1000; min-width: 156px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 30px rgba(15, 18, 38, 0.18); font-size: 0.88rem;
}
.asset-ctx-item {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  background: none; border: 0; border-radius: 5px; cursor: pointer;
  font: inherit; color: var(--text);
}
.asset-ctx-item:hover:not(:disabled) { background: var(--bg); }
.asset-ctx-item:disabled { color: var(--muted); opacity: 0.5; cursor: default; }
.asset-ctx-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.asset-library { margin-top: 26px; }
.asset-library h2 { margin: 18px 0 10px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 12px; }
.asset-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.asset-card[hidden] { display: none; }

.asset-zoom { display: flex; align-items: center; gap: 6px; }
.asset-zoom .btn { padding: 4px 12px; font-size: 1rem; line-height: 1; font-weight: 700; }
.asset-zoom .btn:disabled { opacity: 0.4; cursor: default; }
.asset-zoom-label {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.asset-zoom-label:hover { border-color: var(--primary); color: var(--primary); }
.asset-stage.is-pan { cursor: grab; }
.asset-stage.is-pan:active { cursor: grabbing; }
.asset-card-pic { width: 52px; height: 52px; cursor: pointer; }
.asset-card-id { font-size: 0.72rem; font-weight: 700; color: var(--muted); border: none; background: none; padding: 0; cursor: pointer; }
.asset-card-id:hover { color: var(--primary); text-decoration: underline; }
.asset-card-pic { cursor: pointer; }
.asset-recent-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.asset-recent-label { font-size: 0.76rem; color: var(--muted); }
.asset-recent { display: flex; flex-wrap: wrap; gap: 5px; }
.asset-recent .asset-swatch { width: 22px; height: 22px; aspect-ratio: auto; }
.asset-import-btn { width: 100%; }
.asset-card-name { font-size: 0.8rem; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-card-by { font-size: 0.7rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-card-mod { display: flex; gap: 4px; margin-top: 2px; }
.asset-mod-btn { border: 1px solid var(--danger); color: var(--danger); background: none; border-radius: 999px; font: inherit; font-size: 0.68rem; font-weight: 700; padding: 1px 7px; cursor: pointer; }
.asset-mod-btn:hover { background: var(--danger-bg); }

.asset-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--code-text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.asset-download:hover:not(:disabled) { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.6); color: #fff; }
.asset-download:disabled { opacity: 0.5; cursor: default; }

.asset-card-fit { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; font: inherit; font-size: 0.68rem; font-weight: 700; padding: 1px 8px; cursor: pointer; }
.asset-card-fit:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.asset-card-fit:disabled { opacity: 0.5; cursor: default; }
.asset-card-del { position: absolute; top: 3px; right: 6px; border: none; background: none; color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; }
.asset-card-del:hover { color: #c0392b; }

.asset-frame-info { display: block; margin-top: 8px; font-size: 0.74rem; color: #8aa0d0; font-variant-numeric: tabular-nums; }
.asset-tool-row .btn.is-on { background: var(--primary); color: #fff; border-color: var(--primary); }

.asset-mode {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  width: 100%; max-width: 230px; padding: 4px; margin: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  font: inherit; font-size: 0.86rem; font-weight: 700; cursor: pointer;
}
.asset-mode::before {
  content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px); border-radius: 999px; background: var(--primary);
  transition: transform 0.18s ease;
}
.asset-mode[aria-checked="true"]::before { transform: translateX(100%); }
.asset-mode-opt { position: relative; padding: 6px 10px; text-align: center; color: var(--muted); transition: color 0.18s; }
.asset-mode[aria-checked="false"] .asset-mode-opt:first-child,
.asset-mode[aria-checked="true"] .asset-mode-opt:last-child { color: #fff; }
.asset-mode:hover .asset-mode-opt { color: var(--text); }
.asset-mode[aria-checked="false"]:hover .asset-mode-opt:first-child,
.asset-mode[aria-checked="true"]:hover .asset-mode-opt:last-child { color: #fff; }
.asset-mode:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .asset-mode::before, .asset-mode-opt { transition: none; } }

.asset-studio.is-pixels .asset-shape-only,
.asset-studio:not(.is-pixels) .asset-pixel-only { display: none; }
#asset-breakup[hidden] { display: none; }
.asset-tool:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.asset-grid-size { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--muted); }
.asset-grid-size select {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.asset-stage.is-pixels { background-image: none; }

.sandbox-example-sub {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: 1px;
}

.asset-lib-group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 12px; }
.asset-lib-group > summary { cursor: pointer; padding: 13px 16px; font-weight: 800; font-size: 1.02rem; color: var(--text); list-style: none; display: flex; align-items: center; gap: 10px; }
.asset-lib-group > summary::-webkit-details-marker { display: none; }
.asset-lib-group > summary::before { content: ""; width: 0; height: 0; border-left: 7px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; transition: transform 0.15s ease; flex: none; }
.asset-lib-group[open] > summary::before { transform: rotate(90deg); }
.asset-lib-group > summary:hover { color: var(--primary); }
.asset-lib-count { margin-left: auto; font-size: 0.78rem; font-weight: 700; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 1px 9px; }
.asset-lib-group .asset-grid { padding: 0 16px 16px; }
.asset-lib-group .cc-pager { margin: 0 16px 16px; }

.set-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; margin: 0 0 18px;
  box-shadow: var(--shadow-sm); max-width: 640px;
}
.set-card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.set-card p { margin: 0 0 14px; color: var(--muted); }
.set-note { font-size: 0.88rem; }
.set-card h2.set-sub {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border);
}

.set-seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; flex-wrap: wrap; }
.set-seg-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 0.9rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.set-seg-btn:hover { color: var(--text); }
.set-seg-btn.is-on { background: var(--primary); color: #fff; }
.set-seg-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.set-rows { margin: 0 0 16px; }
.set-row { display: flex; gap: 16px; padding: 9px 0; border-top: 1px solid var(--border); }
.set-row:first-child { border-top: 0; }
.set-row dt { flex: 0 0 130px; color: var(--muted); font-size: 0.9rem; }
.set-row dd { margin: 0; color: var(--text); font-weight: 600; word-break: break-word; }
.set-actions { display: flex; gap: 10px; flex-wrap: wrap; }

