/* ---------- BASE ---------- */
* { box-sizing: border-box; margin: 0; }

:root {
  --ink: #1e2430;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
}

body {
  min-height: 100vh;
  background: #f6f7fb;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top { max-width: 1200px; margin: 0 auto; padding: 28px 16px 8px; }
.top h1 { font-size: clamp(24px, 4vw, 34px); letter-spacing: -.5px; }
.top p { color: var(--muted); margin-top: 6px; }

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 260px;
  grid-template-areas: "controls preview item" "controls code item";
  gap: 16px;
  align-items: start;
}
.controls { grid-area: controls; }
.preview { grid-area: preview; }
.item-panel { grid-area: item; }
.code { grid-area: code; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.panel h2 { font: 700 16px ui-monospace, Consolas, monospace; margin-bottom: 12px; color: var(--accent); }
/* ---------- END BASE ---------- */

/* ---------- BUTTON GROUPS ---------- */
.group { margin-bottom: 14px; }
.group-name { display: block; font: 600 13px ui-monospace, Consolas, monospace; margin-bottom: 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 5px; }
.opt {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: inherit;
  font: 12px ui-monospace, Consolas, monospace;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.opt:hover { border-color: #a5b4fc; }
.opt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt:focus-visible, .tool:focus-visible, .copy:focus-visible, .item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.ctl { display: block; font: 600 13px ui-monospace, Consolas, monospace; }
.ctl > span { display: flex; margin-bottom: 6px; }
.ctl output { margin-left: auto; color: var(--accent); }
.ctl input { width: 100%; accent-color: var(--accent); }
/* ---------- END BUTTON GROUPS ---------- */

/* ---------- PREVIEW ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.tool {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: 600 13px system-ui, sans-serif;
  cursor: pointer;
}
.tool:hover { background: #f2f4f7; }
.axis-note { margin-left: auto; font-size: 12px; color: var(--muted); }

.container {
  min-height: 320px;
  padding: 12px;
  border: 2px dashed #a5b4fc;
  border-radius: 12px;
  background: repeating-linear-gradient(45deg, #fafbff 0 10px, #f3f4fd 10px 20px);
  /* display: flex and the rest are set by script.js */
}
.item {
  min-width: 56px;
  padding: 14px 16px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font: 800 18px system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(30, 36, 48, .15);
  transition: transform .2s, box-shadow .2s;
}
.item:hover { transform: translateY(-2px); }
/* some items are taller, so align-items has something to show */
.item:nth-child(3n + 2) { padding-top: 26px; padding-bottom: 26px; }
.item:nth-child(4n + 3) { font-size: 26px; }
.item.selected { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--ink); }
/* ---------- END PREVIEW ---------- */

/* ---------- CODE ---------- */
.code-head { display: flex; justify-content: space-between; align-items: center; }
.code-head h2 { margin: 0; }
.copy {
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: 600 13px system-ui, sans-serif;
  cursor: pointer;
}
.code pre {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #111827;
  color: #e5e7eb;
  font: 13.5px/1.6 ui-monospace, Consolas, monospace;
  overflow-x: auto;
}
.css .sel { color: #f9a8d4; }
.css .k { color: #93c5fd; }
.css .v { color: #fcd34d; }
/* ---------- END CODE ---------- */

/* ---------- SMALL SCREENS ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "preview" "item" "controls" "code"; }
  .container { min-height: 260px; }
}
@media (prefers-reduced-motion: reduce) {
  .item, .opt { transition: none; }
}
/* ---------- END SMALL SCREENS ---------- */
