:root {
  color-scheme: dark;
  --bg: #101112;
  --panel: rgba(32, 33, 35, 0.92);
  --panel-strong: rgba(18, 18, 20, 0.82);
  --border: rgba(255, 255, 255, 0.12);
  --text: #fbf7f1;
  --muted: #c7beb7;
  --accent: #ff5a52;
  --canvas: #fbfaf7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 80, 70, 0.2), transparent 34rem),
    linear-gradient(145deg, #161719 0%, #101112 54%, #0c0d0e 100%);
  touch-action: manipulation;
}

button,
input { font: inherit; }
button {
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 0.78rem 1.05rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 780;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}
button:not(:disabled):hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.14); }
button:disabled { cursor: not-allowed; opacity: 0.38; }
button:focus-visible,
input:focus-visible,
a:focus-visible { outline: 3px solid rgba(255, 90, 82, 0.7); outline-offset: 3px; }

.playground-chrome {
  color: rgba(255, 255, 255, 0.72);
}
.playground-chrome a { color: #fff; }

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 16px 0 max(48px, env(safe-area-inset-bottom));
}

.hero,
.workspace {
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(42, 41, 43, 0.96), rgba(31, 32, 34, 0.92));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255,255,255,.04);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: clamp(20px, 4vw, 32px);
}

.brand {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.28em;
}

h1,
h2,
p { margin: 0; }
h1 {
  max-width: 11ch;
  font-size: clamp(2.9rem, 7vw, 4rem);
  line-height: 0.9;
  letter-spacing: -0.07em;
}
.dek {
  margin-top: 14px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.08rem);
}
.toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  padding: 18px;
}
.settings {
  align-self: start;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  background: rgba(12, 12, 14, 0.58);
}
.settings h2 { margin-bottom: 16px; font-size: 1.45rem; letter-spacing: -0.045em; }
.settings p { color: var(--muted); line-height: 1.15; }
.settings label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  font-weight: 820;
}
.settings input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 0.95rem 1rem;
  color: var(--text);
  background: rgba(255,255,255,.08);
  font-weight: 850;
}
.matrix-readout {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  border-radius: 16px;
  padding: 16px;
  color: var(--muted);
  background: rgba(255,255,255,.08);
}
.matrix-readout strong { color: var(--text); font-size: 1.1rem; }

.canvases { display: grid; gap: 18px; }
.canvas-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  background: rgba(20, 21, 23, 0.72);
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-title h2 { font-size: 0.98rem; color: #ded6cf; }
.section-title span { color: var(--accent); font-size: 0.96rem; font-weight: 850; }
.canvas-stage {
  display: grid;
  place-items: center;
  min-height: min(46svh, 520px);
  border-radius: 20px;
  background: rgba(255,255,255,.025);
}
.canvas-svg {
  width: min(100%, 580px);
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: visible;
  touch-action: none;
  user-select: none;
}
#edit-canvas { cursor: crosshair; }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 18px, 560px); padding-top: 10px; }
  .hero { align-items: flex-start; flex-direction: column; border-radius: 22px; }
  h1 { font-size: clamp(2.55rem, 15vw, 4.15rem); }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .toolbar button { padding-inline: 0.7rem; }
  .workspace { grid-template-columns: 1fr; border-radius: 22px; padding: 12px; }
  .settings { position: static; }
  .canvas-card { padding: 12px; }
  .canvas-stage { min-height: auto; padding: 0; }
  .canvas-svg { width: 100%; }
}

@media (max-width: 420px) {
  .toolbar { grid-template-columns: 1fr; }
  .section-title { align-items: flex-start; flex-direction: column; }
}
