body {
  background-color: #09090b;
  color: #e4e4e7;
  overflow: hidden;
}

:root {
  --pane-left-width: 519px;
  --pane-right-width: 336px;
  --pane-collapsed-width: 56px;
  --bottom-pane-height: 180px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #18181b;
}
::-webkit-scrollbar-thumb {
  background: #3f3f46;
}
::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

input[type='range'] {
  -webkit-appearance: none;
  background: transparent;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 12px;
  width: 12px;
  background: #fafafa;
  cursor: pointer;
  margin-top: -5px;
  border: 1px solid #09090b;
}
input[type='range']::-webkit-slider-runnable-track {
  width: 100%;
  height: 2px;
  cursor: pointer;
  background: #3f3f46;
}

input[type='color'] {
  -webkit-appearance: none;
  border: none;
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
input[type='color']::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 9999px;
}

.paper-texture {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
}

.tool-bar {
  position: absolute;
  top: 20px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
  background: #0f0f12;
  border: 1px solid #27272a;
  border-radius: 12px;
  z-index: 30;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.mobile-pane-handle {
  display: none;
  position: fixed;
  z-index: 70;
  border: 1px solid #3f3f46;
  background: rgba(9, 9, 11, 0.94);
  color: #d4d4d8;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 7px;
}

.mobile-pane-handle-left,
.mobile-pane-handle-right {
  top: 52%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
}

.mobile-pane-handle-left {
  left: 0;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

.mobile-pane-handle-right {
  right: 0;
  border-right: none;
  border-radius: 8px 0 0 8px;
}

.mobile-pane-handle-bottom {
  bottom: 10px;
  right: 10px;
  border-radius: 9999px;
  padding: 6px 11px;
}

#main-canvas {
  touch-action: none;
}

.touch-modifier-bar {
  position: absolute;
  left: 76px;
  top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid #27272a;
  border-radius: 12px;
  background: rgba(15, 15, 18, 0.95);
  z-index: 30;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.touch-mod-btn {
  border: 1px solid #2f3036;
  border-radius: 8px;
  min-width: 44px;
  height: 30px;
  padding: 0 10px;
  color: #a1a1aa;
  background: #09090b;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.touch-mod-btn.active {
  color: #67e8f9;
  border-color: #155e75;
  background: #082f49;
}

.tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #27272a;
  background: #141417;
  color: #e4e4e7;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tool-icon {
  width: 16px;
  height: 16px;
  display: block;
}

.tool-btn:hover {
  background: #1f1f23;
  color: #fafafa;
}

.tool-btn.active {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.tool-divider {
  height: 1px;
  width: 100%;
  background: #27272a;
  margin: 2px 0;
}

.tool-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.tool-submenu {
  position: absolute;
  left: 44px;
  top: 0;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid #27272a;
  background: #0f0f12;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 40;
}

.tool-submenu.open {
  display: flex;
}

.tool-sub-btn {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid #27272a;
  background: #111113;
  color: #a1a1aa;
  font-size: 0.65rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tool-sub-btn svg {
  width: 16px;
  height: 16px;
}

.tool-sub-btn:hover {
  color: #fafafa;
  background: #1a1a1f;
}

.tool-sub-btn.hover {
  color: #fafafa;
  background: #1a1a1f;
  border-color: #38bdf8;
}

.tool-sub-btn.active {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.tool-btn.hidden {
  display: none;
}

.control-group {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #27272a;
  padding-bottom: 1.5rem;
}

.control-label {
  display: block;
  font-size: 0.75rem;
  line-height: 1rem;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.value-chip {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.value-input.hidden {
  display: none;
}

.control-section {
  margin: 1.5rem 0 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #27272a;
}

.control-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a1a1aa;
}

.left-panel-sections {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.left-panel-section {
  border: 1px solid #27272a;
  background: #0f0f12;
}

.left-panel-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  border-bottom: 1px solid #27272a;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  text-align: left;
}

.left-panel-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a1a1aa;
}

.left-panel-section-toggle {
  width: 14px;
  height: 14px;
  position: relative;
  display: inline-block;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.left-panel-section-toggle::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 3px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent #a1a1aa;
}

.left-panel-section.collapsed .left-panel-section-toggle {
  transform: rotate(0deg);
}

.left-panel-section-body {
  padding: 0.75rem;
}

.layer-item.active {
  border-left: 4px solid #fafafa;
  background-color: rgba(39, 39, 42, 0.5);
}

.layer-item {
  user-select: none;
}

.layer-item.selected {
  border-color: #fafafa;
}

.layer-mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 1px solid #27272a;
  border-radius: 9999px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
  background: rgba(9, 9, 11, 0.72);
}

.layer-mini-badge--mask {
  color: #67e8f9;
  border-color: rgba(103, 232, 249, 0.35);
}

.layer-group {
  background: #101012;
  border-style: dashed;
}

.group-drop-target {
  border-color: #fafafa;
  box-shadow: inset 0 0 0 1px rgba(250, 250, 250, 0.6);
}

.layer-sub {
  padding-left: 0;
}

.layer-grip--spacer {
  display: inline-block;
  width: 14px;
  height: 14px;
}

.group-toggle {
  width: 18px;
  height: 18px;
  border: 1px solid #27272a;
  border-radius: 4px;
  background: #09090b;
  color: #a1a1aa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.group-toggle:hover {
  color: #fafafa;
  border-color: #fafafa;
}

.layer-grip {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.layer-grip .dot {
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: #71717a;
}

.pen-assign {
  position: relative;
  width: 20px;
  height: 20px;
  margin-right: 4px;
}

.pen-pill {
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.pen-menu {
  position: absolute;
  right: 0;
  top: 24px;
  min-width: 160px;
  background: #09090b;
  border: 1px solid #27272a;
  padding: 6px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pen-menu.hidden {
  display: none;
}

.layer-mask-popover-wrap {
  margin: -4px 0 8px;
}

.layer-mask-editor {
  border: 1px solid #27272a;
  background: rgba(9, 9, 11, 0.92);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.layer-mask-editor--compact {
  margin-top: 2px;
}

.layer-mask-editor__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.layer-mask-editor__header-copy {
  display: grid;
  gap: 3px;
}

.layer-mask-editor__title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #e4e4e7;
}

.layer-mask-editor__subtitle {
  font-size: 10px;
  line-height: 1.4;
  color: #71717a;
}

.layer-mask-editor__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #a1a1aa;
}

.layer-mask-editor__list {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding-right: 2px;
}

.layer-mask-editor__source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid #27272a;
  background: rgba(2, 6, 23, 0.56);
  cursor: pointer;
}

.layer-mask-editor__source-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.layer-mask-editor__source-name {
  font-size: 11px;
  color: #e4e4e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-mask-editor__source-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layer-mask-editor__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 1px solid #27272a;
  border-radius: 9999px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
}

.layer-mask-editor__actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.layer-mask-editor__btn {
  border: 1px solid #27272a;
  background: rgba(9, 9, 11, 0.72);
  color: #e4e4e7;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 7px 8px;
}

.layer-mask-editor__btn:hover:not(:disabled) {
  border-color: #52525b;
  background: rgba(24, 24, 27, 0.92);
}

.layer-mask-editor__btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.layer-mask-editor__empty,
.layer-mask-editor__warning {
  font-size: 10px;
  line-height: 1.5;
  color: #71717a;
}

.layer-mask-editor__warning {
  color: #fbbf24;
}

.layer-mask-trigger {
  border: 1px solid #27272a;
  border-radius: 999px;
  background: rgba(24, 24, 27, 0.8);
  color: #a1a1aa;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 10px;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.layer-mask-trigger:hover {
  color: #e4e4e7;
  border-color: #3f3f46;
  background: rgba(39, 39, 42, 0.48);
}

.layer-mask-trigger--active {
  color: #67e8f9;
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(8, 145, 178, 0.12);
}

.pen-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: #e4e4e7;
  text-align: left;
  font-size: 0.75rem;
}

.pen-option:hover {
  border-color: #3f3f46;
  background: #18181b;
}

.pen-option.active {
  border-color: #fafafa;
}

.pen-option .pen-icon {
  width: 16px;
  height: 16px;
}

.pen-icon {
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  border: 1px solid #27272a;
  position: relative;
  background: #e4e4e7;
}

.pen-icon::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: calc(2px + var(--pen-width, 0.3) * 6px);
  height: calc(2px + var(--pen-width, 0.3) * 6px);
  transform: translate(-50%, -50%);
  border-radius: 9999px;
  background: currentColor;
}

.pen-assign .pen-icon {
  color: #e4e4e7;
}

.pen-select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.pen-list .pen-icon {
  border-color: #3f3f46;
}

.pen-item .pen-icon {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
}

.pen-item {
  gap: 8px;
}

.pen-width {
  width: 90px;
}

.pen-width-value {
  width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pen-grip {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.pen-grip:active {
  cursor: grabbing;
}

.pen-grip .dot {
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: #71717a;
}

.formula-text {
  font-variant-ligatures: none;
}

.formula-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.formula-equation,
.formula-values {
  background: #141418;
  border: 1px solid #2a2b31;
  border-radius: 8px;
  padding: 8px 10px;
}

.formula-line {
  white-space: pre-wrap;
}

.formula-values-title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  color: #71717a;
  margin-bottom: 6px;
}

.formula-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.formula-key {
  color: #a1a1aa;
}

.formula-val {
  color: #e5e7eb;
  text-align: right;
}

.pendulum-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pendulum-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pendulum-card {
  border: 1px solid #2a2b31;
  border-radius: 10px;
  padding: 10px;
  background: #141418;
}

.pendulum-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.pendulum-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a1a1aa;
}

.pendulum-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pendulum-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #a1a1aa;
}

.pendulum-toggle input {
  accent-color: #ef4444;
}

.pendulum-delete {
  border: 1px solid #2a2b31;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  color: #ef4444;
  background: transparent;
}

.pendulum-delete:hover {
  background: #2a2b31;
}

.pendulum-controls {
  display: grid;
  gap: 10px;
}

.harmonograph-plotter {
  border: 1px solid #2a2b31;
  border-radius: 10px;
  padding: 10px;
  background: #141418;
  display: grid;
  gap: 8px;
}

.harmonograph-plotter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.harmonograph-plotter-canvas {
  width: 100%;
  max-width: 240px;
  height: auto;
  border: 1px solid #2a2b31;
  border-radius: 8px;
  background: #101115;
}

.harmonograph-plotter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.harmonograph-plotter-range {
  width: 100%;
}

@media (min-width: 640px) {
  .pendulum-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.noise-controls {
  display: grid;
  gap: 10px;
}

@media (min-width: 640px) {
  .noise-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.pendulum-disabled {
  opacity: 0.6;
}

.noise-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid #2a2b31;
  border-radius: 10px;
  padding: 12px;
  background: #141418;
}

.image-effects {
  margin-top: 8px;
  border: 1px dashed #2a2b31;
  border-radius: 8px;
  padding: 8px;
  background: #101014;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  grid-column: 1 / -1;
}

.image-effects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-effect-card {
  border: 1px solid #24252b;
  border-radius: 8px;
  padding: 8px;
  background: #0f0f12;
  width: 100%;
}

.image-effect-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.image-effect-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a1a1aa;
}

.image-effect-card.dragging {
  opacity: 0.6;
  transform: translateY(-2px);
}

.image-effect-drop-indicator {
  height: 2px;
  border-radius: 999px;
  background: #fafafa;
  margin: 4px 0;
}

.noise-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.noise-card {
  border: 1px solid #2a2b31;
  border-radius: 10px;
  padding: 10px;
  background: #121214;
}

.noise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.noise-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a1a1aa;
}

.noise-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.noise-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #a1a1aa;
}

.noise-toggle input {
  accent-color: #ef4444;
}

.noise-delete {
  border: 1px solid #2a2b31;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  color: #ef4444;
  background: transparent;
}

.noise-delete:hover {
  background: #2a2b31;
}

.noise-grip {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.noise-grip .dot {
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: #71717a;
}

.noise-grip:active {
  cursor: grabbing;
}

.noise-card.dragging {
  opacity: 0.6;
  transform: translateY(-2px);
}

.noise-drop-indicator {
  height: 2px;
  border-radius: 999px;
  background: #fafafa;
  margin: 4px 0;
}

.noise-image-block {
  grid-column: 1 / -1;
}

.noise-disabled {
  opacity: 0.6;
}

.angle-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid #2a2b31;
  display: inline-block;
}

.color-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-modal-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-modal-input {
  width: 56px;
  height: 40px;
  border: 1px solid #2a2b31;
  background: transparent;
}

.color-modal-hex {
  flex: 1;
  background: #0f0f12;
  border: 1px solid #2a2b31;
  color: #e5e7eb;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.color-modal-preview {
  height: 32px;
  border-radius: 6px;
  border: 1px solid #2a2b31;
}

.color-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.color-modal-actions button {
  border: 1px solid #2a2b31;
  background: #0f0f12;
  color: #e5e7eb;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.color-modal-actions button:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.pane {
  width: var(--pane-left-width);
  flex: 0 0 auto;
  transition: width 0.2s ease;
  overflow: hidden;
}

.pane-header {
  position: relative;
}

.pane-header-left {
  padding-right: 48px;
}

.pane-header-right {
  padding-left: 48px;
}

.pane-header-left .pane-meta {
  margin-right: 32px;
}

.pane-header-right .pane-title {
  margin-left: 24px;
}

.pane-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 1px solid #27272a;
  border-radius: 9999px;
  background: #09090b;
  color: #a1a1aa;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pane-toggle:hover {
  color: #fafafa;
  border-color: #fafafa;
}

.pane-toggle-left {
  right: 8px;
}

.pane-toggle-right {
  left: 8px;
}

.pane-toggle-bottom {
  right: 12px;
}

.pane-left {
  width: var(--pane-left-width);
}

.pane-right {
  width: var(--pane-right-width);
}

.pane-body {
  min-height: 0;
}

.right-panel-section-scroll {
  min-height: 0;
}

#pens-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(34vh, 300px);
  overflow: hidden;
}

#pens-global-section {
  margin: 0;
  padding-top: 0;
  border-top: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#pens-global-section.collapsed {
  flex: 0 0 auto;
}

#pens-section-body {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#pen-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.pane-collapsed {
  width: var(--pane-collapsed-width);
}

.auto-collapsed .pane:not(.pane-force-open) {
  width: var(--pane-collapsed-width);
}

.pane-collapsed .pane-body,
.auto-collapsed .pane:not(.pane-force-open) .pane-body {
  display: none;
}

.pane-collapsed .pane-title,
.pane-collapsed .pane-meta,
.auto-collapsed .pane:not(.pane-force-open) .pane-title,
.auto-collapsed .pane:not(.pane-force-open) .pane-meta {
  display: none;
}

.pane-collapsed .pane-header button:not(.pane-toggle),
.auto-collapsed .pane:not(.pane-force-open) .pane-header button:not(.pane-toggle) {
  display: none;
}

.pane-collapsed .pane-toggle,
.auto-collapsed .pane:not(.pane-force-open) .pane-toggle {
  transform: translateY(-50%) rotate(90deg);
}

.pane-resizer {
  width: 6px;
  flex: 0 0 auto;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 15;
}

.pane-resizer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #18181b;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pane-resizer:hover::before,
.pane-resizer.active::before {
  opacity: 0.6;
}

.bottom-pane {
  height: var(--bottom-pane-height);
  transition: height 0.2s ease;
  overflow: hidden;
  position: relative;
}

.bottom-pane-header {
  position: relative;
  padding-right: 48px;
}

.bottom-pane-footer {
  margin-top: auto;
}

.bottom-pane-collapsed {
  height: 36px;
}

.bottom-pane-collapsed .bottom-pane-body,
.bottom-pane-collapsed .bottom-pane-footer {
  display: none;
}

.bottom-pane-collapsed .pane-toggle-bottom {
  transform: translateY(-50%) rotate(90deg);
}

.bottom-resizer {
  height: 6px;
  cursor: row-resize;
  background: transparent;
  position: relative;
  z-index: 25;
}

.bottom-resizer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #18181b;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.bottom-resizer:hover::before,
.bottom-resizer.active::before {
  opacity: 0.6;
}

.layer-grip {
  width: 14px;
  color: #71717a;
  cursor: grab;
  font-size: 10px;
  letter-spacing: 1px;
  user-select: none;
}

.layer-item.dragging {
  opacity: 0.6;
  transform: translateY(-2px);
}

.layer-drop-indicator {
  height: 2px;
  background: #fafafa;
  margin: 6px 0;
  border-radius: 9999px;
}

#algo-sticky {
  background: #18181b;
}

.dual-range {
  position: relative;
  height: 20px;
}

.dual-range input[type='range'] {
  position: absolute;
  left: 0;
  top: 8px;
  width: 100%;
  margin: 0;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 9, 11, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

#modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(560px, calc(100% - 32px));
  max-height: 80vh;
  overflow: auto;
  background: #18181b;
  border: 1px solid #27272a;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #fafafa;
}

.modal-close {
  border: 1px solid #27272a;
  background: #09090b;
  color: #71717a;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  cursor: pointer;
}

.modal-close:hover {
  color: #fafafa;
  border-color: #fafafa;
}

.modal-text {
  font-size: 12px;
  line-height: 1.6;
  color: #a1a1aa;
  margin-bottom: 12px;
}

.modal-illustrations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-illustrations.scrollable {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.modal-illustration {
  border: 1px solid #27272a;
  padding: 10px;
  background: #09090b;
}

.modal-illustration svg {
  width: 100%;
  height: auto;
  display: block;
}

.modal-ill-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #71717a;
  margin-bottom: 6px;
}

.modal-ill-desc {
  font-size: 10px;
  line-height: 1.4;
  color: #9ca3af;
  margin-bottom: 8px;
}

.modal-section {
  margin-bottom: 16px;
}

.petal-designer-window {
  position: fixed;
  z-index: 95;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid #334155;
  border-radius: 14px;
  background-color: #0b121a;
  background-image:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 48%),
    linear-gradient(rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.95)),
    linear-gradient(0deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: auto, auto, 20px 20px, 20px 20px;
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(2px);
}

.petal-designer-window.dragging {
  cursor: grabbing;
}

.petal-designer-inline-wrap {
  width: 100%;
}

.petal-designer-inline {
  position: relative;
  left: auto !important;
  top: auto !important;
  width: 100%;
  max-height: none;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.45);
}

.petal-designer-inline .petal-designer-header {
  cursor: default;
  position: static;
}

.petal-designer-inline.focused {
  border-color: #22d3ee;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.55), 0 14px 34px rgba(2, 6, 23, 0.45);
}

.petal-designer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #334155;
  background: rgba(8, 13, 21, 0.86);
  cursor: grab;
  position: sticky;
  top: 0;
  z-index: 2;
  touch-action: none;
}

.petal-designer-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #bae6fd;
}

.petal-designer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.petal-tool-btn,
.petal-close,
.petal-popout,
.petal-popin,
.petal-copy-btn {
  border: 1px solid #334155;
  background: #0f172a;
  color: #cbd5e1;
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1;
  padding: 0 8px;
}

.petal-tool-btn:hover,
.petal-close:hover,
.petal-popout:hover,
.petal-popin:hover,
.petal-copy-btn:hover {
  border-color: #67e8f9;
  color: #cffafe;
}

.petal-tool-btn.active {
  border-color: #22d3ee;
  color: #22d3ee;
  background: rgba(34, 211, 238, 0.12);
}

.petal-designer-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid #334155;
  background: rgba(8, 13, 21, 0.74);
}

.petal-designer-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
}

.petal-designer-controls select {
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  padding: 6px 8px;
  font-size: 11px;
}

.petal-shade-toggle {
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start;
  align-self: center;
}

.petal-shade-toggle input {
  accent-color: #22d3ee;
}

.petal-designer-structure {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 10px 12px;
  border-bottom: 1px solid #334155;
  background: rgba(8, 13, 21, 0.68);
}

.petal-designer-structure label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
}

.petal-designer-structure select {
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  padding: 6px 8px;
  font-size: 11px;
}

.petal-designer-transition {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
  padding: 10px 12px;
  border-bottom: 1px solid #334155;
  background: rgba(8, 13, 21, 0.62);
}

.petal-designer-transition label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
}

.petal-transition-lock {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  align-self: center;
}

.petal-transition-lock input {
  accent-color: #22d3ee;
}

.petal-designer-transition input[type='range'] {
  width: 100%;
}

.petal-designer-visualizer {
  padding: 12px;
  border-top: 1px solid #334155;
  background: rgba(8, 13, 21, 0.62);
}

.petal-visualizer-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
}

.petal-visualizer-mode select {
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  padding: 6px 8px;
  font-size: 11px;
}

.petal-designer-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.petal-designer-grid.is-side-by-side {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.petal-cell {
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.petal-cell-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
}

.petal-cell canvas {
  width: 100%;
  max-width: 100%;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  display: block;
  touch-action: none;
}

.petal-designer-profile-editor {
  padding: 12px;
  border-top: 1px solid #334155;
  background: rgba(8, 13, 21, 0.62);
}

.petal-profile-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.petal-profile-editor-card {
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.72);
  display: grid;
  gap: 8px;
  cursor: pointer;
}

.petal-profile-editor-card.is-active {
  border-color: #22d3ee;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.3);
}

.petal-profile-editor-card-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
}

.petal-profile-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.petal-profile-editor-footer {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.petal-designer-shading {
  padding: 12px;
  border-top: 1px solid #334155;
  background: rgba(8, 13, 21, 0.62);
}

.petal-designer-shading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.petal-designer-shading-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
}

.petal-designer-shading-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.petal-designer-randomness {
  margin: 0 12px 12px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: rgba(8, 13, 21, 0.62);
}

.petal-designer-randomness summary {
  padding: 10px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
  cursor: pointer;
  list-style: none;
}

.petal-designer-randomness summary::-webkit-details-marker {
  display: none;
}

.petal-designer-randomness-stack {
  padding: 0 12px 12px;
  display: grid;
  gap: 8px;
}

.petal-slider-label {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'label value'
    'input input';
  align-items: center;
  gap: 5px 8px !important;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
}

.petal-slider-label > span:first-child {
  grid-area: label;
}

.petal-slider-label .petal-slider-value {
  grid-area: value;
  font-size: 10px;
  color: #67e8f9;
  font-variant-numeric: tabular-nums;
}

.petal-slider-label > input,
.petal-slider-label > select {
  grid-area: input;
}

.petal-slider-label > select {
  border: 1px solid #334155;
  background: #020617;
  color: #e2e8f0;
  padding: 6px 8px;
  font-size: 11px;
}

.petal-shade-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.petal-shade-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: #94a3b8;
}

@media (max-width: 900px) {
  .petal-designer-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .petal-designer-structure {
    grid-template-columns: 1fr;
  }

  .petal-designer-transition {
    grid-template-columns: 1fr;
  }

  .petal-designer-grid.is-side-by-side {
    grid-template-columns: 1fr;
  }

  .petal-shade-controls {
    grid-template-columns: 1fr;
  }

  .petal-profile-editor-grid {
    grid-template-columns: 1fr;
  }
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid #27272a;
  border-radius: 9999px;
  margin-left: 6px;
  font-size: 10px;
  line-height: 1;
  color: #71717a;
  background: #18181b;
  cursor: pointer;
  vertical-align: middle;
}

.info-btn:hover {
  color: #fafafa;
  border-color: #fafafa;
}

.settings-panel {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--pane-left-width);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 40;
  pointer-events: none;
}

.mobile-layout .settings-panel {
  z-index: 90;
}

.settings-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

#app-header {
  position: relative;
  z-index: 220;
  overflow: visible;
}

.header-main {
  min-height: 30px;
  overflow: visible;
}

.header-brand-menu {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
}

.header-menu-divider {
  width: 1px;
  height: 20px;
  margin-left: 8px;
  margin-right: 6px;
  background: #27272a;
  flex: 0 0 auto;
}

.top-menubar {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
  overflow: visible;
  white-space: nowrap;
  margin-left: 2px;
  position: relative;
  z-index: 260;
}

.top-menu {
  position: relative;
  flex: 0 0 auto;
}

.top-menu-trigger {
  border: 1px solid #27272a;
  background: #0f0f12;
  color: #d4d4d8;
  padding: 5px 9px;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.top-menu-trigger::after {
  content: '▾';
  font-size: 9px;
  color: #71717a;
}

.top-menu-trigger:hover,
.top-menu-trigger:focus-visible,
.top-menu-trigger.open {
  border-color: #fafafa;
  color: #fafafa;
  background: #18181b;
  outline: none;
}

.top-menu-trigger:hover::after,
.top-menu-trigger:focus-visible::after,
.top-menu-trigger.open::after {
  color: #fafafa;
}

.top-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 228px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid #27272a;
  background: #09090b;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45);
  z-index: 1400;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.top-menu-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.top-menu-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #a1a1aa;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  line-height: 1.3;
  padding: 7px 8px;
}

.top-menu-shortcut {
  color: #71717a;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.top-menu-item:hover,
.top-menu-item:focus-visible {
  border-color: #3f3f46;
  background: #18181b;
  color: #fafafa;
  outline: none;
}

.top-menu-item:hover .top-menu-shortcut,
.top-menu-item:focus-visible .top-menu-shortcut {
  color: #d4d4d8;
}

.top-menu-item-primary {
  color: #fafafa;
}

.optimization-overlay-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 220px;
  border: 1px solid #27272a;
  background: rgba(9, 9, 11, 0.94);
  padding: 8px 10px;
  z-index: 60;
  pointer-events: none;
}

.optimization-overlay-legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a1a1aa;
  margin-bottom: 6px;
}

.optimization-overlay-legend-gradient {
  height: 8px;
  border: 1px solid #3f3f46;
  margin-bottom: 4px;
}

.optimization-overlay-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #a1a1aa;
}

.color-thickness-control {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(130px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.color-thickness-pill {
  min-height: 24px;
  color: #09090b;
  width: 100%;
  text-align: center;
  border-radius: 9999px;
  overflow: hidden;
}

.color-thickness-size {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.line-style-control {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(150px, 1fr) minmax(86px, auto) auto;
  gap: 8px;
  align-items: end;
}

.style-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.style-field-label {
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #71717a;
}

.style-field > .color-thickness-pill,
.style-field > input[type='number'],
.style-field > button,
.style-field > .color-thickness-size {
  min-height: 24px;
}

@media (max-width: 1024px) {
  .tool-bar {
    top: 12px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    max-width: calc(100vw - 24px);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
  }

  .tool-group {
    flex-direction: row;
  }

  .tool-submenu {
    left: 0;
    top: -44px;
    flex-direction: row;
  }

  .touch-modifier-bar {
    left: 50%;
    top: 66px;
    bottom: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
    justify-content: center;
  }

  .bottom-pane {
    height: min(40vh, 260px);
  }
}

@media (max-width: 900px) {
  :root {
    --pane-left-width: min(88vw, 340px);
    --pane-right-width: min(88vw, 340px);
    --pane-collapsed-width: 40px;
  }

  #app-header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .header-main {
    align-items: flex-start;
  }

  .top-menubar {
    gap: 10px;
    padding-top: 0;
  }

  .pane-resizer,
  .bottom-resizer {
    display: none;
  }

  .mobile-pane-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-layout .pane {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 45;
    max-width: calc(100vw - 18px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  }

  .mobile-layout .pane-left {
    left: 0;
    border-right-width: 1px;
  }

  .mobile-layout .pane-right {
    right: 0;
    border-left-width: 1px;
  }

  .mobile-layout .right-panel-section-scroll {
    max-height: min(22vh, 180px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-layout .right-panel-section-primary {
    max-height: min(42vh, 320px);
  }

  .mobile-layout #pens-section {
    max-height: min(26vh, 220px);
  }

  .mobile-layout .auto-collapsed .pane:not(.pane-force-open),
  .mobile-layout .pane.pane-collapsed {
    width: var(--pane-collapsed-width);
    box-shadow: none;
  }
}

@media (max-width: 640px) {
  .header-menu-divider {
    margin-left: 4px;
    margin-right: 2px;
  }

  #status-bar {
    display: none;
  }

  .top-menu-trigger {
    font-size: 10px;
    padding: 5px 7px;
  }

  .top-menu-item {
    font-size: 10px;
    padding: 7px;
  }
}
.layer-grip:active {
  cursor: grabbing;
}

.palette-toggle {
  font-size: 10px;
  padding: 4px 8px;
  border: 1px solid #27272a;
  color: #a1a1aa;
  background: #09090b;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.palette-toggle:hover {
  color: #fafafa;
  border-color: #fafafa;
}

.palette-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  width: 220px;
  background: #09090b;
  border: 1px solid #27272a;
  padding: 8px;
  z-index: 30;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.palette-search {
  width: 100%;
  background: #18181b;
  border: 1px solid #27272a;
  padding: 6px 8px;
  font-size: 10px;
  color: #e4e4e7;
  margin-bottom: 8px;
}

.palette-options {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.palette-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid transparent;
  font-size: 10px;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.palette-option:hover,
.palette-option.active {
  border-color: #fafafa;
  color: #fafafa;
}

.palette-swatch {
  display: grid;
  grid-template-columns: repeat(5, 8px);
  gap: 2px;
}

.palette-swatch span {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: block;
}

.pen-remove {
  border: 1px solid #27272a;
  background: #09090b;
  color: #71717a;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.pen-remove:hover {
  color: #fafafa;
  border-color: #fafafa;
}

.noise-dropzone {
  border: 1px dashed #3f3f46;
  background: #0f0f12;
  color: #a1a1aa;
  font-size: 12px;
  padding: 24px 12px;
  text-align: center;
  border-radius: 10px;
}

.noise-dropzone.active {
  border-color: #fafafa;
  color: #fafafa;
}

.angle-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-inline-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.control-inline-item,
.angle-item {
  margin-bottom: 0;
}

.control-inline-row .control-inline-item:last-child input[type='checkbox'] {
  margin-top: 6px;
}

.masking-controls {
  margin-bottom: 16px;
  border: 1px solid #27272a;
  background: rgba(9, 9, 11, 0.72);
}

.masking-controls__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #e4e4e7;
}

.masking-controls__summary::-webkit-details-marker {
  display: none;
}

.masking-controls__body {
  padding: 0 12px 12px;
}

@media (max-width: 900px) {
  .control-inline-row {
    grid-template-columns: 1fr;
  }
}

.angle-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.angle-dial {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid #2a2b31;
  background: #141418;
  cursor: pointer;
  flex-shrink: 0;
}

.angle-dial:hover {
  border-color: #3f3f46;
}

.angle-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: rotate(var(--angle));
  transform-origin: center center;
}

.angle-indicator::before {
  content: '';
  position: absolute;
  width: 2px;
  height: 20px;
  background: #ef4444;
  border-radius: 999px;
  transform: translate(-1px, -20px);
}

.angle-indicator::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 999px;
  transform: translate(-3px, -28px);
}

.inline-value-input {
  position: absolute;
  z-index: 10;
  background: #0f0f12;
  border: 1px solid #2a2b31;
  color: #ef4444;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  padding: 2px 6px;
  text-align: right;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.global-section {
  margin: 1.5rem 0 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #27272a;
}

.global-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  padding: 0 0 0.5rem;
  cursor: pointer;
  text-align: left;
}

.global-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a1a1aa;
}

.global-section-toggle {
  width: 14px;
  height: 14px;
  position: relative;
  display: inline-block;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.global-section-toggle::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 3px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent #a1a1aa;
}

.global-section.collapsed .global-section-toggle {
  transform: rotate(0deg);
}

.global-section-body {
  padding-top: 0.25rem;
}

.optimization-panel {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #27272a;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.optimization-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.optimization-row .control-label {
  margin-bottom: 0;
  font-size: 0.65rem;
}

.optimization-overlay {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.optimization-actions {
  display: flex;
  justify-content: flex-end;
}

.opt-reset {
  width: 100%;
  font-size: 0.65rem;
  border: 1px solid #27272a;
  padding: 0.4rem 0.5rem;
  color: #e4e4e7;
  background: transparent;
  cursor: pointer;
}

.opt-reset:hover {
  background: #27272a;
}

.optimization-stats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.optimization-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.optimization-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.optimization-card {
  border: 1px solid #27272a;
  padding: 0.5rem;
  background: #0f0f12;
}

.optimization-card.dragging {
  opacity: 0.6;
}

.optimization-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.optimization-card-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: #e4e4e7;
}

.optimization-card-actions {
  display: flex;
  gap: 0.5rem;
  font-size: 0.6rem;
  color: #a1a1aa;
}

.opt-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.optimization-grip {
  background: transparent;
  border: none;
  display: grid;
  grid-template-columns: repeat(2, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.optimization-grip .dot {
  width: 3px;
  height: 3px;
  background: #52525b;
  border-radius: 999px;
}

.optimization-grip:active {
  cursor: grabbing;
}

.optimization-drop-indicator {
  height: 4px;
  border-radius: 999px;
  background: #38bdf8;
  opacity: 0.8;
  margin: 2px 0;
}

.optimization-controls.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.noise-image-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.noise-image-left {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 120px;
}

.noise-image-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.noise-image-preview {
  width: 200px;
  height: 200px;
  border: 1px solid #27272a;
  border-radius: 6px;
  background: #111114;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.noise-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.noise-image-clear {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
}

.noise-image-preview.active {
  border-color: #fafafa;
}

.noise-dropzone.compact {
  min-height: 64px;
  font-size: 10px;
  padding: 10px;
}

.layer-name-input,
.pen-name-input {
  user-select: text;
}
