/* ============================================================
   CSS Playground — self-contained, no external dependencies.
   Light default + dark via prefers-color-scheme, overridable by
   the data-theme toggle. Brand: indigo (matches the site).
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --ink: #1a1c25;
  --muted: #475063;          /* >= 7:1 on surface */
  --faint: #5b6472;
  --line: #e4e6ef;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: rgba(79, 70, 229, 0.10);
  --shadow: 0 1px 2px rgba(20,24,40,.05), 0 10px 28px -14px rgba(20,24,40,.18);
  --mono: 'SF Mono','JetBrains Mono',ui-monospace,Menlo,Consolas,monospace;
  --sans: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,system-ui,sans-serif;
  --checker: #eceef4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0b0d13;
    --surface: #141822;
    --surface-2: #1a1f2b;
    --ink: #e8eaf2;
    --muted: #b7bccd;
    --faint: #99a1b3;
    --line: #262a38;
    --accent: #8d89f6;
    --accent-ink: #0b0d13;
    --accent-soft: rgba(141, 137, 246, 0.14);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 14px 32px -16px rgba(0,0,0,.6);
    --checker: #1e2431;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d13;
  --surface: #141822;
  --surface-2: #1a1f2b;
  --ink: #e8eaf2;
  --muted: #b7bccd;
  --faint: #99a1b3;
  --line: #262a38;
  --accent: #8d89f6;
  --accent-ink: #0b0d13;
  --accent-soft: rgba(141, 137, 246, 0.14);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 14px 32px -16px rgba(0,0,0,.6);
  --checker: #1e2431;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; max-width: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- App shell (fills first viewport) ---------- */
.pg-app { display: flex; flex-direction: column; height: 100vh; min-height: 520px; }

.pg-header {
  display: flex; align-items: center; gap: 16px;
  padding: 0 18px; height: 56px; flex: 0 0 auto;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.pg-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.pg-logo { color: var(--accent); display: inline-flex; }
.pg-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.pg-tabs { display: flex; gap: 4px; flex: 1 1 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.pg-tabs::-webkit-scrollbar { display: none; }
.pg-tab {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.pg-tab:hover { background: var(--surface-2); color: var(--ink); }
.pg-tab.active { background: var(--accent-soft); color: var(--accent); }
.pg-header-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.pg-controls { min-width: 0; }
.pg-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s;
}
.pg-icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .icon-sun { display: none; } :root:not([data-theme="light"]) .icon-moon { display: inline; } }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
:root[data-theme="light"] .icon-sun { display: inline; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ---------- Main split ---------- */
.pg-main { flex: 1 1 auto; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.pg-controls {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px; overflow-y: auto; overscroll-behavior: contain;
}
.pg-output { display: grid; grid-template-rows: 1fr auto; min-height: 0; min-width: 0; }
.pg-preview-wrap { display: flex; flex-direction: column; min-height: 0; }
.pg-panel-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--faint);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.pg-hint { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }
.pg-preview {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  background-color: var(--surface-2);
  background-image:
    linear-gradient(45deg, var(--checker) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.pg-code-wrap { border-top: 1px solid var(--line); background: var(--surface); max-height: 40%; display: flex; flex-direction: column; }
.pg-code {
  margin: 0; padding: 14px 16px; overflow: auto; overscroll-behavior: contain;
  font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--ink);
  white-space: pre; tab-size: 2;
}
.pg-copy-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); font-family: inherit; font-size: 12px;
  font-weight: 600; padding: 4px 10px; border-radius: 7px; cursor: pointer; text-transform: none;
  letter-spacing: 0; transition: background .15s, color .15s;
}
.pg-copy-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- Controls ---------- */
.ctrl-group { margin-bottom: 20px; }
.ctrl-group > .ctrl-group-title {
  font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 12px;
}
.ctrl { margin-bottom: 15px; }
.ctrl label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--ink); }
.ctrl label .val { font-family: var(--mono); font-weight: 500; color: var(--accent); font-size: 12px; }
.ctrl input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; height: 22px; }
.ctrl select, .ctrl input[type="text"], .ctrl textarea {
  width: 100%; font-family: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  color: var(--ink);
}
.ctrl textarea { font-family: var(--mono); resize: vertical; min-height: 180px; line-height: 1.5; white-space: pre; }
.ctrl input[type="color"] { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); cursor: pointer; vertical-align: middle; }
.ctrl-color-row { display: flex; align-items: center; gap: 10px; }
.ctrl-color-row .hex { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; min-width: 0; appearance: none; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); font-family: inherit; font-size: 12px;
  font-weight: 600; padding: 7px 8px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.seg button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ctrl-check { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; cursor: pointer; }
.ctrl-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.ctrl-note { font-size: 12px; color: var(--faint); line-height: 1.5; margin-top: 4px; }

/* preview demo elements — match the generated .item CSS so the preview
   is exactly what the copied HTML+CSS produce. */
.demo-flex-item {
  flex: 0 0 auto; padding: 18px 22px; background: #6366f1; color: #fff;
  border-radius: 8px; font: 600 15px var(--sans);
  display: flex; align-items: center; justify-content: center;
}
.demo-grid-item {
  padding: 20px; background: #6366f1; color: #fff; border-radius: 8px;
  font: 600 15px var(--sans); display: flex; align-items: center; justify-content: center;
}
.demo-box { background: var(--accent); }
/* the .container demo box: bounded, labelled, clips overflow so `nowrap` is visible */
.demo-flex-box, .demo-grid-box {
  background: var(--surface);
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 10px; padding: 30px 14px 14px; position: relative; overflow: hidden;
}
.demo-flex-box::before, .demo-grid-box::before {
  content: attr(data-label); position: absolute; top: 9px; left: 13px;
  font: 600 10.5px var(--mono); letter-spacing: .04em; color: var(--faint);
}

/* generated-code tabs */
.pg-code-head { padding: 6px 10px 6px 14px; }
.pg-codetabs { display: flex; gap: 4px; }
.pg-codetab {
  appearance: none; border: 0; background: transparent; color: var(--faint);
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.pg-codetab:hover:not(.active) { color: var(--ink); }
.pg-codetab.active { background: var(--accent-soft); color: var(--accent); }
.pg-code[hidden] { display: none; }

/* ---------- Toast ---------- */
.pg-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; box-shadow: var(--shadow);
}
.pg-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .pg-app { height: auto; min-height: 0; }
  .pg-main { grid-template-columns: 1fr; }
  .pg-controls { border-right: none; border-bottom: 1px solid var(--line); max-height: none; }
  .pg-output { grid-template-rows: none; }
  .pg-preview { min-height: 260px; }
  .pg-code-wrap { max-height: none; }
  .pg-title { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ============================================================
   About / SEO content section — self-contained WCAG-AA palette
   (independent of the app theme so contrast is always guaranteed)
   ============================================================ */
.tool-about {
  --ab-bg: #ffffff; --ab-surface: #f6f7fb; --ab-text: #1a1c25;
  --ab-muted: #475063; --ab-faint: #5b6472; --ab-border: #e4e6ef;
  --ab-accent: #4f46e5;
  background: var(--ab-bg); color: var(--ab-text);
  border-top: 1px solid var(--ab-border); padding: 64px 24px 80px; font-size: 15px;
}
:root[data-theme="dark"] .tool-about {
  --ab-bg: #0f131a; --ab-surface: #1a1f2b; --ab-text: #e8eaf2;
  --ab-muted: #b7bccd; --ab-faint: #99a1b3; --ab-border: #262a38; --ab-accent: #8d89f6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .tool-about { --ab-bg: #0f131a; --ab-surface: #1a1f2b; --ab-text: #e8eaf2;
    --ab-muted: #b7bccd; --ab-faint: #99a1b3; --ab-border: #262a38; --ab-accent: #8d89f6; }
}
.tool-about-inner { max-width: 860px; margin: 0 auto; line-height: 1.65; }
.tool-about h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; color: var(--ab-text); }
.tool-about code { font-family: var(--mono); font-size: 0.88em; background: var(--ab-surface); padding: 1px 6px; border-radius: 5px; color: var(--ab-text); }
.about-lede { font-size: 1.05rem; color: var(--ab-muted); margin-top: 14px; max-width: 68ch; }
.about-cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.about-btn { display: inline-flex; align-items: center; padding: 10px 18px; border-radius: 10px; background: var(--ab-accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 0.95rem; transition: transform .15s ease, box-shadow .15s ease; }
.about-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px -6px var(--ab-accent); }
.about-btn.ghost { background: transparent; color: var(--ab-accent); border: 1px solid var(--ab-border); }
.about-btn:focus-visible, .about-links a:focus-visible, .about-faq summary:focus-visible { outline: 2px solid var(--ab-accent); outline-offset: 2px; border-radius: 6px; }
.about-highlight { margin: 40px 0; padding: 22px 24px; background: var(--ab-surface); border: 1px solid var(--ab-border); border-left: 4px solid var(--ab-accent); border-radius: 12px; }
.about-highlight h2 { font-size: 1.15rem; margin: 0 0 8px; color: var(--ab-text); }
.about-highlight p { color: var(--ab-muted); margin: 0; }
.about-h2 { font-size: 1.3rem; font-weight: 700; margin: 40px 0 16px; color: var(--ab-text); }
.about-features { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2,1fr); gap: 12px 28px; }
.about-features li { position: relative; padding-left: 26px; color: var(--ab-muted); font-size: 0.95rem; }
.about-features li::before { content: "\2713"; position: absolute; left: 0; top: 0; color: #15803d; font-weight: 700; }
:root[data-theme="dark"] .about-features li::before { color: #35c08a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .about-features li::before { color: #35c08a; } }
.about-features strong { color: var(--ab-text); }
.about-faq { display: flex; flex-direction: column; gap: 10px; }
.about-faq details { border: 1px solid var(--ab-border); border-radius: 10px; background: var(--ab-surface); overflow: hidden; }
.about-faq summary { cursor: pointer; padding: 14px 18px; font-weight: 600; color: var(--ab-text); list-style: none; position: relative; }
.about-faq summary::-webkit-details-marker { display: none; }
.about-faq summary::after { content: "+"; position: absolute; right: 18px; color: var(--ab-accent); font-weight: 700; }
.about-faq details[open] summary::after { content: "\2013"; }
.about-faq details p { padding: 0 18px 16px; margin: 0; color: var(--ab-muted); }
.about-links ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.about-links li { color: var(--ab-muted); }
.about-links a { color: var(--ab-accent); font-weight: 600; text-decoration: none; }
.about-links a:hover { text-decoration: underline; }
.about-foot { margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--ab-border); font-size: 0.9rem; color: var(--ab-faint); }
.about-foot a { color: var(--ab-accent); text-decoration: none; }
@media (max-width: 640px) { .about-features { grid-template-columns: 1fr; } .tool-about { padding: 48px 18px 64px; } }
