@font-face {
  font-family: DM;
  src: url("/sans.woff2") format("woff2");
  font-weight: 100 1000;
  font-display: swap;
}
@font-face {
  font-family: Plex;
  src: url("/mono.woff2");
  font-display: swap;
}
:root {
  font-family: DM, "Segoe UI", sans-serif;
  --ink: #242424;
  --muted: #5d5c58;
  --line: #deded9;
  --workbench: #f6f6f3;
  --paper: #fff;
  --inset: #f7f7f4;
  --control-line: #bcbcb6;
  --canvas: #eaeae6;
  --baiff-red: #fd0000;
  --action: #bd1717;
  --action-hover: #9d1010;
  --selected: #fff0ed;
  --focus: #b81d1d;
  accent-color: var(--action);
  color: var(--ink);
  background: var(--workbench);
  font-variant-numeric: tabular-nums;
  --mono: Plex, Consolas, monospace;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
  color: inherit;
}
button {
  border: 0;
  background: none;
}
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.btn:not(.primary):hover:enabled, .icon:hover:enabled, .viewtools button:hover:enabled {
  background: var(--inset);
}
.primary:hover:enabled, #send:hover:enabled {
  background: var(--action-hover);
  border-color: var(--action-hover);
}
button:active:enabled { translate: 0 1px; }

svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
  flex: none;
}
i[data-i] {
  display: inline-flex;
  font-style: normal;
}
.shell {
  width: min(1510px, 100%);
  padding: 0 clamp(20px, 3.6vw, 62px);
  margin: auto;
}
.topbar {
  background: #202020;
  color: #fff;
}
.topinner {
  height: 66px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  color: white;
  text-decoration: none;
  font-size: 23px;
  letter-spacing: -1.2px;
}
.brand-logo {
  width: 86px;
  height: 20px;
  overflow: hidden;
  flex: none;
}
.brand-logo img {
  /* The official PNG includes transparent margins around the wordmark. */
  width: 185px;
  max-width: none;
  display: block;
  transform: translate(-24%, -57%);
}
.brand > span:last-child {
  color: #e4e4df;
  font-weight: 450;
}
nav {
  display: flex;
  align-items: center;
  gap: 4px;
  border-left: 1px solid #414146;
  padding-left: 24px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #bfbfc7;
  padding: 8px 13px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 550;
}
.topbar :focus-visible { outline-color: #fff; }
.nav:hover, .account:hover { background: #323232; color: white; }
.nav.active {
  background: #383838;
  box-shadow: inset 0 -2px var(--baiff-red);
  color: #fff;
}
.nav svg {
  width: 16px;
  height: 16px;
}
.connection {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 12px var(--mono);
  color: #d2cfd8;
  white-space: nowrap;
}
.connection b {
  width: 7px;
  height: 7px;
  background: #c19e74;
  border-radius: 50%;
}
.connection.online b {
  background: #9addaf;
}
.icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
}
.studio {
  --sidebar-width: 280px;
  --bar-height: 58px;
  display: grid;
  grid-template-rows: var(--bar-height) minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
}
.studio .topinner {
  height: 100%;
  gap: 0;
  padding-right: 22px;
}
.studio .brand {
  width: var(--sidebar-width);
  padding-left: 22px;
  flex: none;
}
.studio nav {
  padding-left: 16px;
}
.account {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: 18px;
  padding: 6px 10px;
  border: 1px solid #4a474f;
  border-radius: 6px;
  color: #eeeeea;
  font: 12px var(--mono);
}
.account svg { width: 15px; height: 15px; }
.desktop {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 0;
}
.desktop[hidden] { display: none; }
.command-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
}
.command-head { padding: 20px 20px 14px; }
.command-head .sidehead { margin: 0; }
.command-head h2 { font-size: 16px; }
.command-list {
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 18px;
  scrollbar-width: thin;
}
.command-group { padding: 4px 0; border-top: 1px solid var(--line); }
.command-group summary, .command-group button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border-radius: 6px;
}
.command-group summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 650;
}
.command-group summary::-webkit-details-marker { display: none; }
.command-group summary .trailing { margin-left: auto; }
.command-group summary .trailing svg { width: 12px; }
.command-group[open] .trailing { transform: rotate(90deg); }
.command-group[open] summary > i:first-child { color: var(--action); }
.command-group button { padding: 8px 8px 8px 24px; font-size: 13px; font-weight: 500; }
.command-group svg { width: 16px; height: 16px; }
.command-group button svg, .command-group summary .trailing { color: var(--muted); }
.command-group summary:hover, .command-group button:hover, .command-group button:focus-visible {
  background: var(--inset);
}
.command-group[open] { padding-bottom: 10px; }
.workspace {
  min-width: 0;
  overflow: auto;
  padding: 0 clamp(16px, 2vw, 32px) 24px;
}
.desktop .workspace {
  display: flex;
  flex-direction: column;
  padding-top: 12px;
}
.studio .compact-only { display: none; }
.pagehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 20px 0;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: clamp(28px, 2.3vw, 36px);
  line-height: 1.15;
  letter-spacing: -1.7px;
  font-weight: 700;
}
.pageactions,
.btn {
  display: flex;
  align-items: center;
  gap: 9px;
}
.btn {
  padding: 10px 15px;
  border: 1px solid var(--control-line);
  background: var(--paper);
  border-radius: 7px;
  font-weight: 650;
  font-size: 14px;
  justify-content: center;
}
.primary {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.workgrid {
  display: grid;
  flex: 1 0 auto;
  grid-template-columns: minmax(0, 1fr) clamp(238px, 19vw, 295px);
  gap: 16px;
  align-items: start;
}
.editor {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-width: 0;
}
.inspector {
  display: grid;
  min-width: 0;
  gap: 14px;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.filebar, .file-actions, .document-picker {
  display: flex;
  align-items: center;
}
.filebar { flex: 1; min-width: 0; gap: 12px; padding-inline: 14px; }
.session-document { min-width: 0; }
.session-document h1, .document-picker {
  color: var(--paper);
  font: 600 14px/1.4 DM, sans-serif;
  letter-spacing: 0;
}
.session-document h1, #current-bitmap {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.document-picker {
  gap: 7px;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid #555550;
  border-radius: 6px;
  background: #30302e;
  text-align: left;
}
.document-picker:hover, .document-picker[aria-expanded="true"] { background: #41413f; }
.document-picker svg { width: 15px; height: 15px; }
.document-picker i:last-child svg { width: 12px; transform: rotate(90deg); }
.file-actions { flex: none; gap: 6px; margin-left: auto; }
.file-actions .btn { padding: 7px 10px; font-size: 13px; gap: 5px; }
.file-actions #import { background: transparent; border-color: #666660; color: var(--paper); }
.file-actions #import:hover { background: #383836; }
.session-files {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 0;
  --menu-width: min(340px, calc(100vw - 16px));
  width: var(--menu-width);
  left: clamp(8px, var(--anchor-left), calc(100% - var(--menu-width) - 8px));
  max-height: 65dvh;
  border: 1px solid var(--control-line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 6px 22px #2222;
}
.session-files:popover-open { display: flex; flex-direction: column; }
.session-files h2 { font-size: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
#session-file-list { overflow: auto; overscroll-behavior: contain; padding: 5px; }
.session-file {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 9px;
  border-radius: 5px; text-align: left; color: var(--ink);
}
.session-file > img {
  width: 36px; height: 40px; flex: none; object-fit: contain;
  image-rendering: pixelated; background: var(--inset); border: 1px solid var(--line); border-radius: 3px;
}
.session-file > span { min-width: 0; }
.session-file strong, .session-file small { display: block; overflow-wrap: anywhere; }
.session-file strong { font-size: 14px; line-height: 1.3; }
.session-file small { color: var(--muted); margin-top: 3px; font-size: 12px; }
.session-file > svg { width: 16px; height: 16px; margin-left: auto; color: var(--action); }
.session-file:hover { background: var(--inset); }
.session-file[aria-current="true"] { background: var(--selected); }
.session-file:focus-visible { outline-offset: -2px; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap;
}
.source-link {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--action);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.source-link:hover { color: var(--action-hover); }
.width-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 16px;
  background: var(--selected);
  color: var(--ink);
  font-size: 13px;
}

h2 {
  font-size: 17px;
  font-weight: 680;
  line-height: 1.25;
  letter-spacing: -0.45px;
}
.segment {
  font-family: DM, sans-serif;
  display: flex;
  flex: none;
  border: 1px solid var(--line);
  background: var(--inset);
  padding: 3px;
  gap: 2px;
  border-radius: 7px;
}
.segment button {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 5px;
  color: var(--muted);
}
.segment button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--action);
  box-shadow: 0 1px 3px #0002;
  font-weight: 650;
}
.segment svg {
  width: 13px;
  height: 13px;
}
.segment button:hover:enabled { color: var(--action); }
.stage {
  --ruler-width: 62px;
  --ruler-height: 36px;
  flex: 1 0 265px;
  position: relative;
  overflow: hidden;
  background-color: var(--canvas);
  background-image: radial-gradient(#c8c8c1 0.85px, transparent 0.9px);
  background-size: 12px 12px;
  border-block: 1px solid var(--line);
}
.viewport {
  position: absolute;
  inset: var(--ruler-height) 0 0 var(--ruler-width);
  overflow: auto;
  display: grid;
  align-items: safe center;
  justify-content: safe center;
  padding: 20px 22px 60px;
}
.artboard {
  position: relative;
  background-repeat: repeat-y;
  flex: none;
  image-rendering: pixelated;
  box-shadow:
    0 0 0 1px #29253925,
    0 4px 14px #34304019;
  cursor: crosshair;
}
.opening-guide {
  position: absolute;
  inset-block: 0;
  border-left: 2px dashed var(--action);
  background: var(--paper);
  transform: translateX(-50%);
  box-shadow: 0 0 0 1px #ffffffbd;
  pointer-events: none;
}
.pixel-marker {
  position: absolute;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--action);
  box-shadow: 0 0 0 1px white, inset 0 0 0 1px white;
  pointer-events: none;
}
.ruler-key, .xruler, .yruler {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  background: var(--inset);
  color: var(--ink);
  font: 12px/1.1 var(--mono);
}
.ruler-key {
  inset: 0 auto auto 0; width: var(--ruler-width); height: var(--ruler-height);
  display: grid; align-content: center; padding-left: 7px;
  color: var(--muted); font: 600 11px/1.15 DM, sans-serif;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.xruler { inset: 0 0 auto var(--ruler-width); height: var(--ruler-height); border-bottom: 1px solid var(--control-line); }
.yruler { inset: var(--ruler-height) auto 0 0; width: var(--ruler-width); border-right: 1px solid var(--control-line); }
.xruler span, .yruler span { position: absolute; white-space: nowrap; }
.xruler span { bottom: 0; border-left: 1px solid var(--muted); }
.xruler .major { padding: 0 0 3px 3px; }
.xruler .minor { height: 4px; border-color: var(--control-line); }
.yruler span { right: 0; }
.yruler .major { transform: translateY(-50%); padding-right: 9px; }
.yruler span::after {
  content: ""; position: absolute; right: 0; top: 50%;
  width: 6px; border-top: 1px solid var(--muted);
}
.yruler .minor::after { width: 3px; border-color: var(--control-line); }
.yruler .repeat-start { color: var(--action); font-weight: 650; }
.coordinate-guides {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  font: 600 12px/18px var(--mono); color: white;
}
.coordinate-guides::before, .coordinate-guides::after {
  content: ""; position: absolute; background: var(--action);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 66%);
}
.coordinate-guides::before {
  left: var(--cursor-x); top: calc(var(--ruler-height) - 4px); width: 1px;
  height: max(0px, calc(var(--cursor-y) - var(--ruler-height) + 4px));
}
.coordinate-guides::after {
  top: var(--cursor-y); left: var(--ruler-width); height: 1px;
  width: max(0px, calc(var(--cursor-x) - var(--ruler-width)));
}
.coordinate-guides span {
  position: absolute; background: var(--action); padding: 0 4px; border-radius: 3px;
}
#column-reading {
  top: 1px; left: clamp(var(--ruler-width), var(--cursor-x), calc(100% - 3.5ch));
  transform: translateX(-50%);
}
#rank-reading {
  right: calc(100% - var(--ruler-width) + 4px);
  top: clamp(calc(var(--ruler-height) + 9px), var(--cursor-y), calc(100% - 9px));
  transform: translateY(-50%);
}
.viewtools {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--paper);
  border: 1px solid var(--control-line);
  border-radius: 7px;
  box-shadow: 0 2px 5px #29253216;
  padding: 3px;
}
.viewtools button {
  height: 32px;
  width: 32px;
  border-radius: 4px;
  display: grid;
  place-items: center;
}
.viewtools svg {
  height: 15px;
  width: 15px;
}
.viewtools span {
  font: 12px var(--mono);
  min-width: 42px;
  text-align: center;
}
.viewtools b {
  height: 15px;
  border-right: 1px solid var(--line);
}
.canvasfoot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 7px 17px;
  justify-content: space-between;
  color: var(--muted);
  font: 12px var(--mono);
}
.canvasfoot > span {
  display: flex;
  align-items: center;
  gap: 6px;
}
#opening-legend[hidden] { display: none; }
#opening-legend { color: var(--action); }
#opening-legend.has-guide::before {
  content: "";
  height: 12px;
  border-left: 2px dashed currentColor;
}
.canvasfoot svg {
  width: 12px;
  height: 12px;
}
.fields label[hidden] { display: none; }
.field-swatches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.field-swatches .swatch { width: 20px; height: 20px; border: 1px solid var(--line); }
.auth-shell { display: grid; place-items: center; min-height: 75vh; padding: 20px; }
.auth-card { width: min(100%, 430px); padding: 26px; }
.auth-card h1 { font-size: 26px; margin: 0 0 21px; }
.auth-contact { margin: 22px 0 0; font-size: 14px; line-height: 1.5; }
.auth-card .primary { width: 100%; }
.auth-contact a { color: var(--action); }
.credit-section { margin: 15px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.credit-section summary { cursor: pointer; font-weight: 600; }
.credit-section .fields { margin-top: 12px; }
.credit-list { padding: 0; list-style: none; max-height: 260px; overflow: auto; }
.credit-list li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.credit-list small { display:block; color:var(--muted); overflow-wrap:anywhere; }
.rank-editor, .rank-list { display: grid; gap: 8px; }
.rank-editor > .btn { justify-self: start; }
.rank-block { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)) auto; gap: 5px; align-items: end; }
.block-tools { display: flex; gap: 2px; }
.block-tools .btn { padding: 6px; }
.rank-count { color: var(--muted); font-size: 13px; }
.workflow-note { font: inherit; resize: vertical; width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.workflow-views { display: flex; flex-wrap: wrap; gap: 10px; }
.workflow-views figure { flex: 1; margin: 8px 0 0; min-width: 0; }
.workflow-views figcaption { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.workflow-views img { display: block; max-width: 100%; height: 95px; object-fit: contain; image-rendering: pixelated; }
.background-sheet { background: var(--paper); outline: 1px solid var(--line); }
.workflow-views .background-sheet img { width: 100%; height: 100%; }
.background-sheet img[hidden], .overlay-toggle[hidden] { display: none; }
.overlay-toggle { font: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.overlay-toggle[aria-pressed="true"] { color: var(--action); background: var(--selected); border-color: var(--action); }
.workflow-views .overlay-toggle { margin-top: 8px; }
.seam-strip { overflow-x: auto; border: 1px solid var(--line); }
.seam-strip img { max-width: none; height: auto; min-width: 100%; }
.workflow-actions { flex-wrap: wrap; }
.resultbox { white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .rank-block { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .block-tools { grid-column: 1/-1; }
}
.sidehead {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 17px;
}
.sidehead > svg,
.sidehead > i {
  color: var(--muted);
}
.properties { padding: 17px 16px; }
.properties .sidehead h2 { font-size: 15px; }
.properties .sidehead i { color: var(--muted); }
.bitmap-info { padding-inline: 14px; }
.bitmap-info summary {
  display: flex; align-items: center; gap: 7px; min-height: 43px;
  cursor: pointer; list-style: none;
}
.bitmap-info summary::-webkit-details-marker { display: none; }
.bitmap-info summary strong { font-size: 13px; }
#bitmap-size { margin-left: auto; color: var(--muted); font: 11px var(--mono); }
.bitmap-info summary svg { width: 13px; height: 13px; flex: none; color: var(--muted); }
.bitmap-info[open] summary svg { transform: rotate(90deg); }
.bitmap-info summary:focus-visible { outline-offset: -3px; }
.bitmap-info dl { display: grid; gap: 8px; margin: 0; padding: 10px 0 12px; border-top: 1px solid var(--line); }
.bitmap-info dl > div { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: baseline; font-size: 12px; }
.bitmap-info dt { color: var(--muted); }
.bitmap-info dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.bitmap-info .source-link { margin-bottom: 12px; font-size: 12px; }
#palette { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
#palette .swatch { width: 14px; height: 14px; border-radius: 3px; }
.width-limit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  margin: 14px 0 0;
}
.width-limit label {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--muted);
}
.width-limit input,
.width-limit select {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  background: var(--inset);
  border: 1px solid var(--control-line);
  border-radius: 6px;
  font: 13px var(--mono);
}
.width-limit .btn {
  padding: 5px 10px;
  font-size: 13px;
}
#width-hint[hidden] {
  display: none;
}
.swatch {
  width: 28px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #0002;
}
textarea { width: 100%; resize: vertical; color: var(--ink); }
#open-commands[hidden], #local-library-nav[hidden], #doc-title[hidden], #open-bitmap[hidden] { display: none; }
#chat-limit:empty, .generation-cost:empty { display: none; }
.drawing-machine { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; color: var(--action); font-size: 13px; text-align: left; }
.drawing-machine svg { width: 14px; height: 14px; flex: none; }
#drawing-limit { margin: 6px 0 14px; font-size: 12px; }
#prompt { font: inherit; border: 1px solid var(--control-line); border-radius: 6px; padding: 10px; }
#chatform { min-height: 0; }
#chatform .form-footer .actions { flex-wrap: wrap; }
.agent-connection { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; }
#agent-state { font-size: 13px; color: var(--muted); }
#drawing-history, .creation-motifs { margin-top: 12px; }
#send svg { width: 16px; height: 16px; }
.canvas-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.canvasfoot .export-drawing { font: 550 13px DM, sans-serif; padding: 5px 10px; }
.conversation {
  max-height: 260px;
  overflow: auto;
  overflow-wrap: anywhere;
}
.conversation p {
  white-space: pre-wrap;
  background: var(--inset);
  border-radius: 7px;
  padding: 8px;
  margin: 6px 0;
  font-size: 13px;
}
.conversation .user {
  background: var(--selected);
}
.count {
  padding: 2px 6px;
  background: var(--inset);
  color: var(--muted);
  font: 11px var(--mono);
  border-radius: 5px;
  vertical-align: middle;
  letter-spacing: normal;
}
.textbtn {
  color: var(--action);
  font-weight: 650;
  font-size: 13px;
}
.library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.tile {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  min-width: 0;
}
.tile.chosen {
  border-color: var(--action);
  box-shadow: 0 0 0 1px var(--action);
}
.thumb {
  position: relative;
  width: 100%;
  height: 150px;
  background-color: var(--canvas);
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.thumb b {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--action);
  color: white;
  border: 1px solid white;
  border-radius: 50%;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
}
.thumb svg {
  width: 11px;
  height: 11px;
}
.tiletext {
  padding: 8px 10px;
  width: 100%;
}
.tiletext strong,
.tiletext small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tiletext strong {
  font-size: 13px;
  font-weight: 650;
}
.tiletext small {
  font: 10px var(--mono);
  color: var(--muted);
  margin-top: 3px;
}
dialog {
  width: min(505px, calc(100% - 28px));
  max-height: 86dvh;
  color: var(--ink);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 20px 70px #211c3940;
}
dialog::backdrop {
  background: #1e1a2b55;
  backdrop-filter: blur(2px);
}
.dialoghead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
}
.dialoghead h2 {
  font-size: 20px;
}
#dialogbody {
  padding: 19px 20px;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.fields label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.fields input,
.fields select {
  max-width: 100%;
  width: 100%;
  background: var(--inset);
  color: var(--ink);
  border: 1px solid var(--control-line);
  border-radius: 6px;
  padding: 8px;
}
.fields input[type="color"] {
  padding: 2px;
  height: 38px;
}
.fields .wide {
  grid-column: 1/-1;
}
.point-window {
  max-height: 260px;
  overflow: auto;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.point-sheet { position: relative; margin-inline: auto; cursor: crosshair; }
.point-sheet img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.point-marks { position: absolute; inset: 0; pointer-events: none; }
.point-marks .pixel-marker {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--action); color: white; font: bold 10px/12px var(--mono); text-align: center;
}
.point-area {
  position: absolute; outline: 2px solid var(--action);
  box-shadow: inset 0 0 0 1px white; background: rgb(189 23 23 / 12%);
}
.point-tools { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 6px; }
.point-tools .hint { margin: 0; }
.point-picker { min-width: 0; }
.point-coordinates { margin-top: 8px; font-size: 13px; }
.point-coordinates summary { cursor: pointer; color: var(--muted); }
.point-coordinates .fields { margin-top: 8px; }
.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.rows {
  display: grid;
  gap: 8px;
}
.rowbtn {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}
.rowbtn:hover {
  background: var(--selected);
}
.rowbtn svg {
  color: var(--action);
}
.hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.hint {
  margin-bottom: 14px;
}
.error {
  color: #a03b40;
}
.resultbox {
  padding: 12px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 7px;
  line-height: 1.5;
}
#notice {
  position: fixed;
  inset: auto auto 18px 50%;
  margin: 0;
  max-width: calc(100% - 24px);
  border: 0;
  transform: translateX(-50%);
  z-index: 8;
  background: #302d3d;
  color: white;
  border-radius: 8px;
  padding: 10px 15px;
  font-size: 14px;
  box-shadow: 0 4px 16px #0002;
}
.pending {
  cursor: progress;
}
.pending #send {
  opacity: 0.5;
}
@media (max-width: 1150px) {
  .studio { --sidebar-width: 252px; }
  .workspace { padding-inline: 16px; }
  .workgrid { gap: 12px; }
  .properties { padding: 15px 12px; }
  .segment button { padding-inline: 6px; }
}
@media (max-width: 1050px) {
  .workgrid { grid-template-columns: minmax(0, 1fr); }
  .stage { flex-basis: max(290px, calc(100dvh - var(--bar-height) - 160px)); }
  .inspector { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 760px) {
  .studio { --bar-height: 52px; }
  .desktop { grid-template-columns: minmax(0, 1fr); }
  .studio .topinner { padding-inline: 14px; }
  .studio .brand { width: auto; padding: 0 15px 0 0; }
  .studio nav { padding-left: 8px; }
  .studio .compact-only { display: inline-flex; align-items: center; justify-content: center; }
  .command-head .compact-only { margin-left: auto; }
  .command-sidebar {
    position: fixed;
    inset: var(--bar-height) auto 0 0;
    width: min(300px, calc(100% - 24px));
    max-height: none;
    height: calc(100dvh - var(--bar-height));
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: 4px 0 24px #211c3924;
  }
  .command-sidebar:not(:popover-open) { display: none; }
  .command-sidebar::backdrop { background: #1e1a2b44; }
  .command-head { padding-top: 14px; }
  .pagehead { position: sticky; top: 0; z-index: 2; background: var(--workbench); }
  .nav { justify-content: center; padding: 7px; font-size: 0; gap: 0; }
}
@media (max-width: 580px) {
  .shell { padding-inline: 13px; }
  .brand { font-size: 19px; gap: 4px; }
  .brand-logo { width: 59px; height: 14px; }
  .brand-logo img { width: 127px; }
  .connection span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .account { font-size: 10px; margin-left: 8px; padding: 5px; }
  .workspace { padding-inline: 12px; }
  .pagehead { padding: 13px 0; gap: 10px; flex-wrap: wrap; }
  .pagehead h1 { font-size: 25px; margin-top: 3px; }
  .pageactions { gap: 5px; flex-wrap: wrap; }
  .pageactions .btn { padding: 7px 8px; font-size: 12px; gap: 4px; }
  .canvasfoot { font-size: 11px; padding-inline: 9px; }
  .library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inspector { grid-template-columns: minmax(0, 1fr); }
  .fields { gap: 10px; }
}
@media (max-width: 420px) {
  .account span { display: none; }
  .account { justify-content: center; }
  .studio .brand { padding-right: 8px; }
  .studio .topinner { padding-inline: 9px; }
}

@media (pointer: coarse) {
  .viewport { padding-bottom: 72px; }
  .btn, .icon, .nav, .account, .viewtools button, #send,
  .segment button, .command-group button, .command-group summary, .drawing-machine,
  .fields input, .fields select, .width-limit input, .width-limit select {
    min-height: 44px;
  }
  .icon, .nav, .account, .viewtools button, #send, #download { min-width: 44px; }
}

/* Finestre degli strumenti */
#dialog {
  width: min(548px, calc(100% - 24px));
  max-height: min(90dvh, 840px);
  background: var(--paper);
  overflow: hidden;
}
#dialog[open] { display: flex; flex-direction: column; }
.dialoghead { flex: none; gap: 8px; padding: 12px 16px 12px 20px; }
.dialoghead h2 { flex: 1; margin: 0; font-size: 20px; line-height: 1.25; }
#dialogtitle:focus { outline: none; }
#dialog-back svg { transform: rotate(180deg); }
#dialog [hidden] { display: none; }
#dialogbody { overflow: auto; min-height: 0; overscroll-behavior: contain; }
#dialogbody:has(> .dialog-form) { display: flex; padding: 0; overflow: hidden; }
.dialog-form { width: 100%; min-width: 0; display: flex; flex-direction: column; }
.form-scroll { padding: 16px 20px 20px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.form-scroll > .hint { margin: 0 0 16px; }
.form-footer { flex: none; border-top: 1px solid var(--line); padding: 12px 20px; }
.form-footer .actions { margin: 0; }
#autopilot-activity {
  flex: none;
  max-height: 24dvh;
  overflow-y: auto;
  background: var(--workbench);
}
.autopilot-operation {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}
body > #autopilot-activity:not(:empty) { border-top: 1px solid var(--line); }
body > #autopilot-activity .autopilot-operation { max-width: 28rem; margin-inline: auto; border-bottom: 0; }
.operation-caption { flex: 1; min-width: 0; }
.operation-caption small { display: block; color: var(--muted); font-size: 12px; }
.operation-caption strong { display: block; font-size: 14px; font-weight: 600; }
.operation-time { color: var(--muted); font: 12px/1 var(--mono); }
.knit-sample {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
  border-radius: 6px;
  background: var(--selected);
  color: var(--action);
}
.knit-sample i {
  height: 4px;
  width: 4px;
  background: repeating-linear-gradient(to right, currentColor 0 4px, transparent 4px 6px);
  animation: knit-rank 2.4s ease-in-out infinite;
}
.knit-sample i:nth-child(2), .knit-sample i:nth-child(4) { width: 16px; }
.knit-sample i:nth-child(3) { width: 28px; animation-delay: 240ms; }
.knit-sample i:nth-child(2) { animation-delay: 120ms; }
.knit-sample i:nth-child(4) { animation-delay: 360ms; }
.knit-sample i:nth-child(5) { animation-delay: 480ms; }
@keyframes knit-rank {
  0%, 85%, 100% { opacity: .25; }
  20%, 52% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .knit-sample i { animation: none; }
}
.form-status:not(:empty) { font-size: 13px; line-height: 1.45; margin: 0 0 10px; max-height: 16dvh; overflow: auto; }
.form-status:empty, .generation-cost:empty, .credit-section .error:empty { display: none; }
.form-footer .generation-cost { flex: 1 0 100%; margin: 0 0 2px; text-align: right; }
.form-source {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  margin-bottom: 14px; border-radius: 6px; background: var(--workbench);
}
.form-source > svg { flex: none; width: 18px; height: 18px; color: var(--muted); }
.source-thumb { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; flex: none; }
.form-source > div { min-width: 0; }
.form-source small, .wallet-balance small, .rowbtn small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; }
.form-source strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.source-size { margin-left: auto; font: 11px/1.5 var(--mono); text-align: right; color: var(--muted); }
#dialog .fields, .detected-color { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#dialog .fields label { min-width: 0; color: var(--ink); font-weight: 550; align-self: end; }
#dialog .fields input, #dialog .fields select, #dialog textarea { min-width: 0; min-height: 40px; background: var(--paper); font-weight: 400; }
#dialog .fields .drawing-pass:not([hidden]) { display: flex; flex-direction: row; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
#dialog .drawing-pass input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; margin: 0; accent-color: var(--action); }
.form-options { border-top: 1px solid var(--line); }
.form-options > summary, .credit-section > summary {
  cursor: pointer; font-size: 14px; font-weight: 600; padding: 10px 0;
}
.form-options[open] > summary { margin-bottom: 4px; }
.form-options .fields { padding-bottom: 4px; }
.detected-color, .seed-point { display: grid; align-items: end; gap: 10px; }
.seed-point { grid-template-columns: repeat(2,minmax(0,1fr)) auto; margin-bottom: 8px; }
.field-swatches .swatch { width: 26px; height: 26px; }
.field-swatches .swatch[aria-pressed="true"] { outline: 2px solid var(--focus); outline-offset: 1px; }
.rowbtn { min-height: 52px; }
.rowbtn > span { flex: 1; }
.rowbtn strong { font-size: 14px; }
.rowbtn > svg:last-child { width: 14px; color: var(--muted); }
.profile-new { float: right; margin: 0 0 8px 12px; }
.form-scroll > .fields { clear: both; }
.wallet-balance strong { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.credit-section { padding: 0; margin: 8px 0; }
#dialog button:disabled { opacity: .5; cursor: default; }
@media (max-width: 480px) {
  #dialog .edit-fields { grid-template-columns: 1fr; }
  #dialog { max-height: 94dvh; }
  .dialoghead, .form-scroll, .form-footer { padding-inline: 14px; }
  .form-source { flex-wrap: wrap; gap: 4px 8px; }
  .form-source > div { flex: 1; }
  .source-size { flex-basis: 100%; padding-left: 26px; text-align: left; }
  .form-footer .actions { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .form-footer .generation-cost { grid-column: 1/-1; }
  .form-footer .primary { white-space: normal; line-height: 1.25; }
  .detected-color { grid-template-columns: minmax(0,1fr); }
  .form-footer .btn { min-height: 44px; }
}

@media (min-width: 761px) {
  .studio nav:has(#local-library-nav[hidden]) { display: none; }
}
@media (min-width: 761px) and (max-width: 1150px) {
  .studio .brand { width: auto; padding: 0 16px; }
  .studio nav { padding-left: 8px; }
}
@media (max-width: 920px) {
  .studio .connection span { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .studio .account { margin-left: 8px; }
  .filebar { gap: 6px; padding-inline: 8px; }
  .file-actions .action-tail { display: none; }
}
@media (max-width: 760px) {
  .studio { --bar-height: 94px; }
  .studio .topinner {
    display: grid; grid-template-columns: auto 1fr auto auto; grid-template-rows: 44px 1fr;
    padding-inline: 12px;
  }
  .studio .brand { grid-area: 1/1; }
  .studio nav { grid-area: 1/2; }
  #open-commands { font-size: 12px; gap: 4px; }
  .studio .connection { grid-area: 1/3; }
  .studio .account { grid-area: 1/4; }
  .filebar { grid-area: 2/1/3/-1; padding: 2px 0 4px; border-top: 1px solid #42423e; }
  .file-actions .btn { padding-inline: 8px; }
  .document-picker { min-height: 36px; }
  .stage { --ruler-width: 53px; }
}
@media (max-width: 359px) {
  .studio nav:has(#local-library-nav:not([hidden])) #open-commands { font-size: 0; gap: 0; }
}

.layer-panel .sidehead { margin-bottom: 4px; }
#layer-help { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
#layer-count { margin-left: auto; color: var(--muted); font: 11px var(--mono); }
#layer-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.layer-row {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  position: relative;
}
.layer-row.selected { border-color: var(--action); background: var(--selected); box-shadow: inset 2px 0 var(--action); }
.layer-row.selected .layer-pick { color: var(--action); font-weight: 650; }
.layer-row.invisible .layer-pick img { opacity: .45; }
.layer-grip { display: grid; place-items: center; color: var(--control-line); width: 16px; flex: none; }
.layer-grip svg { width: 14px; stroke-width: 3; }
.layer-row.movable .layer-grip, .layer-row.movable .layer-pick { cursor: grab; touch-action: none; user-select: none; }
.layer-row.dragging { opacity: .6; cursor: grabbing; }
.layer-row.drop-above::before, .layer-row.drop-below::after {
  content: ""; position: absolute; inset-inline: 0; height: 2px; background: var(--action); pointer-events: none;
}
.layer-row.drop-above::before { top: -4px; }
.layer-row.drop-below::after { bottom: -4px; }
.layer-pick { display: flex; gap: 6px; align-items: center; min-width: 0; flex: 1; padding: 3px 2px; text-align: left; font-size: 12px; }
.layer-pick input {
  appearance: none; display: grid; place-content: center; flex: none; width: 16px; height: 16px; margin: 0;
  border: 1px solid var(--control-line); border-radius: 3px; background: var(--paper); cursor: pointer;
}
.layer-pick input:checked { background: var(--action); border-color: var(--action); }
.layer-pick input:checked::before {
  content: ""; width: 8px; height: 4px; border: solid white; border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg);
}
@media (forced-colors: active) { .layer-pick input { appearance: auto; } .layer-pick input::before { display: none; } }
.layer-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-pick img {
  width: 32px; height: 32px; flex: none; object-fit: contain; image-rendering: pixelated;
  border: 1px solid var(--control-line); border-radius: 3px; background: var(--paper);
}
.layer-pick img + span + img { width: 20px; height: 20px; margin-left: auto; }
.layer-tool { display: grid; place-items: center; width: 30px; min-height: 30px; padding: 0; border-radius: 4px; color: var(--muted); }
.layer-tool svg { width: 15px; height: 15px; }
.layer-tool:hover:enabled { background: var(--inset); color: var(--ink); }
#layer-changes:not([hidden]) { display: block; margin-top: 6px; font-size: 11px; }
.layer-tools { display: flex; align-items: stretch; gap: 6px; margin-top: 10px; }
.layer-add { flex: 1; padding: 7px; font-size: 13px; }
#layer-remove { width: 34px; }
@media (min-width: 1051px) {
  .inspector { max-height: calc(100dvh - var(--bar-height) - 36px); overflow-y: auto; grid-auto-rows: max-content; scrollbar-width: thin; }
}
@media (min-width: 581px) and (max-width: 1050px) {
  .layer-panel { grid-column: 1; grid-row: 1 / span 2; }
  .bitmap-info { grid-column: 2; }
}
@media (pointer: coarse) {
  .layer-tool { flex: 0 1 44px; height: 44px; }
  #layer-remove { width: 44px; }
}
