@font-face {
  font-family: Roboto;
  src: url('assets/Roboto-Regular.ttf');
}
@font-face {
  font-family: Roboto;
  src: url('assets/Roboto-Bold.ttf');
  font-weight: 700;
}

:root {
  color-scheme: dark;
  --bg: #14171c;
  --panel: #1c2027;
  --panel2: #242931;
  --border: #30363e;
  --muted: #8f99a6;
  --text: #e7ebef;
  --accent: #c5ed95;
  --purple: #bdb1fb;
  font: 13px Roboto, system-ui, -apple-system, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  color: inherit;
  border: 0;
  background: none;
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

input {
  color: inherit;
}

button:hover:not(:disabled) {
  background: #ffffff0c;
}

button,
input {
  transition: background 0.15s, border-color 0.15s;
}

kbd {
  font: 10px Roboto, Arial, sans-serif;
  border: 1px solid #ffffff16;
  border-radius: 4px;
  padding: 3px 5px;
  color: var(--muted);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* --- Topbar --- */

.topbar {
  height: 80px;
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: #1b1f26;
}

.brand {
  display: flex;
  gap: 11px;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.8px;
}

.brand small {
  display: block;
  letter-spacing: 2.1px;
  font-size: 8px;
  color: var(--muted);
  margin-top: 4px;
}

.brand-icon {
  position: relative;
  font-size: 38px;
  line-height: 38px;
  letter-spacing: -7px;
  width: 42px;
  color: var(--accent);
  transform: rotate(-8deg);
  font-weight: 700;
}

.brand-icon span {
  position: absolute;
  font-size: 18px;
  top: -12px;
  right: 3px;
}

.document {
  padding-left: 25px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 100px;
}

.document input {
  background: none;
  border: 0;
  font-size: 14px;
  width: 210px;
  padding: 0;
  text-overflow: ellipsis;
}

.document > span {
  font-size: 10px;
  color: var(--muted);
}

.document > span.saved::before {
  content: '●';
  color: var(--accent);
  font-size: 7px;
  margin-right: 6px;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.btn {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 13px;
  white-space: nowrap;
  font-size: 12px;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1b2615;
  font-weight: 700;
}

.btn.primary:hover:not(:disabled) {
  background: #d4f5b0;
}

.btn kbd {
  font-size: 9px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 20px;
}

.file-actions > .icon-btn {
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 15px;
  margin-left: 5px;
}

.export-wrap {
  position: relative;
}

.dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  width: 255px;
  background: #272d35;
  border: 1px solid #414851;
  border-radius: 10px;
  padding: 6px;
  z-index: 10;
  box-shadow: 0 12px 50px #0006;
}

.dropdown button {
  display: flex;
  width: 100%;
  text-align: left;
  padding: 12px 9px;
  align-items: center;
  justify-content: space-between;
  border-radius: 5px;
  font-size: 12px;
}

.dropdown small {
  color: var(--muted);
  margin-left: 8px;
}

/* --- Main Studio Grid --- */

.studio {
  height: calc(100dvh - 80px);
  display: grid;
  grid-template-columns: 64px minmax(300px, 1fr) 300px;
}

/* --- Left Minimalist Tool Rail --- */

.tools {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 12px 0;
  gap: 11px;
  position: relative;
  z-index: 25;
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
}

.liquify-tool-wrap {
  position: relative;
}

.liquify-subtools {
  position: absolute;
  left: calc(100% + 10px);
  top: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #1f242c;
  border: 1px solid #38414e;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  z-index: 45;
}

.liquify-subtools[hidden] {
  display: none !important;
}

.liq-subtool.active::before {
  display: none;
}

.liq-subtool.active {
  background: #c5ed9522;
  border: 1px solid #748d55;
  color: var(--accent);
}

.tool {
  height: 40px;
  width: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #a5afba;
  position: relative;
}

.tool svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tool.active {
  background: #c5ed9517;
  color: var(--accent);
}

.tool.active::before {
  content: '';
  position: absolute;
  left: -12px;
  width: 2px;
  height: 22px;
  border-radius: 2px;
  background: var(--accent);
}

.tools-bottom {
  margin-top: auto;
}

/* --- Center Workspace --- */

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.workspace-bar {
  min-height: 51px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid #2b3038;
  font-size: 11px;
  color: var(--muted);
  overflow-x: auto;
  scrollbar-width: thin;
}

.liquify-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 11px;
  width: 100%;
}

.liquify-topbar[hidden],
.history[hidden] {
  display: none !important;
}

.liq-top-item {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.liq-top-item label {
  font-size: 10px;
  color: #a6b0bd;
}

.liq-top-item input[type='range'] {
  width: 66px;
  height: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}

.liq-top-item input[type='number'] {
  width: 44px;
  height: 24px;
  background: #15191f;
  border: 1px solid #343c47;
  border-radius: 4px;
  color: #d6dfe9;
  font-size: 10px;
  text-align: right;
  padding: 0 5px;
  font-variant-numeric: tabular-nums;
}

.liq-top-item.dim {
  opacity: 0.42;
  pointer-events: none;
}

.liq-top-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #bac3ce;
  cursor: pointer;
  white-space: nowrap;
}

.liq-top-check input[type='checkbox'] {
  accent-color: var(--accent);
  cursor: pointer;
}

.liq-bar-btn {
  height: 25px;
  padding: 0 9px;
  font-size: 10px;
  border-radius: 5px;
  white-space: nowrap;
}

.bg-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid #4a5565;
  background: repeating-conic-gradient(#777 0 25%, #ccc 0 50%) 0 / 8px 8px;
  display: inline-block;
  flex-shrink: 0;
}

.liq-top-select {
  height: 24px;
  background: #15191f;
  border: 1px solid #343c47;
  border-radius: 4px;
  color: #d6dfe9;
  font-size: 10px;
  padding: 0 5px;
  cursor: pointer;
}

.breadcrumb {
  display: flex;
  gap: 10px;
  align-items: center;
}

.breadcrumb strong {
  font-size: 10px;
  font-weight: 400;
  color: #c0c7d0;
}

.breadcrumb > span:not(.live-dot) {
  color: #525c68;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.history {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.history .icon-btn {
  font-size: 23px;
  color: #b1bac5;
}

.divider {
  height: 17px;
  border-left: 1px solid var(--border);
  margin: 0 7px;
}

.text-btn {
  font-size: 11px;
  color: var(--muted);
  border-radius: 4px;
  padding: 7px;
}

.text-btn.active {
  color: var(--accent);
}

.viewport {
  flex: 1;
  min-height: 120px;
  position: relative;
  overflow: hidden;
  outline: none;
  background-color: #12151a;
  background-image: radial-gradient(#626b742e 0.8px, transparent 0.8px);
  background-size: 18px 18px;
  touch-action: none;
}

.canvas-shadow {
  position: absolute;
  left: 0;
  top: 0;
  box-shadow: 0 20px 75px #0007;
  background: repeating-conic-gradient(#e5e7eb 0 25%, #fff 0 50%) 0 / 18px 18px;
  transform-origin: 0 0;
  pointer-events: none;
}

.canvas-shadow canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.zoom-controls {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: #20252de8;
  border: 1px solid #3a424e;
  border-radius: 8px;
  box-shadow: 0 5px 20px #0004;
  padding: 4px;
  z-index: 2;
}

.zoom-controls button {
  height: 28px;
  min-width: 29px;
  border-radius: 4px;
  font-size: 17px;
}

.zoom-controls #zoom-fit {
  font-size: 10px;
  min-width: 55px;
}

.zoom-controls span {
  height: 15px;
  border-right: 1px solid #3d444e;
  margin: 0 4px;
}

.view-badge {
  position: absolute;
  top: 17px;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid #596b45;
  border-radius: 20px;
  background: #202a20e8;
  font-size: 9px;
  letter-spacing: 1.1px;
  padding: 10px 14px;
  white-space:nowrap;
  pointer-events: none;
}

.view-badge .live-dot {
  margin-right: 7px;
}

.transport {
  height: 69px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-top: 1px solid var(--border);
  background: #1a1e25;
}

.transport-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-btn {
  border-color: #55506c;
  background: #bdb1fb10;
  color: var(--purple);
}

.mode-btn.active {
  background: #bdb1fb24;
}

.play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #49515d;
  font-size: 17px;
  display: inline-grid;
  place-items: center;
  color: #cdd6e2;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.play-btn:hover {
  border-color: #6a7585;
  color: #fff;
}

.mouse-jiggle-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mouse-jiggle-btn.active {
  background: #c5ed951c;
  border-color: #799459;
  color: var(--accent);
}

.shake-btn {
  border: 0;
  color: var(--accent);
  padding: 0 8px;
}

.shake-btn span {
  font-size: 22px;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  margin-left: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.switch-label input {
  position: absolute;
  opacity: 0;
  width: 31px;
  height: 18px;
  cursor: pointer;
}

.switch {
  width: 29px;
  height: 17px;
  border-radius: 20px;
  background: #444c58;
  position: relative;
}

.switch::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 11px;
  height: 11px;
  background: #c2c9d2;
  border-radius: 50%;
  transition: transform 0.15s;
}

.switch-label input:checked + .switch {
  background: #698647;
}

.switch-label input:checked + .switch::after {
  background: var(--accent);
  transform: translateX(12px);
}

.switch-label input:focus-visible + .switch {
  outline: 2px solid var(--accent);
}

.workspace-footer {
  height: 34px;
  flex-shrink: 0;
  background: #1c2027;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 22px;
  font-size: 11px;
  color: #8b95a3;
  font-family: Consolas, ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 18px;
}

.cursor-coords {
  min-width: 105px;
  color: #bac3ce;
}

.footer-meta {
  color: #8b95a3;
}

/* --- Right Inspector --- */

.inspector {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title h2 {
  font-size: 12px;
  letter-spacing: 0.1px;
  margin: 0;
  font-weight: 700;
}

.section-title h2 > span {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  background: #303641;
  padding: 2px 6px;
  margin-left: 7px;
  border-radius: 4px;
}

.layers-section {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.section-desc {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
  margin: 7px 0 17px;
  max-width: 210px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 220px;
  overflow: auto;
  scrollbar-width: thin;
}

.layer {
  display: flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  gap: 7px;
  cursor: pointer;
}

.layer.selected {
  background: #bdb1fb12;
  border-color: #bdb1fb4a;
}

.layer.drag-over {
  border-top: 2px solid var(--accent);
}

.layer .grip {
  color: #596472;
  font-size: 11px;
  cursor: grab;
}

.layer .layer-dot {
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
  flex-shrink: 0;
}

.layer-name {
  font-size: 11px;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.layer button {
  font-size: 14px;
  color: #9ca6b4;
  padding: 3px;
  width: 24px;
  border-radius: 4px;
}

.layer button.checked {
  color: var(--accent);
  background: #c5ed951c;
}

.layer .dim {
  opacity: 0.35;
}

.layer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.layer-actions .text-btn:last-child {
  color: #a9a0a1;
}

.layer-name-edit .field-label {
  margin: 10px 0 6px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: #181c22;
}

.mode-tab {
  height: 29px;
  border-radius: 6px;
  border: 1px solid #2e3540;
  background: #1f242c;
  color: #96a1af;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mode-tab:hover {
  color: #d6dfe9;
  border-color: #454f5e;
}

.mode-tab.active {
  background: #c5ed951a;
  border-color: #748d55;
  color: var(--accent);
}

.properties {
  padding: 22px 19px 16px;
}

.mini-label {
  font-size: 9px;
  color: var(--purple);
  font-variant-numeric: tabular-nums;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin: 18px 0 8px;
}

.text-field {
  width: 100%;
  height: 33px;
  border: 1px solid #39414b;
  background: #171b21;
  border-radius: 6px;
  padding: 0 9px;
  font-size: 12px;
}

.shape-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 17px 0 5px;
}

.shape-row .field-label {
  margin: 0 auto 0 0;
}

.chip {
  font-size: 9px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: #a0abb9;
  white-space: nowrap;
}

.chip.active {
  color: var(--accent);
  border-color: #728858;
  background: #c5ed9514;
}

.puru-block {
  margin-top: 14px;
}

.puru-block .field-label {
  margin: 0 0 7px;
}

.chip-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.chip-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.chip-grid-3 .chip,
.chip-grid-4 .chip {
  text-align: center;
  justify-content: center;
}

.slider-control {
  margin-top: 17px;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 5px;
}

.slider-label label {
  font-size: 11px;
  color: #bac3ce;
}

.slider-label output {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: #c8d4df;
  background: #2a303a;
  border-radius: 4px;
  padding: 3px 6px;
  min-width: 36px;
  text-align: right;
}

.slider-control input {
  width: 100%;
  height: 3px;
  display: block;
  margin: 10px 0 2px;
  accent-color: var(--purple);
  cursor: pointer;
}

.slider-control:first-child input {
  accent-color: var(--accent);
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: #6f7b89;
  margin-top: 7px;
}

#nodes-topbar .slider-control {
  flex: 0 0 220px;
  width: 220px;
  margin-top: 0;
}

#nodes-topbar .slider-label {
  margin-bottom: 4px;
}

.transform-section {
  margin-top: 24px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
}

.transform-section h3 {
  font-size: 11px;
  font-weight: 400;
  color: #b5beca;
  margin: 0 0 13px;
}

.number-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.number-grid label {
  font-size: 9px;
  color: var(--muted);
}

.number-grid input {
  display: block;
  margin-top: 6px;
  width: 100%;
  background: #171b21;
  border: 1px solid #39414b;
  border-radius: 5px;
  font-size: 11px;
  padding: 7px 9px;
  color: #d8dee6;
}

.reset-params {
  width: 100%;
  font-size: 9px;
  margin-top: 16px;
}

.privacy-note {
  margin-top: auto;
  padding: 20px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #a9b2bd;
  font-size: 10px;
  line-height: 1.6;
}

.privacy-note > span {
  color: var(--accent);
  font-size: 22px;
}

.privacy-note small {
  display: block;
  color: #717e8d;
  font-size: 9px;
}

#no-selection {
  font-size: 12px;
  color: var(--muted);
  padding: 25px 0;
  line-height: 1.7;
}

/* --- Overlays, Crop Confirm, Dialogs & Toast --- */

.drop-overlay {
  position: absolute;
  inset: 15px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a2729f5;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  gap: 15px;
  font-size: 19px;
  color: var(--accent);
  pointer-events: none;
}

.drop-overlay > span {
  font-size: 48px;
}

.drop-overlay small {
  font-size: 12px;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: #303a2a;
  color: #d6f6b7;
  border: 1px solid #5b7049;
  border-radius: 8px;
  padding: 12px 20px;
  z-index: 1000;
  font-size: 12px;
  max-width: 85vw;
  box-shadow: 0 8px 40px #0005;
}

.toast.error {
  background: #42282b;
  border-color: #9a5158;
  color: #ffd6db;
}

.fatal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 50px;
  background: #14171cf5;
  z-index: 2000;
  font-size: 18px;
  color: #ffb5bf;
  line-height: 1.8;
}

dialog {
  width: min(850px, 90vw);
  max-height: 88dvh;
  overflow: auto;
  background: #20252d;
  border: 1px solid #424a55;
  border-radius: 16px;
  color: var(--text);
  padding: 30px;
  box-shadow: 0 25px 100px #0008;
}

dialog::backdrop {
  background: #080b10b8;
  backdrop-filter: blur(5px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-header h2 {
  font-size: 25px;
  letter-spacing: -0.6px;
  margin: 10px 0;
}

.eyebrow {
  font-size: 8px;
  letter-spacing: 1.8px;
  color: var(--accent);
}

.dialog-intro {
  font-size: 12px;
  color: #a8b4c3;
  line-height: 1.8;
  margin: 10px 0 25px;
  max-width: 640px;
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 30px;
}

.help-grid h3 {
  font-size: 12px;
  margin: 8px 0 16px;
}

.help-grid p {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #a9b4c2;
  line-height: 1.8;
  gap: 7px;
}

.help-note {
  font-size: 10px;
  color: #97a5b6;
  line-height: 1.8;
  background: #161c23;
  border: 1px solid #36404c;
  border-radius: 7px;
  padding: 14px;
  margin-top: 25px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.project-card {
  position: relative;
  text-align: left;
  border: 1px solid #3c4552;
  border-radius: 10px;
  background: #171c23;
  overflow: hidden;
  padding: 0 0 13px;
  display: block;
  min-width: 0;
}

.project-card:hover {
  border-color: var(--accent);
  background: #202a25;
}

.project-card img {
  width: 100%;
  aspect-ratio: 1.3;
  object-fit: contain;
  background: #13171c;
  display: block;
  margin-bottom: 13px;
}

.project-card strong,
.project-card small {
  display: block;
  padding: 0 13px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  font-size: 12px;
}

.project-card small {
  font-size: 10px;
  color: var(--muted);
  margin-top: 7px;
}

.project-card .remove-project {
  position: absolute;
  right: 7px;
  top: 7px;
  background: #171b24d9;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 14px;
}

body.preview .properties {
  opacity: 0.55;
}

body.preview .viewport {
  cursor: grab;
}

body.preview .viewport:active {
  cursor: grabbing;
}

body.recording .viewport {
  outline: 2px solid #e17b82;
  outline-offset: -2px;
}

.record-label {
  color: #f3a1a6 !important;
}

.empty-library {
  font-size: 12px;
  color: var(--muted);
  padding: 25px 0;
  grid-column: 1 / -1;
}

/* --- Responsive Breakpoints --- */

@media (min-width: 1600px) {
  .studio {
    grid-template-columns: 70px minmax(300px, 1fr) 330px;
  }
  .inspector .layers-section,
  .inspector .properties {
    padding-left: 24px;
    padding-right: 24px;
  }
  .layer-list {
    max-height: 270px;
  }
}

@media (max-width: 1100px) {
  .topbar {
    gap: 20px;
    padding: 0 16px;
  }
  .document {
    padding-left: 17px;
  }
  .document input {
    width: 140px;
  }
  .btn kbd {
    display: none;
  }
  .studio {
    grid-template-columns: 56px minmax(280px, 1fr) 270px;
  }
  .transport {
    padding: 0 12px;
  }
  .transport-left {
    gap: 5px;
  }
  .transport .btn {
    padding: 0 8px;
    font-size: 10px;
  }
  .switch-label {
    margin-left: 4px;
    font-size: 9px;
    gap: 5px;
  }
  .transport > #reset-btn {
    font-size: 9px;
  }
  .workspace-footer {
    padding: 0 12px;
    font-size: 8px;
  }
  .workspace-footer > span:last-child {
    display: none;
  }
  .tools .tool.active::before {
    left: -8px;
  }
}

@media (max-width: 820px) {
  .topbar {
    height: 66px;
    gap: 12px;
  }
  .brand {
    font-size: 20px;
  }
  .brand-icon {
    font-size: 32px;
    width: 34px;
  }
  .document {
    border: 0;
    padding: 0;
  }
  .document input {
    width: 120px;
    font-size: 12px;
  }
  .file-actions {
    gap: 5px;
  }
  .file-actions .btn {
    font-size: 10px;
    padding: 0 8px;
    height: 32px;
  }
  #library-btn {
    display: none;
  }
  .studio {
    height: calc(100dvh - 66px);
    grid-template-columns: 48px minmax(230px, 1fr) 235px;
  }
  .tools .tool {
    width: 34px;
    height: 36px;
  }
  .properties {
    padding: 18px 13px;
  }
  .layers-section {
    padding: 13px 11px 8px;
  }
  .workspace-bar {
    padding: 0 10px;
  }
  .transport {
    height: auto;
    min-height: 65px;
    padding: 9px;
  }
  .transport-left {
    flex-wrap: wrap;
    gap: 7px;
  }
  .transport > #reset-btn {
    display: none;
  }
  .switch-label {
    margin-left: 0;
  }
  .privacy-note {
    padding: 12px;
    font-size: 9px;
  }
  .privacy-note small {
    font-size: 8px;
  }
  .view-badge {
    font-size: 7px;
    letter-spacing: 0.4px;
  }
}

@media (max-width: 600px) {
  body {
    overflow: auto;
  }
  .topbar {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 9px;
  }
  .brand small {
    display: none;
  }
  .brand-icon {
    line-height: 28px;
  }
  .document {
    margin-left: auto;
  }
  .file-actions {
    width: 100%;
    margin: 0;
    justify-content: space-between;
  }
  .file-actions #library-btn {
    display: block;
  }
  .studio {
    height: auto;
    min-height: calc(100dvh - 110px);
    grid-template-columns: 44px 1fr;
    align-items: stretch;
  }
  .tools {
    grid-row: 1 / 3;
    position: sticky;
    top: 0;
    max-height: 100dvh;
  }
  .workspace {
    height: 70dvh;
    min-height: 440px;
  }
  .inspector {
    grid-column: 2;
    overflow: visible;
    display: grid;
    grid-template-columns: 1fr;
  }
  .layer-list {
    max-height: 160px;
  }
  .properties {
    padding: 20px;
  }
  .sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
  }
  .privacy-note {
    grid-column: 1 / -1;
  }
  .help-grid {
    grid-template-columns: 1fr;
  }
  dialog {
    padding: 22px;
  }
  .workspace-footer {
    font-size: 8px;
  }
  .number-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .zoom-controls {
    bottom: 12px;
  }
}

/* Background removal uses the same toolbar geometry as Liquify. */
#bgremove-topbar [hidden] { display: none !important; }
#bg-status { flex: 1 1 240px; font-size: 11px; color: #b9c4d2; }
#bgremove-topbar { gap: 7px 10px; }
#bgremove-topbar button:disabled { opacity: .45; cursor: default; }

/* Automatic shape detection: first tool in the rail. */
.magic-tool-wrap { position: relative; }
.magic-menu { position: absolute; left: calc(100% + 10px); top: 0; width: max-content; max-width: min(300px, calc(100vw - 80px)); padding: 5px; border: 1px solid #38414e; background: #1f242c; border-radius: 9px; box-shadow: 0 12px 30px #0008; z-index: 46; }
.magic-menu[hidden], #shape-topbar[hidden], #shape-topbar [hidden] { display: none !important; }
.magic-menu button { display: flex; gap: 9px; width: 100%; padding: 10px 11px; text-align: left; font-size: 12px; color: #dbe3ed; border-radius: 5px; }
.magic-menu button:hover, .magic-menu button:focus-visible { background: #c5ed9522; color: #c5ed95; }
#shape-topbar { gap: 7px 10px; }
#shape-count { font-size: 11px; color: #c7d0db; }
#shape-status { flex-basis: 100%; font-size: 11px; color: #b9c4d2; line-height: 1.4; }
.shape-results { display: flex; flex-wrap: wrap; gap: 5px; flex-basis: 100%; max-height: 80px; overflow-y: auto; }
.shape-results:empty { display: none; }
.shape-results label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #39424e; border-radius: 5px; padding: 3px 6px; font-size: 10px; cursor: pointer; }
.shape-results input { accent-color: #c5ed95; }
#shape-topbar button:disabled { opacity: .45; cursor: default; }

.shape-results label.shape-conflict { border-color: #a45d4c; color: #ecaa98; cursor: not-allowed; }



/* Contextual inspector and crop controls */
.region-inspector { display:flex; flex-direction:column; flex:1; min-width:0; }
.crop-panel { display:flex; flex-direction:column; flex:1; min-height:0; }
.crop-heading { padding:14px 18px; border-bottom:1px solid var(--border); flex-shrink:0; }
.crop-heading .icon-btn { width:26px; height:26px; font-size:21px; }
.crop-panel-body { padding:0 16px 12px; flex:1; min-height:0; overflow-y:auto; scrollbar-width:thin; }
.crop-source { color:var(--muted); font-size:11px; margin:15px 2px; }
.crop-card { padding:14px; border:1px solid var(--border); border-radius:9px; margin-bottom:12px; background:#1a1e25; }
.crop-card h3 { font-size:11px; font-weight:500; margin:0 0 13px; display:flex; justify-content:space-between; }
.crop-card h3 span { color:var(--muted); font-size:10px; }
.crop-number-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.crop-number-grid label { display:flex; flex-direction:column; gap:6px; color:#aeb7c2; font-size:10px; }
.crop-number-grid input, .crop-ratio-fields input, .crop-select { width:100%; min-width:0; height:32px; padding:0 9px; background:#14181e; border:1px solid #353c47; border-radius:5px; color:var(--text); font:inherit; font-variant-numeric:tabular-nums; }
.crop-number-grid input { font-size:12px; }
.crop-select { font-size:11px; margin-top:5px; }
.crop-ratio-fields { display:flex; align-items:center; gap:8px; margin-top:12px; }
.crop-ratio-fields input { flex:1; width:55px; }
.crop-ratio-fields .icon-btn { flex-shrink:0; width:27px; }
.crop-check { display:flex; align-items:center; gap:6px; margin-top:13px; font-size:11px; color:#afb8c3; }
.crop-check input { accent-color:var(--accent); }
.crop-transform-row { display:grid; grid-template-columns:repeat(4,1fr); gap:5px; }
.crop-transform-row button { height:39px; border-radius:5px; background:#2a3039; display:flex; align-items:center; justify-content:center; gap:2px; font-size:23px; }
.crop-transform-row button small { font-size:8px; color:var(--muted); }
.crop-transform-row svg { width:23px; height:23px; fill:none; stroke:currentColor; stroke-width:1.4; }
.crop-result { display:flex; justify-content:space-between; align-items:center; padding:5px 2px; font-size:11px; color:var(--muted); }
.crop-result strong { color:var(--accent); font-weight:500; }
.crop-reset { width:100%; margin:10px 0 4px; font-size:11px; }
.crop-status { color:var(--muted); font-size:10px; line-height:1.7; margin:8px 2px 0; }
.crop-actions { display:flex; gap:8px; flex-shrink:0; padding:14px 16px; background:var(--panel); border-top:1px solid var(--border); margin-top:auto; }
.crop-actions .btn { flex:1; min-width:0; padding:0 8px; height:35px; font-size:11px; }
.crop-actions kbd { padding:1px 3px; font-size:8px; }
.tool-context { padding:22px 18px; flex:1; }
.tool-context h2 { font-size:12px; margin:0 0 12px; }
.tool-context p { font-size:11px; line-height:1.8; color:var(--muted); }
body.crop-active #canvas-frame { visibility:hidden; }
body.crop-active .inspector { overflow:hidden; }
body.crop-active .privacy-note { flex-shrink:0; padding:12px 16px; }
@media(max-width:680px){ .crop-panel-body { display:grid; grid-template-columns:1fr 1fr; gap:10px; overflow:visible; } .crop-source,.crop-result,.crop-reset,.crop-status { grid-column:1/-1; } .crop-card { margin-bottom:0; } }


/* Image geometry menu and Image Size inspector */
.image-size-menu { gap:6px; padding:6px; }
.size-menu-item { display:flex; align-items:center; gap:8px; padding:9px 11px; border-radius:6px; white-space:nowrap; color:#c5ced9; font-size:11px; }
.size-menu-item svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.5; flex-shrink:0; }
.size-menu-item.active { background:#c5ed9522; color:var(--accent); }
.resize-panel .crop-card h3 { margin-bottom:10px; }
.resize-dimensions { margin-top:12px; }
.resize-resolution { display:flex; gap:7px; }
.resize-resolution input { width:80px; min-width:0; height:32px; border-radius:5px; border:1px solid #353c47; background:#14181e; padding:0 8px; color:var(--text); }
.resize-resolution select { flex:1; margin-top:0; }
.resize-note { color:var(--muted); font-size:10px; line-height:1.7; margin:10px 0 0; }
.resize-result { display:flex; flex-direction:column; gap:6px; padding:5px 2px 10px; }
.resize-result strong { font-size:12px; color:var(--accent); font-weight:500; }
.resize-result span { color:var(--muted); font-size:10px; }
.resize-preview { width:100%; margin:6px 0; height:32px; font-size:11px; }
.resize-error { color:#e8a0a7; font-size:10px; line-height:1.6; }
.resize-param { display:flex; align-items:center; justify-content:space-between; margin-top:12px; font-size:10px; color:#aeb7c2; gap:10px; }
.resize-param input { width:72px; accent-color:var(--accent); }
.resize-param input[type=number] { height:26px; color:var(--text); background:#14181e; border:1px solid #353c47; border-radius:4px; padding:0 6px; }
body.resize-active #canvas-frame { visibility:hidden; }
body.resize-active .inspector { overflow:hidden; }
body.resize-active .privacy-note { flex-shrink:0; padding:12px 16px; }
@media(max-width:680px){ .resize-panel .crop-panel-body { display:block; } .resize-panel .crop-card { margin-bottom:12px; } .image-size-menu { flex-direction:column; align-items:stretch; } }

/* Retouch draft and inspector */
.retouch-menu { gap:4px; padding:6px; max-width:calc(100vw - 90px); overflow-x:auto; }
.retouch-panel .crop-card { margin-top:14px; }
.retouch-label { margin-top:14px; }
.retouch-range { display:block; margin-top:15px; font-size:11px; color:var(--muted); }
.retouch-range span { display:flex; justify-content:space-between; gap:8px; margin-bottom:8px; }
.retouch-range output { color:var(--text); }
.retouch-range input { width:100%; accent-color:var(--accent); }
.retouch-row { display:flex; flex-wrap:wrap; gap:8px; margin:14px 0 4px; }
.retouch-row .btn { flex:1; min-width:80px; min-height:32px; padding:6px 8px; font-size:10px; }
.retouch-row .text-btn { font-size:10px; }
body.retouch-active #canvas-frame { visibility:hidden; }
body.retouch-active .inspector { overflow:hidden; }
body.retouch-active .privacy-note { flex-shrink:0; padding:12px 16px; }
@media(max-width:680px){ .retouch-panel .crop-panel-body { display:block; } .retouch-menu .size-menu-item span { display:none; } }
