/* Spekkit — one canvas, one inspector. Soft, tactile surfaces:
   raised (buttons, cards) and inset (fields, tracks) on a quiet grey ground. */
/* one accent for the whole interface: selection, focus, slider fills */
:root { --accent: #3fa0b4; --accent-ink: #ffffff; }

body {
  --bg: #ececee;
  --surface: #f8f8f9;
  --cell: #ececef;
  --cell-hover: #e4e4e8;
  --cell-fill: #d3d3da;
  --tick: #8d8d97;
  --rule: rgba(20, 20, 30, .07);
  --ink: #141418;
  --ink-2: #4b4b54;
  --ink-3: #6b6b75;
  --label: #4b4b54;
  --r-lg: 28px;
  --r: 16px;
  --r-sm: 12px;
  --ease: cubic-bezier(.23, 1, .32, 1);
  --dur-fast: 120ms; --dur-base: 180ms; --dur-slow: 260ms;

  /* raised = lit from above; inset = pressed into the ground */
  --raise-bg: linear-gradient(#ffffff, #f3f3f5);
  --raise: 0 1px 0 #fff inset, 0 1px 2px rgba(20, 20, 30, .07), 0 5px 12px -6px rgba(20, 20, 30, .16), 0 0 0 1px rgba(20, 20, 30, .05);
  --raise-hover: 0 1px 0 #fff inset, 0 2px 4px rgba(20, 20, 30, .08), 0 8px 16px -6px rgba(20, 20, 30, .2), 0 0 0 1px rgba(20, 20, 30, .06);
  --inset: inset 0 1px 2px rgba(20, 20, 30, .08), inset 0 0 0 1px rgba(20, 20, 30, .035);
  --dark-bg: linear-gradient(#383840, #17171b);
  --dark: 0 1px 0 rgba(255, 255, 255, .22) inset, 0 -1px 0 rgba(0, 0, 0, .4) inset, 0 6px 14px -5px rgba(20, 20, 30, .5), 0 0 0 1px rgba(0, 0, 0, .55);
  --shadow-sm: var(--raise);
  --shadow-pop: 0 1px 0 #fff inset, 0 24px 60px -20px rgba(20, 20, 30, .38), 0 6px 18px -8px rgba(20, 20, 30, .16), 0 0 0 1px rgba(20, 20, 30, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 450 15px/1.45 ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: -.011em;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

::selection { background: var(--accent); color: var(--accent-ink); }
* { scrollbar-width: thin; scrollbar-color: #d2d2d9 transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: #d2d2d9; border-radius: 99px; border: 3px solid var(--surface); }
*::-webkit-scrollbar-thumb:hover { background: #c0c0c9; }
*::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 14px; top: -48px; z-index: 40;
  background: var(--dark-bg); color: #fff; padding: 9px 15px; border-radius: 14px;
  text-decoration: none; font-weight: 600; font-size: 14px; transition: top var(--dur-base) var(--ease);
}
.skip:focus { top: 12px; }

/* ---------- top bar ---------- */
.topbar {
  flex: 0 0 auto; position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 18px; height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark { flex: none; width: 34px; height: 34px; display: none; }
.logotype { display: block; height: 40px; width: auto; margin-left: -10px; }
.brand h1 { margin: 0; display: flex; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.histgroup { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 18px; border: 0; border-radius: 15px;
  background: var(--raise-bg); box-shadow: var(--raise); color: var(--ink);
  font: inherit; font-size: 14.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.btn:hover { box-shadow: var(--raise-hover); }
.btn-primary { background: var(--dark-bg); color: #fff; box-shadow: var(--dark); }
.btn-primary:hover { box-shadow: var(--dark), 0 8px 18px -6px rgba(20, 20, 30, .5); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-wide { width: 100%; }

.iconbtn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 15px; background: var(--raise-bg); box-shadow: var(--raise);
  color: var(--ink); cursor: pointer;
}
.iconbtn:hover { box-shadow: var(--raise-hover); }
.iconbtn[disabled] { opacity: .35; cursor: default; box-shadow: none; background: none; }
.iconbtn-soft { background: var(--raise-bg); }
.iconbtn-sm { width: 30px; height: 30px; border-radius: 11px; box-shadow: none; background: none; color: var(--ink-2); }
.iconbtn-sm:hover { background: var(--cell); box-shadow: none; }

.chip {
  height: 34px; display: inline-flex; align-items: center; justify-content: center;
  min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  padding: 0 13px; border: 0; border-radius: 12px;
  background: var(--raise-bg); box-shadow: var(--raise); color: var(--ink);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover { box-shadow: var(--raise-hover); }
.chip-quiet { background: none; box-shadow: none; color: var(--ink-2); }
.chip-quiet:hover { background: var(--cell); box-shadow: none; color: var(--ink); }
.chip-solid { background: var(--dark-bg); color: #fff; box-shadow: var(--dark); }
.chip-solid:hover { box-shadow: var(--dark); filter: brightness(1.15); }
.chip-wide { width: 100%; height: 40px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip-row .chip { flex: 1 1 auto; min-width: 0; }

.seg { display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: 17px; background: var(--cell); box-shadow: var(--inset); }
.seg-btn {
  height: 32px; padding: 0 14px; border: 0; border-radius: 13px;
  background: none; color: var(--ink-3);
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on { background: var(--raise-bg); color: var(--ink); box-shadow: var(--raise); }

/* ---------- popovers: a floating menu ---------- */
.popwrap { position: relative; }
.pop {
  position: fixed; z-index: 50; overflow: auto;
  width: 292px; max-width: calc(100vw - 24px); padding: 8px;
  background: linear-gradient(#fdfdfd, #f7f7f8); border-radius: 28px; box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 4px;
  transform-origin: top right; animation: pop var(--dur-base) var(--ease);
}
.pop-wide { width: 316px; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-6px); } }
.pop-title {
  margin: 0; padding: 12px 14px 10px; font-size: 15px; font-weight: 650; letter-spacing: -.015em; color: var(--ink);
  border-radius: 20px; box-shadow: 0 0 0 1px var(--rule); margin-bottom: 4px;
}
.pop-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 12px 14px; border: 0; border-radius: 17px;
  background: none; color: var(--ink); font: inherit; font-size: 15px; font-weight: 500;
  cursor: pointer; text-align: left;
}
.pop-row:hover { background: #efeff1; }
.pop-note {
  color: var(--ink-3); font-size: 12px; font-weight: 500;
}
.pop-opts { display: flex; flex-direction: column; gap: 2px; }
.opt {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 17px; background: none;
  font-size: 14.5px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.opt:hover { background: #efeff1; }
.opt input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.opt .switch { order: 2; margin-left: auto; }
.opt > span:last-child:not(.switch) { order: 0; }
.chip-select {
  appearance: none; height: 34px; padding: 0 30px 0 13px;
  border: 0; border-radius: 12px; background-color: var(--cell); box-shadow: var(--inset);
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.8 4.6 6 7.8l3.2-3.2' fill='none' stroke='%234b4b54' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
}
.pop .btn-wide { margin-top: 4px; height: 46px; border-radius: 18px; }

/* ---------- layout: two floating panels on the ground ---------- */
.shell {
  --side-w: 400px;
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 24px var(--side-w);
  grid-template-rows: minmax(0, 100%); gap: 0; padding: 0 12px 12px;
  transition: grid-template-columns var(--dur-slow) var(--ease);
}
.shell.is-resizing { transition: none; cursor: col-resize; user-select: none; -webkit-user-select: none; }
.shell.is-collapsed { grid-template-columns: minmax(0, 1fr) 24px 0px; }

/* ---------- canvas ---------- */
.stage {
  position: relative; min-height: 0; overflow: hidden; border-radius: 30px;
  background:
    radial-gradient(circle at center, #c4c4cc 1.1px, transparent 1.2px) 0 0 / 26px 26px,
    linear-gradient(#f3f3f5, #ededf0);
  box-shadow: var(--inset), 0 0 0 1px rgba(20, 20, 30, .03);
  touch-action: none; outline: none;
}
.stage.over-item { cursor: grab; }
.stage.over-pan { cursor: grab; }
.stage.dragging { cursor: grabbing; }
.stage::after {
  content: ""; position: absolute; inset: 10px; border-radius: 22px;
  border: 1.5px dashed transparent; pointer-events: none;
  transition: border-color var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}
.stage.dropping::after { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.drop-hint {
  position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%);
  margin: 0; padding: 7px 14px; border-radius: 99px;
  background: var(--dark-bg); color: #fff; font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity var(--dur-base) var(--ease); pointer-events: none;
}
.stage.dropping .drop-hint { opacity: 1; }

.world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.item {
  position: absolute; top: 0; left: 0; transform-origin: 50% 50%;
  box-shadow: 0 14px 34px -14px rgba(16, 16, 30, .5), 0 0 0 1px rgba(16, 16, 30, .07);
  overflow: hidden; animation: fade-in var(--dur-slow) var(--ease);
}
.item.is-image { box-shadow: none; }
.item.is-active { box-shadow: 0 14px 34px -14px rgba(16, 16, 30, .5), 0 0 0 2px var(--accent); }
.item-art, .item-art svg, .item-art img { display: block; width: 100%; height: 100%; }
.item-label {
  position: absolute; bottom: 100%; left: 0; max-width: 100%;
  color: var(--label); white-space: nowrap; pointer-events: none;
  font-weight: 600; overflow: hidden; text-overflow: ellipsis;
}
.item.is-active .item-label { color: var(--ink); }

.sel-layer { position: absolute; top: 0; left: 0; z-index: 9; pointer-events: none; overflow: visible; }
.sel-box { fill: none; stroke: var(--accent); }
.sel-handle { fill: #fff; stroke: var(--accent); pointer-events: auto; cursor: nwse-resize; }
.sel-handle[data-handle="1"], .sel-handle[data-handle="3"] { cursor: nesw-resize; }
.sel-handle[data-handle="rot"] { cursor: grab; }
.guide-snap { stroke: #ff3b6b; opacity: .9; }

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--label); pointer-events: none;
}
.empty p { margin: 0; }
.empty .btn { pointer-events: auto; }

/* ---------- the one toolbar: a floating pill ---------- */
.toolbar {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 8;
  display: flex; align-items: center; gap: 4px; padding: 6px;
  background: linear-gradient(#fdfdfd, #f4f4f6); border-radius: 24px; box-shadow: var(--shadow-pop);
}
.tool {
  height: 38px; min-width: 38px; padding: 0 10px; border: 0; border-radius: 17px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: none; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.tool:hover { background: #ebebee; color: var(--ink); }
.tool-text { font-weight: 600; padding: 0 14px; }
.tool-label { min-width: 54px; text-align: center; font-size: 13px; font-weight: 550; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tool-sep { width: 1px; height: 22px; background: rgba(20, 20, 30, .09); margin: 0 4px; }

/* ---------- inspector: a floating card ---------- */
.inspector {
  position: relative; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  background: linear-gradient(#fbfbfc, #f6f6f8); border-radius: 30px; padding-bottom: 32px;
  box-shadow: 0 1px 0 #fff inset, 0 20px 50px -24px rgba(20, 20, 30, .3), 0 0 0 1px rgba(20, 20, 30, .05);
}
.inspector-top {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: 22px 24px 14px; background: linear-gradient(#fbfbfc 75%, rgba(251, 251, 252, 0));
}
.inspector-top h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-input {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 0; border-radius: 11px;
  background: var(--cell); box-shadow: var(--inset); font: inherit; font-size: 16px; font-weight: 650; color: var(--ink);
}
.seg-mode { flex: none; }
body[data-sel="pattern"] .seg-mode { display: inline-flex; }
body:not([data-sel="pattern"]) .seg-mode { display: none; }

.sec { padding: 18px 18px 20px; margin: 0 14px 12px; border-radius: 24px; background: rgba(255, 255, 255, .55); box-shadow: 0 0 0 1px var(--rule); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.sec-toggle {
  display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0;
  padding: 2px 0; border: 0; background: none; cursor: pointer; color: var(--ink-3);
  text-align: left; transition: color var(--dur-fast) var(--ease);
}
.sec-toggle:hover, .sec-toggle:hover .sec-title { color: var(--ink); }
.sec-chevron { flex: none; transition: transform var(--dur-base) var(--ease); }
.sec.is-closed .sec-chevron { transform: rotate(-90deg); }
.sec.is-closed .sec-body { display: none; }
.sec.is-closed { padding-bottom: 14px; }
.sec.is-closed .sec-head { margin-bottom: 0; }
.sec-title {
  margin: 0; font-size: 12px; font-weight: 650;
  letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
}
.sec-body { display: flex; flex-direction: column; gap: 12px; }
.slot { display: flex; flex-direction: column; gap: 14px; }
.hint { margin: 2px 2px 0; color: var(--ink-3); font-size: 12.5px; line-height: 1.45; }
.hint-block { margin: 0; }
.lockbtn {
  width: 28px; height: 28px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px; background: none; color: var(--ink-3); cursor: pointer;
}
.lockbtn:hover { background: var(--cell); color: var(--ink-2); }
.lockbtn .lk-shackle { transform-origin: 8px 7px; transition: transform var(--dur-base) var(--ease); }
.lockbtn:not(.is-on) .lk-shackle { transform: translateX(2.2px) rotate(16deg); }
.lockbtn.is-on { background: var(--dark-bg); color: #fff; box-shadow: var(--dark); }

/* ---------- cells: the row is the control (inset fields) ---------- */
.cell {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 18px;
  background: var(--cell); box-shadow: var(--inset); border-radius: var(--r); overflow: hidden;
}
.cell-group { display: flex; flex-direction: column; }
.cell-label { position: relative; z-index: 1; pointer-events: none; color: var(--ink); font-size: 14.5px; font-weight: 500; flex: 1; min-width: 0; }
.cell-value {
  position: relative; z-index: 1; pointer-events: none;
  color: var(--ink); font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  text-align: right; white-space: nowrap;
}
.is-range { cursor: ew-resize; touch-action: none; user-select: none; -webkit-user-select: none; }
.is-range:hover { background: var(--cell-hover); }
.is-range:focus-within { box-shadow: var(--inset), 0 0 0 2px var(--accent); }
.cell-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: var(--fill, 0%);
  background: linear-gradient(color-mix(in srgb, var(--accent) 34%, #fff), color-mix(in srgb, var(--accent) 46%, #fff));
  border-radius: var(--r) 0 0 var(--r); pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: background var(--dur-base) var(--ease);
}
.cell-fill::after {
  content: ""; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 78%, #000);
}
.cell-input-range {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; opacity: 0; appearance: none; background: none; pointer-events: none;
}
.ruler { height: 16px; margin: 3px 12px 0; }
.ruler-ticks {
  display: block; height: 100%; background-repeat: repeat-x;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='16'%3E%3Cg fill='%23c3c3cd'%3E%3Crect x='0' width='1' height='12'/%3E%3Crect x='6' width='1' height='7'/%3E%3Crect x='12' width='1' height='7'/%3E%3Crect x='18' width='1' height='7'/%3E%3Crect x='24' width='1' height='7'/%3E%3Crect x='30' width='1' height='12'/%3E%3Crect x='36' width='1' height='7'/%3E%3Crect x='42' width='1' height='7'/%3E%3Crect x='48' width='1' height='7'/%3E%3Crect x='54' width='1' height='7'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}
.ruler-ends { display: flex; justify-content: space-between; padding: 0 12px; color: var(--ink-3); font-size: 12px; }

.is-select { cursor: pointer; }
.is-select:hover { background: var(--cell-hover); }
.is-select:focus-within { box-shadow: var(--inset), 0 0 0 2px var(--accent); }
.cell-chevron { position: relative; z-index: 1; pointer-events: none; color: var(--ink-3); display: flex; }
.cell-input-select { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; opacity: 0; border: 0; cursor: pointer; font: inherit; }

.is-toggle { cursor: pointer; }
.is-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch {
  flex: none; width: 46px; height: 28px; border-radius: 99px; position: relative;
  background: #d5d5dc; box-shadow: var(--inset);
  transition: background var(--dur-base) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: linear-gradient(#fff, #f0f0f3);
  box-shadow: 0 1px 0 #fff inset, 0 2px 5px rgba(20, 20, 30, .28), 0 0 0 1px rgba(20, 20, 30, .05);
  transition: transform var(--dur-base) var(--ease);
}
input:checked + .switch { background: var(--dark-bg); box-shadow: 0 1px 3px rgba(0, 0, 0, .5) inset; }
input:checked + .switch::after { transform: translateX(18px); }
input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.is-color { cursor: pointer; }
.cell-dot { width: 28px; height: 28px; border-radius: 50%; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(20, 20, 30, .14), 0 2px 5px -1px rgba(20, 20, 30, .2); position: relative; z-index: 1; }
.cell-input-color { position: absolute; inset: 0; z-index: 2; opacity: 0; cursor: pointer; border: 0; }

.cell.is-segmented { flex-direction: column; align-items: stretch; gap: 10px; padding: 0; min-height: 0; background: none; box-shadow: none; overflow: visible; }
.is-segmented .cell-label { flex: none; font-size: 13px; color: var(--ink-2); padding-left: 2px; }
.is-segmented .seg { display: flex; background: none; box-shadow: none; padding: 0; gap: 6px; }
.is-segmented .seg-btn { flex: 1; height: 40px; background: var(--raise-bg); box-shadow: var(--raise); padding: 0 8px; color: var(--ink-2); }
.is-segmented .seg-btn.is-on { background: var(--dark-bg); color: #fff; box-shadow: var(--dark); }

.is-number .cell-input-number {
  width: 96px; height: 34px; border: 0; border-radius: 12px;
  background: var(--raise-bg); box-shadow: var(--raise); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; text-align: right; padding: 0 12px; font-variant-numeric: tabular-nums;
}
.is-text { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 12px 12px; }
.is-text .cell-label { flex: none; font-size: 13px; color: var(--ink-2); padding-left: 4px; }
.cell-input-text {
  width: 100%; height: 38px; border: 0; border-radius: 12px;
  background: var(--raise-bg); box-shadow: var(--raise); color: var(--ink); font: inherit; font-size: 14.5px; padding: 0 12px;
}

/* ---------- seed row ---------- */
.seedrow { display: flex; gap: 8px; }
.seedfield {
  flex: 1; min-width: 0; height: 40px; padding: 0 14px; border: 0; border-radius: var(--r);
  background: var(--cell); box-shadow: var(--inset); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; letter-spacing: .06em;
}
.seedfield:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- style tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 12px; }
.tile-wrap { position: relative; animation: rise-in var(--dur-slow) var(--ease) backwards; }
.tile-wrap:nth-child(3n+2) { animation-delay: 30ms; }
.tile-wrap:nth-child(3n) { animation-delay: 60ms; }
.tile {
  position: relative; width: 100%; display: flex; flex-direction: column; gap: 7px;
  padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: var(--ink-2);
}
.tile-art {
  display: block; border-radius: 16px; overflow: hidden; aspect-ratio: 26 / 17;
  box-shadow: 0 4px 10px -5px rgba(20, 20, 30, .3), 0 0 0 1px rgba(20, 20, 30, .07);
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.tile-art svg { display: block; width: 100%; height: 100%; }
.tile-name { font-size: 12.5px; font-weight: 550; text-align: center; }
.tile:hover { color: var(--ink); }
.tile:hover .tile-art { transform: translateY(-2px); box-shadow: 0 10px 18px -8px rgba(20, 20, 30, .42), 0 0 0 1px rgba(20, 20, 30, .07); }
.tile.is-on { color: var(--ink); }
.tile.is-on .tile-art { box-shadow: 0 0 0 2.5px var(--accent), 0 8px 16px -8px rgba(20, 20, 30, .4); }
.tile-check {
  position: absolute; top: 7px; right: 7px; width: 21px; height: 21px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--dark-bg); color: #fff; box-shadow: var(--dark);
  opacity: 0; transform: scale(.7);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-base) var(--ease);
}
.tile.is-on .tile-check { opacity: 1; transform: none; }
.tile-x {
  position: absolute; top: -6px; left: -6px; width: 20px; height: 20px;
  border: 0; border-radius: 50%; background: var(--dark-bg); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer; opacity: 0; z-index: 2;
  transition: opacity var(--dur-fast) var(--ease);
}
.tile-wrap:hover .tile-x, .tile-x:focus-visible { opacity: 1; }
.style-actions { display: flex; }
.style-form { display: flex; gap: 8px; width: 100%; }
.style-name {
  flex: 1; min-width: 0; height: 36px; padding: 0 13px; border: 0; border-radius: 12px;
  background: var(--cell); box-shadow: var(--inset); font: inherit; font-size: 14px; color: var(--ink);
}
.style-name::placeholder { color: var(--ink-3); }
.style-name:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.paste-form { display: flex; gap: 8px; width: 100%; }

/* ---------- palette ---------- */
.palette-row { display: flex; align-items: center; gap: 8px; }
.palette-strip {
  flex: 1; display: flex; height: 64px; border-radius: var(--r); overflow: hidden;
  box-shadow: 0 4px 10px -5px rgba(20, 20, 30, .3), 0 0 0 1px rgba(20, 20, 30, .07);
}
.pal { position: relative; flex: 1; cursor: pointer; min-width: 18px; }
.pal-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; cursor: pointer; }
.pal-add {
  flex: none; width: 48px; align-self: stretch; border: 0; border-radius: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--cell); box-shadow: inset 1px 0 0 rgba(20, 20, 30, .08);
  color: var(--ink-2); font-size: 18px; cursor: pointer;
}
.pal-add:hover { background: var(--cell-hover); color: var(--ink); }

/* ---------- mark picker ---------- */
.markgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.markcell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  padding: 6px; border: 0; border-radius: 16px; background: var(--cell); box-shadow: var(--inset); cursor: pointer;
  font: inherit; font-size: 12px; color: var(--ink-3);
}
.markcell img { max-width: 100%; max-height: 100%; display: block; }
.markcell:hover { background: var(--cell-hover); }
.markcell.is-on { box-shadow: var(--inset), 0 0 0 2px var(--accent); color: var(--ink); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 10px);
  margin: 0; padding: 12px 18px; max-width: 64ch;
  display: flex; align-items: center; gap: 14px;
  background: var(--dark-bg); color: #fff; border-radius: 20px; font-size: 14px; font-weight: 500;
  box-shadow: var(--dark), 0 18px 40px -18px rgba(16, 16, 30, .7);
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-slow) var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-action {
  border: 0; border-radius: 12px; padding: 6px 12px; cursor: pointer;
  background: rgba(255, 255, 255, .16); color: #fff; font: inherit; font-size: 13px; font-weight: 600;
}
.toast-action:hover { background: rgba(255, 255, 255, .26); }

/* ---------- the mobile bar ---------- */
.mobilebar {
  display: none; position: static; flex: none;
  gap: 8px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
}
.mb-btn {
  height: 44px; min-width: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 16px; background: var(--raise-bg); box-shadow: var(--raise); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.mb-btn:disabled { opacity: .35; }
.mb-text { flex: 1; }
.mb-primary { background: var(--dark-bg); color: #fff; box-shadow: var(--dark); }

/* ---------- motion: press feedback, arrivals ---------- */
.btn, .iconbtn, .chip, .seg-btn, .tool, .pop-row, .mb-btn, .lockbtn, .tile, .markcell, .pal-add, .opt, .cell {
  transition-property: background-color, background, color, box-shadow, opacity, transform, filter;
  transition-duration: var(--dur-fast); transition-timing-function: var(--ease);
}
.btn:active, .iconbtn:active, .chip:active, .seg-btn:active, .tool:active, .pop-row:active,
.mb-btn:active, .tile:active, .markcell:active { transform: scale(.97); }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade-in { from { opacity: 0; } }
#panelPattern:not([hidden]), #panelImage:not([hidden]), #panelTheme:not([hidden]) { animation: rise-in var(--dur-slow) var(--ease); }

/* ---------- responsive ---------- */
@media (max-width: 859px) {
  body { height: 100dvh; }
  .topbar { height: 56px; padding: 0 12px; }
  .brand h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mark { display: block; }
  .shell { display: flex; flex-direction: column; padding: 0 10px 0; gap: 10px; }
  .stage { flex: none; height: 38vh; min-height: 220px; border-radius: 26px; }
  .toolbar { bottom: 12px; padding: 4px; }
  .tool-text { padding: 0 10px; font-size: 13.5px; }
  .tool-label { min-width: 46px; font-size: 12.5px; }
  .inspector { flex: 1; min-height: 0; border-radius: 26px; }
  .mobilebar { display: flex; }
  .pop {
    left: 12px !important; right: 12px !important; top: auto !important;
    bottom: calc(74px + env(safe-area-inset-bottom)); width: auto; max-width: none; max-height: 68vh !important;
  }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .markgrid { grid-template-columns: repeat(3, 1fr); }
  .sec { padding: 12px 12px 14px; margin: 0 8px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .btn:active, .iconbtn:active, .chip:active, .seg-btn:active, .tool:active, .tile:active, .markcell:active { transform: none; }
}

/* ---------- Phosphor icons ---------- */
.ph { display: block; flex: none; }
.lockbtn:not(.is-on) .ic-lock-on, .lockbtn.is-on .ic-lock-off,
.pal-lock:not(.is-on) .ic-lock-on, .pal-lock.is-on .ic-lock-off { display: none; }
.tile-x { display: flex; align-items: center; justify-content: center; padding: 0; }
.tile-check .ph { width: 12px; height: 12px; }

/* ---------- colour picker & palette browser ---------- */
.cp {
  position: fixed; z-index: 55; width: 308px; max-width: calc(100vw - 24px); padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(#ffffff, #f8f8f9); border-radius: 30px; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(6px) scale(.98); transform-origin: center right;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-slow) var(--ease);
}
.cp.is-in { opacity: 1; transform: none; }
.cp.is-sheet { left: 0 !important; right: 0 !important; margin: 0 auto; top: auto !important; width: min(380px, calc(100% - 20px)); bottom: calc(74px + env(safe-area-inset-bottom)); transform-origin: bottom center; }

.cp-field {
  position: relative; height: 176px; border-radius: 22px; cursor: crosshair; touch-action: none; outline-offset: 3px;
  background:
    linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
    linear-gradient(to right, #fff, hsl(var(--hue) 100% 50%));
  box-shadow: inset 0 0 0 1px rgba(20, 20, 30, .08);
}
.cp-knob {
  position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; pointer-events: none;
  background: var(--picked); border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(20, 20, 30, .28), 0 3px 8px rgba(20, 20, 30, .35);
  transition: transform var(--dur-fast) var(--ease);
}
.is-dragging > .cp-knob { transform: scale(1.12); }
.cp-row { display: flex; align-items: center; gap: 12px; }
.cp-hue {
  position: relative; flex: 1; height: 14px; border-radius: 99px; cursor: pointer; touch-action: none; outline-offset: 5px;
  background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00);
  box-shadow: inset 0 0 0 1px rgba(20, 20, 30, .1);
}
.cp-hue .cp-knob-bar { top: 50%; background: hsl(var(--hue) 100% 50%); }
.cp-dropper { width: 36px; height: 36px; flex: none; color: var(--ink-2); }
.cp-dropper:hover { color: var(--ink); background: var(--cell); }

.cp-pill {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  height: 46px; padding: 0 16px; border: 0; border-radius: 99px; background: #fff;
  box-shadow: 0 0 0 1px rgba(20, 20, 30, .1), 0 1px 2px rgba(20, 20, 30, .05);
  color: var(--ink-2); font: inherit; font-size: 15px; font-weight: 600;
}
.cp-pill:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.cp-values { gap: 10px; }
.cp-fmt { flex: 0 0 112px; }
.cp-value { flex: 1; min-width: 0; width: 100%; text-align: center; font-variant-numeric: tabular-nums; outline: none; }
.cp-value.is-bad { color: #c2243c; }
.cp-src { width: 100%; }
.cp-caret { display: flex; color: var(--ink-3); }
.cp-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; font: inherit; }

.cp-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px 8px; padding: 2px 6px 4px; }
.cp-swatch {
  aspect-ratio: 1; width: 100%; padding: 0; cursor: pointer; border-radius: 9px;
  background: var(--c); border: 1.5px solid color-mix(in srgb, var(--c) 72%, #000);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.cp-swatch:hover { transform: scale(1.12); }
.cp-swatch:active { transform: scale(.94); }
.cp-swatch.is-on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.cp-empty { grid-column: 1 / -1; margin: 6px 0; text-align: center; color: var(--ink-3); font-size: 13px; }

.cp-palettes { width: 312px; padding: 8px; max-height: min(70vh, 560px); }
.cp-plist { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0 2px; }
.cp-ghead { margin: 10px 12px 4px; font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.cp-ghead:first-child { margin-top: 6px; }
.cp-prow {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 9px 12px; border: 0; border-radius: 17px;
  background: none; color: var(--ink); font: inherit; font-size: 15px; font-weight: 500; text-align: left; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.cp-prow:hover { background: #efeff1; }
.cp-prow:active { transform: scale(.98); }
.cp-prow.is-on { background: #efeff1; font-weight: 650; }
.cp-pname { flex: 1; min-width: 0; }
.cp-pcheck { display: flex; color: var(--ink); }
.cp-pstrip {
  display: inline-flex; flex: none; width: 76px; height: 26px; border-radius: 9px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(20, 20, 30, .1);
}
.cp-pstrip > span { flex: 1; }

/* the palette cell: a row that opens the browser */
.is-palette { width: 100%; border: 0; text-align: left; font: inherit; cursor: pointer; }
.is-palette:hover { background: var(--cell-hover); }
.cell-strip { position: relative; z-index: 1; display: flex; }
.cell-strip .cp-pstrip { width: 56px; height: 22px; border-radius: 7px; }

/* palette strip: each swatch opens the picker */

/* colour cells: the row opens the picker */
.is-color { cursor: pointer; }
.is-color:hover { background: var(--cell-hover); }
.is-color.is-editing { box-shadow: var(--inset), 0 0 0 2px var(--accent); }
.is-color .cell-value { color: var(--ink-2); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.cell-dot.is-auto { background: repeating-conic-gradient(#d8d8de 0 25%, #fff 0 50%) 0 0 / 10px 10px !important; }

/* ---------- resizable, collapsible sidebar ---------- */
/* a slim grip, inside a generous invisible grab zone that reaches into both panels */
.side-handle {
  position: relative; z-index: 12; display: flex; align-items: center; justify-content: center;
  cursor: col-resize; touch-action: none; outline: none; -webkit-user-select: none; user-select: none;
}
.side-handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: -10px; right: -10px; }
.side-handle span {
  position: relative; width: 6px; height: 56px; border-radius: 99px; pointer-events: none;
  background: rgba(20, 20, 30, .2);
  box-shadow: 0 0 0 2px rgba(248, 248, 249, .9);
  transition: height var(--dur-base) var(--ease), background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.side-handle:hover span, .side-handle:focus-visible span { height: 88px; background: rgba(20, 20, 30, .42); }
.side-handle:active span, .shell.is-resizing .side-handle span { height: 104px; background: var(--accent); }
.side-handle:focus-visible span { box-shadow: 0 0 0 2px rgba(248, 248, 249, .9), 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
.shell.is-resizing { transition: none; }
body.is-col-resizing, body.is-col-resizing * { cursor: col-resize !important; -webkit-user-select: none; user-select: none; }
body.is-col-resizing .stage, body.is-col-resizing .inspector { pointer-events: none; }
.inspector { min-width: 0; transition: opacity var(--dur-base) var(--ease), visibility 0s linear 0s; }
.shell.is-collapsed .inspector { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--dur-fast) var(--ease), visibility 0s linear var(--dur-slow); }
.side-toggle[aria-pressed="false"] { color: var(--ink-3); }
@media (max-width: 859px) {
  .side-handle, .side-toggle { display: none; }
  .shell, .shell.is-collapsed { display: flex; }
  .shell.is-collapsed .inspector { opacity: 1; visibility: visible; pointer-events: auto; }
}

/* ---------- palette swatches: quiet until you reach for them ---------- */
.pal { position: relative; flex: 1; min-width: 20px; cursor: pointer; color: var(--ink-on, #fff); outline: none; }
/* the swatch being edited keeps its size; the others make room, so it reads as zoomed in */
.pal { min-width: 0; transition: flex-grow var(--dur-slow) var(--ease), filter var(--dur-base) var(--ease); }
.palette-strip.has-editing .pal:not(.is-editing) { flex-grow: .45; }
.palette-strip:not(.has-editing) .pal:hover { filter: brightness(1.06); }
/* a squeezed swatch has no room for the pill, only for a lone lock */
.palette-strip.has-editing .pal:not(.is-editing) .pal-x { display: none; }
.palette-strip.has-editing .pal:not(.is-editing):not(.is-locked) .pal-tools { opacity: 0; }
.pal:focus-visible { outline: none; }

/* one small glass pill holds both actions */
.pal-tools {
  position: absolute; left: 50%; bottom: 12px; z-index: 1; pointer-events: none;
  display: flex; align-items: center; gap: 0; padding: 2px; border-radius: 99px;
  color: var(--ink-on, #fff);
  background: color-mix(in srgb, var(--ink-on, #fff) 14%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.3); backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-on, #fff) 16%, transparent);
  opacity: 0; transform: translate(-50%, 4px);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.pal:hover .pal-tools, .pal:focus-within .pal-tools, .pal.is-editing .pal-tools { opacity: 1; transform: translate(-50%, 0); }
.pal-lock, .pal-x {
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  background: none; color: inherit;
  transition: background-color var(--dur-fast) var(--ease);
}
.pal-lock:hover, .pal-x:hover { background: color-mix(in srgb, var(--ink-on, #fff) 20%, transparent); }
.pal-lock:focus-visible, .pal-x:focus-visible { outline: 2px solid var(--ink-on, #fff); outline-offset: 0; }
.pal-lock:not(.is-on) .ic-lock-on, .pal-lock.is-on .ic-lock-off { display: none; }
/* a locked colour keeps a lone lock showing, with no pill around it */
.pal.is-locked:not(:hover):not(:focus-within):not(.is-editing) .pal-tools { opacity: .9; transform: translate(-50%, 0); background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.pal.is-locked:not(:hover):not(:focus-within):not(.is-editing) .pal-x { display: none; }
@media (hover: none) { .pal-tools { opacity: 1; transform: translate(-50%, 0); } }

.palette-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.pal-lock .ph, .pal-x .ph { width: 13px; height: 13px; }

/* ---------- image as the palette's source ---------- */
.source-card {
  display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--r);
  background: var(--raise-bg); box-shadow: var(--raise); animation: rise-in var(--dur-slow) var(--ease);
}
.source-thumb { flex: none; width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--cell); box-shadow: 0 0 0 1px rgba(20, 20, 30, .1); }
.source-name { font-size: 14.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-x { width: 34px; height: 34px; flex: none; }

/* ---------- custom palettes ---------- */
.source-save { flex: none; gap: 7px; padding: 0 12px; height: 34px; }
.source-save.is-saved { background: none; box-shadow: none; color: var(--ink-3); cursor: default; }
.source-save .ph { flex: none; }
.cp-prow-wrap { position: relative; display: flex; align-items: center; }
.cp-prow-wrap .cp-prow { flex: 1; min-width: 0; }
.cp-pdel {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--ink-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center; opacity: 0;
  transition: opacity var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.cp-prow-wrap:hover .cp-pdel, .cp-pdel:focus-visible { opacity: 1; }
.cp-pdel:hover { background: rgba(20, 20, 30, .08); color: #c2243c; }
.cp-prow-wrap:hover .cp-pcheck { visibility: hidden; }
@media (hover: none) { .cp-pdel { opacity: 1; } }
.source-form { display: flex; gap: 8px; align-items: center; animation: rise-in var(--dur-base) var(--ease); }
.source-form .style-name { height: 40px; border-radius: var(--r-sm); }

/* segmented controls inside the export window fill the row */
.pop .seg { display: flex; width: 100%; }
.pop .seg .seg-btn { flex: 1; padding: 0 8px; }
.seg-scope { margin-bottom: 2px; }

/* ---------- welcome tour ---------- */
.wl {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(20, 20, 30, .4); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transition: opacity var(--dur-base) var(--ease);
}
.wl.is-in { opacity: 1; }
.wl-card {
  position: relative; width: min(620px, 100%); max-height: calc(100dvh - 40px); overflow-x: hidden; overflow-y: auto;
  padding: 10px 10px 20px; border-radius: 36px;
  background: linear-gradient(#ffffff, #f6f6f8); box-shadow: var(--shadow-pop);
  transform: translateY(14px) scale(.98); transition: transform var(--dur-slow) var(--ease);
}
.wl.is-in .wl-card { transform: none; }
.wl-close { position: absolute; top: 22px; right: 22px; z-index: 5; }
.wl-stage {
  position: relative; overflow: hidden; border-radius: 28px; aspect-ratio: 16 / 10;
  background: radial-gradient(circle at center, #c4c4cc 1.1px, transparent 1.2px) 0 0 / 24px 24px, linear-gradient(#f3f3f5, #eaeaee);
  box-shadow: var(--inset);
}
.wl-track { display: flex; height: 100%; transition: transform 460ms cubic-bezier(.32, .72, 0, 1); }
.wl-slide { position: relative; flex: 0 0 100%; height: 100%; }

.wl-board {
  position: absolute; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden;
  box-shadow: 0 14px 30px -14px rgba(16, 16, 30, .5), 0 0 0 1px rgba(16, 16, 30, .07);
}
.wl-board svg { display: block; width: 100%; height: 100%; }
.wl-hero, .wl-canvas, .wl-panel { position: absolute; inset: 0; }
.wl-logotype { position: absolute; top: 7%; left: 50%; transform: translateX(-50%); height: 44px; width: auto; }
.wl-fan { position: absolute; left: 7%; right: 7%; top: 27%; bottom: 3%; }
.wl-toolbar { bottom: 14px; }
.wl-toolbar .tool { pointer-events: none; }
.wl-panel { display: grid; place-items: center; padding: 16px; }
.wl-panel .sec { margin: 0; width: min(400px, 88%); animation: none; }
.wl-tiles { grid-template-columns: repeat(3, 1fr); gap: 12px; }
.wl-tiles .tile-wrap { animation: none; }
.wl-tiles .wl-on { box-shadow: 0 0 0 2.5px var(--accent), 0 8px 16px -8px rgba(20, 20, 30, .4); }
.wl-seed { display: flex; align-items: center; }
.wl-strip .pal { cursor: default; }
.wl-strip .wl-wide { flex-grow: 1.7; }
.wl-panel .source-card { animation: none; }
.wl-pop { position: relative !important; left: auto !important; right: auto !important; top: auto !important; bottom: auto !important; max-height: none !important; max-width: none; width: min(340px, 88%); animation: none; transform: none; opacity: 1; overflow: visible; }
.wl-select { display: inline-flex; align-items: center; }
.wl-pop .seg-btn, .wl-pop .btn { cursor: default; display: flex; align-items: center; justify-content: center; }
.wl-pop .btn { height: 46px; margin-top: 2px; border-radius: 18px; }

.wl-copy { padding: 24px 26px 6px; min-height: 148px; }
.wl-title { margin: 0 0 8px; font-size: 25px; line-height: 1.2; font-weight: 650; letter-spacing: -.025em; color: var(--ink); }
.wl-text { margin: 0; font-size: 15.5px; line-height: 1.55; color: var(--ink-2); max-width: 52ch; }
.wl-copy.is-in .wl-title, .wl-copy.is-in .wl-text { animation: rise-in var(--dur-slow) var(--ease) backwards; }
.wl-copy.is-in .wl-text { animation-delay: 50ms; }
.wl-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px 0 26px; }
.wl-dots { display: flex; align-items: center; gap: 8px; }
.wl-dot {
  width: 8px; height: 8px; padding: 0; border: 0; border-radius: 99px; cursor: pointer; background: rgba(20, 20, 30, .18);
  transition: width var(--dur-slow) var(--ease), background-color var(--dur-base) var(--ease);
}
.wl-dot:hover { background: rgba(20, 20, 30, .32); }
.wl-dot.is-on { width: 24px; background: var(--ink); }
.wl-actions { display: flex; align-items: center; gap: 8px; }
.wl-back { width: 44px; padding: 0; }
.wl-next { padding: 0 20px; }

@media (max-width: 560px) {
  .wl { padding: 12px; align-items: end; }
  .wl-card { border-radius: 30px; }
  .wl-stage { aspect-ratio: 1 / 1; }
  .wl-panel .sec, .wl-pop { zoom: .8; }
  .wl-copy { padding: 20px 18px 4px; min-height: 168px; }
  .wl-foot { padding: 6px 8px 0 18px; }
  .wl-logotype { height: 36px; }
}
@media (prefers-reduced-motion: reduce) { .wl-track { transition: none; } .wl-card { transition: none; } }

/* a segmented row with many options: no grey box, scrolls sideways */
.is-segmented.is-scroll .seg {
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-behavior: smooth;
  padding: 3px 2px 12px; margin: -3px -2px -12px; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding: 0 2px;
}
.is-segmented.is-scroll .seg::-webkit-scrollbar { display: none; }
.is-segmented.is-scroll .seg-btn { flex: 0 0 auto; padding: 0 16px; height: 40px; scroll-snap-align: start; }
.is-segmented.is-scroll .seg[data-fade="end"] { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.is-segmented.is-scroll .seg[data-fade="start"] { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); }
.is-segmented.is-scroll .seg[data-fade="both"] { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 36px), transparent); }
@media (prefers-reduced-motion: reduce) { .is-segmented.is-scroll .seg { scroll-behavior: auto; } }

/* the image card: thumbnail, then the name with its remove button, then Save underneath */
.source-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.source-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.source-head .source-name { flex: 1; min-width: 0; }
.source-head .source-x { width: 30px; height: 30px; margin-right: -4px; }
.source-main .source-save { width: 100%; height: 36px; justify-content: center; }
