/* Shared theme tokens are loaded by both legacy editors. */
:root {
  --panel: var(--surface);
  --edge: var(--line);
  --accent: var(--clay);
  --accent-hover: #833825;
  --accent-wash: var(--clay-wash);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 290px; }
button, input, select { font: inherit; }
button, select, input[type=range] { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 75px;
  padding: 12px max(28px, calc((100vw - 1536px) / 2));
  background: var(--panel);
  border-bottom: 1px solid var(--edge);
}
.brand, .top-actions, .history { display: flex; align-items: center; }
.brand { gap: 11px; min-width: 0; }
.wordmark {
  font-size: 1rem;
  font-weight: 680;
  letter-spacing: -.025em;
  white-space: nowrap;
}
.top-actions { gap: 15px; flex: none; }
.history { gap: 3px; padding-right: 13px; border-right: 1px solid var(--edge); }
.icon-button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .875rem;
  white-space: nowrap;
}
.icon-button { width: 38px; height: 38px; padding: 0; border: 0; background: transparent; }
.icon-button:disabled { color: #a19e91; }
.icon-button:hover:enabled, .quiet:hover:enabled { background: var(--hover); }
.button { padding: 0 14px; min-height: 42px; border: 1px solid transparent; }
.button svg { width: 17px; height: 17px; }
.primary { color: #fffaf1; background: var(--accent); }
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .72; }
.secondary { border-color: var(--line); background: var(--panel); }
.secondary svg { color: var(--accent); }
.secondary:hover { background: var(--hover); }
.quiet { background: transparent; color: #6b5d52; padding: 0 10px; margin-left: -10px; }
.quiet:disabled { opacity: .45; }
main { max-width: 1592px; margin: 0 auto; padding: 27px 28px 24px; }
.studio { display: grid; grid-template-columns: 274px minmax(0, 1fr); gap: 28px; align-items: start; }
.controls { background: var(--panel); border: 1px solid var(--edge); border-radius: 15px; overflow: hidden; }
.tool-section { padding: 19px 21px 18px; }
.tool-section + .tool-section { border-top: 1px solid var(--edge); }
h2 { margin: 0 0 15px; font: 680 1.18rem/1.2 var(--font-ui); }
.field + .field { margin-top: 14px; }
.field label, #palette-label { font-weight: 700; font-size: .875rem; }
.field-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field output {
  font-size: .775rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.select-wrap { position: relative; margin-top: 5px; }
.select-wrap svg { pointer-events: none; position: absolute; top: 50%; translate: 0 -50%; color: #6d7060; }
.select-wrap .leading { left: 10px; width: 16px; height: 16px; }
.select-wrap .chevron { right: 9px; width: 15px; height: 15px; }
select {
  appearance: none;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 7px 25px 7px 33px;
  color: var(--ink);
  background: var(--surface);
  font-size: .875rem;
  font-weight: 500;
  text-overflow: ellipsis;
}
select:hover { border-color: #bcb8a8; }
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  --progress: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 9px;
  background: linear-gradient(to right, var(--accent) var(--progress), #e8e3d7 var(--progress));
}
input[type=range]::-moz-range-track {
  height: 5px; border-radius: 9px;
  background: linear-gradient(to right, var(--accent) var(--progress), #e8e3d7 var(--progress));
}
input[type=range]::-webkit-slider-thumb {
  appearance: none; margin-top: -5px;
  height: 15px; width: 15px; border: 2px solid var(--panel);
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent);
}
input[type=range]::-moz-range-thumb {
  height: 12px; width: 12px; border: 2px solid var(--panel);
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent);
}
.color-field { margin-top: 17px; }
.palette { display: flex; justify-content: space-between; align-items: center; gap: 5px; padding: 4px 1px 2px; }
.palette button, .custom-color {
  height: 27px; width: 27px; border-radius: 50%; flex: none; padding: 0;
  border: 1px solid #252b2317;
}
.palette button { background: var(--swatch); }
.palette button[aria-pressed=true] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--swatch); }
.custom-color { position: relative; display: grid; place-items: center; border: 1px dashed #a5a092; color: var(--muted); }
.custom-color svg { width: 15px; height: 15px; }
.custom-color input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.custom-color:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.custom-color.active { border-style: solid; color: var(--swatch); }
.clear-row { border-top: 1px solid var(--edge); padding: 9px 21px; }

.workspace { min-width: 0; }
.canvas-heading {
  display: flex; justify-content: space-between; gap: 15px; align-items: end;
  margin: 0 0 15px; padding-top: 1px;
}
h1 { margin: 0; font: 680 clamp(1.6rem,4vw,2.35rem)/1.15 var(--font-ui); letter-spacing: -.033em; }
.canvas-heading p { margin: 7px 0 0; color: var(--muted); }
.canvas-heading button { margin-bottom: 2px; }
.artboard {
  position: relative;
  overflow: hidden;
  height: clamp(480px, calc(100svh - 253px), 810px);
  border: 1px solid #d8ceba;
  border-radius: 14px;
  background: #f4ecd7;
  box-shadow: 0 5px 18px #4d3b2109;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.canvas-footer {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 13px 2px 0; color: var(--muted); font-size: .875rem;
}
.canvas-summary, .guide-control { display: flex; gap: 8px; align-items: center; }
.canvas-summary svg { width: 16px; height: 16px; color: #757a64; }
.summary-divider { width: 3px; height: 3px; border-radius: 50%; background: #898776; }
.guide-control { cursor: pointer; position: relative; font-weight: 600; white-space: nowrap; }
.guide-control input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.guide-control input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch { display: inline-block; padding: 3px; width: 31px; height: 17px; border-radius: 9px; background: #aaa798; }
.switch::after { content: ""; display: block; width: 11px; height: 11px; background: #fffaf0; border-radius: 50%; }
input:checked + .switch { background: #626c53; }
input:checked + .switch::after { translate: 14px; }
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 1;
  background: #2b342a; color: #fffaf0; border-radius: 9px; padding: 10px 16px;
  box-shadow: 0 3px 14px #201b1526; font-size: .875rem;
}
@media (min-width: 1300px) {
  .studio { grid-template-columns: 286px minmax(0, 1fr); }
}
@media (max-width: 980px) {
  main { padding-inline: 20px; }
  .topbar { padding-inline: 20px; }
  .studio { grid-template-columns: 245px minmax(0, 1fr); gap: 20px; }
  .tool-section, .clear-row { padding-inline: 16px; }
  h1 { font-size: 2.6rem; }
}
@media (max-width: 760px) {
  .topbar { min-height: 63px; gap: 8px; padding: 10px 14px; }
  .top-actions { gap: 8px; }
  .history { padding-right: 5px; }
  .icon-button { width: 31px; }
  .wordmark { font-size: 1.72rem; white-space: normal; }
  .brand { gap: 7px; }
  .primary { padding-inline: 9px; }
  main { padding: 18px 14px; }
  .studio { display: flex; flex-direction: column-reverse; align-items: stretch; gap: 19px; }
  [role=tabpanel]:not([hidden]) { display: grid; grid-template-columns: 1fr 1fr; }
  .tool-section + .tool-section { border-top: 0; border-left: 1px solid var(--edge); }
  .artboard { height: clamp(340px, 59svh, 600px); }
}
@media (max-width: 490px) {
  .wordmark { font-size: 1.4rem; }
  .tool-section { padding: 13px 11px; }
  .canvas-heading { align-items: start; gap: 8px; }
  .canvas-heading p { font-size: .94rem; }
  .canvas-heading .button { padding-inline: 8px; min-height: 35px; gap: 5px; }
  h1 { font-size: 2.25rem; }
  .palette { gap: 5px; justify-content: flex-start; flex-wrap: wrap; }
  .palette button, .custom-color { width: 24px; height: 24px; }
  .canvas-footer { align-items: start; }
  .canvas-summary { flex-wrap: wrap; gap: 5px 7px; }
}
@media (max-width: 360px) {
  .wordmark { font-size: 1.2rem; }
  select { padding-left: 7px; }
  .select-wrap .leading { display: none; }
}

.studio-tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  margin: 8px;
  border: 1px solid #e7e0d3;
  border-radius: 10px;
  background: #f0ece2;
}
.studio-tabs button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 3px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-size: .875rem;
  font-weight: 700;
  color: var(--muted);
}
.studio-tabs button[aria-selected=true] {
  color: var(--clay);
  border-color: #e2dace;
  background: var(--panel);
  box-shadow: 0 1px 2px #48372710;
}
.studio-tabs svg, .tool-grid svg { width: 16px; height: 16px; }
[role=tabpanel] > .tool-section:first-child { padding-top: 12px; }
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.tool-grid button {
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 1px;
  border: 1px solid var(--edge);
  border-radius: 7px;
  background: var(--surface);
  font-size: .82rem;
  color: var(--muted);
}
.tool-grid button:hover { background: var(--hover); }
.tool-grid button[aria-pressed=true] { color: var(--clay); border-color: var(--clay-edge); background: var(--accent-wash); font-weight: 700; }
.ink-section .color-field { margin-top: 0; }
.check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}
.check-row[hidden] { display: none; }
.check-row input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); }
.check-row + .field { margin-top: 13px; }
.lab-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.select-wrap.plain select { padding-left: 8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; }
.shuffle { margin: 0; padding-inline: 6px; min-height: 30px; color: var(--clay); gap: 5px; }
.shuffle svg { width: 15px; height: 15px; }
.clear-row { display: flex; align-items: center; justify-content: space-between; }
#help { height: 30px; width: 30px; border: 1px solid var(--edge); border-radius: 50%; color: var(--muted); }
#help span { font-weight: 700; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.menu summary .caret { width: 13px; height: 13px; }
.menu[open] summary .caret { rotate: 180deg; }
.menu-panel {
  position: absolute; top: calc(100% + 7px); right: 0; z-index: 4;
  min-width: 176px; padding: 4px; border: 1px solid var(--edge); border-radius: 9px;
  background: var(--panel); box-shadow: 0 7px 25px #39332420;
}
.menu-panel button {
  display: block; width: 100%; text-align: left; white-space: nowrap;
  min-height: 36px; padding: 6px 10px; border-radius: 5px; border: 0;
  background: none; font-size: .875rem; font-weight: 600;
}
.menu-panel button:hover, .menu-panel button:focus-visible { background: #eee8da; }
.canvas-heading .menu { margin-bottom: 2px; }
.view-tools { display: flex; align-items: center; gap: 1px; margin-left: auto; padding-right: 10px; border-right: 1px solid var(--edge); }
.view-tools .icon-button { width: 29px; height: 29px; }
.view-tools .icon-button svg { height: 15px; width: 15px; }
.zoom-label {
  min-width: 43px; padding: 2px 3px; border: 0; border-radius: 5px; background: transparent;
  font: 600 .83rem/1.5 var(--font-ui); color: var(--muted);
}
.zoom-label:hover { background: var(--hover); }
.canvas-footer { padding-top: 7px; min-height: 38px; }
canvas[data-cursor=hand] { cursor: grab; }
canvas[data-cursor=panning] { cursor: grabbing; }
dialog { width: min(500px, calc(100% - 28px)); border: 1px solid var(--edge); border-radius: 14px; padding: 20px; color: var(--ink); background: var(--panel); }
dialog::backdrop { background: #2b342a56; }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; margin: 16px 0 0; font-size: .875rem; }
.shortcuts dd { margin: 0; text-align: right; }
kbd { font: inherit; background: #eee9df; border: 1px solid #dcd7cb; border-radius: 4px; padding: 1px 4px; white-space: nowrap; }

@media (max-width: 760px) {
  .studio-tabs button { min-height: 39px; }
}
@media (max-width: 490px) {
  .canvas-heading .menu .button { padding-inline: 8px; min-height: 35px; gap: 5px; }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #lab-panel:not([hidden]) { display: block; }
  #lab-panel .tool-section + .tool-section { border-left: 0; border-top: 1px solid var(--edge); }
  .canvas-footer { display: grid; grid-template-columns: 1fr auto; }
  .canvas-summary { grid-column: 1 / -1; }
  .view-tools { margin-left: 0; border: 0; padding: 0; }
  .guide-control { justify-content: flex-end; }
  .shortcuts { grid-template-columns: 1fr; gap: 4px; }
  .shortcuts dd { text-align: left; margin-bottom: 10px; }
}

.space-link { text-decoration: none; color: var(--ink); }
@media (max-width: 550px) {
  .topbar { flex-wrap: wrap; }
  .top-actions { margin-left: auto; }
}
