/* ==========================================================================
   1. Design tokens y reset
   ========================================================================== */

:root {
  font-family: Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color: #f5f7fa;
  background: #101114;
  font-synthesis: none;
  --bg: #101114;
  --panel: #17191e;
  --panel2: #1c1f25;
  --line: #2a2e36;
  --muted: #9ba3b2;
  --text: #f4f6f8;
  --accent: #8be06b;
  --accent2: #6dcc50;
  --danger: #ff8d77;
}

* {
  box-sizing: border-box;
}

html,body,#root {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

button,input,label {
  font: inherit;
}

.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ==========================================================================
   2. Barra superior y marca PIXEL ZERO
   ========================================================================== */

.topbar {
  height: 60px;
  flex: 0 0 60px;
  background: #14161a;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg,#a1ef82,#5eb942);
  color: #0f1a0c;
  box-shadow: 0 0 28px rgba(139,224,107,.12);
}

.brand strong {
  font-size: 14px;
  display: block;
  letter-spacing: -.01em;
}

.brand span {
  display: block;
  color: #747d8d;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .11em;
  margin-top: 1px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-btn,
.tool-btn,
.zoom-controls button,
.preview-switcher button,
.button-grid button,
.text-button,
.panel-toggle,
.format-tabs button {
  border: 0;
  color: var(--text);
  cursor: pointer;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: transparent;
  display: grid;
  place-items: center;
}

.icon-btn:hover:not(:disabled) {
  background: #22252b;
}

.icon-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 3px;
}

.button {
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #101810;
}

.button.primary:hover:not(:disabled) {
  background: #9aed7d;
}

.button.secondary {
  background: #1b1e23;
  color: var(--text);
}

.button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.wide {
  width: 100%;
}

.dropzone input {
  display: none;
}

.new-image-button {
  white-space: nowrap;
}

/* ==========================================================================
   3. Layout principal y barra de herramientas
   ========================================================================== */

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 68px minmax(0,1fr) 310px;
}

.toolbar {
  background: #14161a;
  border-right: 1px solid var(--line);
  padding: 10px 7px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 12;
}

.tool-btn {
  width: 54px;
  min-height: 53px;
  border-radius: 11px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #aeb5c1;
}

.tool-btn svg {
  width: 19px;
}

.tool-btn span {
  font-size: 9px;
}

.tool-btn:hover {
  background: #202329;
}

.tool-btn.active {
  background: rgba(139,224,107,.12);
  color: var(--accent);
  outline: 1px solid rgba(139,224,107,.15);
}

.tool-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 7px;
}

/* ==========================================================================
   4. Canvas, carga inicial y controles de vista
   ========================================================================== */

.canvas-area {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #1d1f23;
}

.editor-canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.tool-pan {
  cursor: grab;
}

.tool-pan:active {
  cursor: grabbing;
}

.tool-remove,.tool-keep {
  cursor: crosshair;
}

.tool-wand {
  cursor: cell;
}

.empty-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 4;
  padding: 24px;
}

.dropzone {
  width: min(540px,92%);
  min-height: 330px;
  border: 1px dashed #414650;
  border-radius: 24px;
  background: radial-gradient(circle at 50% 0%,rgba(139,224,107,.08),transparent 38%),#17191d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 42px;
  cursor: pointer;
  transition: .2s;
}

.dropzone:hover,.dropzone.drag {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 16px 60px rgba(0,0,0,.22);
}

.drop-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: #24282e;
  display: grid;
  place-items: center;
  color: var(--accent);
  margin-bottom: 15px;
}

.dropzone h1 {
  font-size: 28px;
  letter-spacing: -.04em;
  margin: 0 0 8px;
}

.dropzone p {
  color: var(--muted);
  margin: 0 0 22px;
  max-width: 360px;
  line-height: 1.5;
}

.dropzone small {
  color: #737c8b;
  margin-top: 14px;
  font-size: 11px;
}

.preview-switcher {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: rgba(19,21,25,.9);
  border: 1px solid #31353d;
  padding: 3px;
  border-radius: 11px;
  backdrop-filter: blur(10px);
  z-index: 5;
}

.preview-switcher button {
  background: transparent;
  color: #8f98a7;
  font-size: 11px;
  padding: 7px 10px;
  border-radius: 8px;
}

.preview-switcher button.active {
  background: #292d34;
  color: #fff;
}

.zoom-controls {
  position: absolute;
  left: 14px;
  bottom: 14px;
  background: rgba(19,21,25,.92);
  border: 1px solid #31353d;
  border-radius: 11px;
  padding: 3px;
  display: flex;
  align-items: center;
  z-index: 5;
}

.zoom-controls button {
  width: 31px;
  height: 31px;
  background: transparent;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.zoom-controls button:hover {
  background: #292d34;
}

.zoom-controls span {
  font-size: 10px;
  color: #b2bac6;
  width: 46px;
  text-align: center;
}

.processing-chip {
  position: absolute;
  right: 14px;
  bottom: 14px;
  background: #15171b;
  border: 1px solid #31353d;
  border-radius: 10px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: #dce2ea;
  z-index: 6;
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }

}

/* ==========================================================================
   5. Panel de ajustes y refinamiento
   ========================================================================== */

.properties {
  position: relative;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-width: 0;
  z-index: 11;
  transition: width .18s;
}

.properties.closed {
  width: 40px;
}

.properties.open {
  width: 310px;
}

.panel-toggle {
  position: absolute;
  left: -34px;
  top: 10px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #17191e;
  border: 1px solid #31353d;
  display: grid;
  place-items: center;
}

.properties-inner {
  height: 100%;
  overflow: auto;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head span {
  font-size: 15px;
  font-weight: 750;
}

.panel-head small {
  font-size: 9px;
  color: #737c8a;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.panel-section {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.panel-section.prominent {
  border: 1px solid #30363b;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(145deg,rgba(139,224,107,.06),rgba(139,224,107,.01));
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 720;
  margin-bottom: 8px;
}

.panel-section p {
  font-size: 11px;
  color: #8e97a5;
  line-height: 1.5;
  margin: 0 0 12px;
}

.range-control {
  margin: 0 0 16px;
}

.range-control > div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
}

.range-control label {
  font-size: 11px;
  color: #c9ced6;
}

.range-control output {
  font-size: 10px;
  color: #8992a1;
}

.range-control input {
  width: 100%;
  accent-color: var(--accent);
  height: 4px;
}

.check-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  cursor: pointer;
}

.check-row input {
  accent-color: var(--accent);
  margin-top: 3px;
}

.check-row strong,
.check-row small {
  display: block;
}

.check-row strong {
  font-size: 11px;
}

.check-row small {
  font-size: 9px;
  color: #7f8896;
  margin-top: 3px;
  line-height: 1.35;
}

/* Refinamiento principal: una acción frecuente y opciones avanzadas plegadas. */
.refine-primary,
.advanced-action {
  width: 100%;
  background: #22252b;
  border: 1px solid #30343c;
  color: var(--text);
  border-radius: 9px;
  padding: 10px 9px;
  font-size: 10px;
  cursor: pointer;
}

.refine-primary:hover:not(:disabled),
.advanced-action:hover:not(:disabled) {
  border-color: #4d535e;
  background: #282c33;
}

.refine-primary:disabled,
.advanced-action:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.advanced-settings {
  margin-top: 10px;
  border: 1px solid #2e333b;
  border-radius: 11px;
  background: #15171b;
  overflow: hidden;
}

.advanced-settings summary {
  list-style: none;
  cursor: pointer;
  color: #a8b0bc;
  font-size: 10px;
  padding: 10px 11px;
  user-select: none;
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 7px;
  transition: transform .16s ease;
}

.advanced-settings[open] summary::before {
  transform: rotate(90deg);
}

.advanced-content {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
  border-top: 1px solid #252930;
}

.edge-adjust-control {
  padding-top: 10px;
  margin-bottom: 0;
}

.edge-adjust-control small {
  display: block;
  color: #77818f;
  font-size: 9px;
  line-height: 1.35;
  margin-top: 5px;
}

.danger-subtle {
  color: #d9dde4;
}

.text-button {
  background: none;
  color: #8a93a1;
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 12px auto;
}

.text-button:hover:not(:disabled) {
  color: #fff;
}

.text-button:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.document-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

.document-actions .text-button {
  margin: 12px 0 0;
}

/* Avisos breves. Sustituyen al antiguo bloque de Estado del panel lateral. */
.status-toast {
  position: absolute;
  right: 14px;
  bottom: 14px;
  max-width: min(390px, calc(100% - 28px));
  padding: 10px 12px;
  border: 1px solid #343941;
  border-radius: 11px;
  background: rgba(19,21,25,.94);
  box-shadow: 0 12px 35px rgba(0,0,0,.28);
  color: #c8ced7;
  font-size: 10px;
  line-height: 1.4;
  z-index: 7;
  backdrop-filter: blur(10px);
}

/* ==========================================================================
   6. Exportación
   ========================================================================== */

.export-wrap {
  position: relative;
}

.export-popover {
  position: absolute;
  right: 0;
  top: 43px;
  width: 250px;
  background: #1b1e23;
  border: 1px solid #343942;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.38);
  z-index: 50;
}

.export-popover > strong {
  font-size: 12px;
}

.format-tabs {
  display: flex;
  gap: 5px;
  margin: 12px 0;
}

.format-tabs button {
  flex: 1;
  background: #24282e;
  border: 1px solid #30353d;
  border-radius: 8px;
  padding: 7px;
  font-size: 10px;
  color: #969eaa;
}

.format-tabs button.active {
  color: #111;
  background: var(--accent);
  border-color: var(--accent);
}

.export-popover small {
  display: block;
  color: #7f8997;
  line-height: 1.4;
  font-size: 9px;
  margin: 10px 0 12px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #aab2bd;
}

.color-row input {
  width: 28px;
  height: 24px;
  border: 0;
  background: none;
  padding: 0;
}

.color-row span {
  font-family: ui-monospace,monospace;
  color: #7f8997;
}

/* ==========================================================================
   7. Responsive: tablet y móvil
   ========================================================================== */

@media (max-width: 850px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0,1fr) 68px;
  }

  .toolbar {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 7px;
    flex-direction: row;
    justify-content: center;
  }

  .tool-btn {
    width: 62px;
    min-height: 52px;
  }

  .tool-sep {
    width: 1px;
    height: 38px;
    margin: 7px 2px;
  }

  .canvas-area {
    order: 1;
  }

  .properties {
    position: absolute;
    right: 0;
    top: 60px;
    bottom: 68px;
    box-shadow: -12px 0 40px rgba(0,0,0,.26);
  }

  .properties.closed {
    width: 0;
    border: 0;
  }

  .properties.open {
    width: min(310px,86vw);
  }

  .panel-toggle {
    left: -38px;
  }

  .new-image-button {
    font-size: 12px;
    padding: 0 10px;
  }

  .preview-switcher {
    top: 10px;
    max-width: calc(100% - 24px);
  }

  .preview-switcher button {
    padding: 7px 8px;
  }

  .dropzone {
    min-height: 280px;
    padding: 28px 22px;
  }

  .dropzone h1 {
    font-size: 24px;
  }

  .brand span {
    display: none;
  }

}

@media (max-width: 520px) {
  .topbar {
    height: 56px;
    flex-basis: 56px;
    padding: 0 10px;
  }

  .workspace {
    grid-template-rows: minmax(0,1fr) 62px;
  }

  .properties {
    top: 56px;
    bottom: 62px;
  }

  .brand strong {
    font-size: 13px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
  }

  .top-actions .divider,
  .top-actions > .icon-btn {
    display: none;
  }

  .button {
    padding: 0 10px;
  }

  .new-image-button {
    font-size: 11px;
  }

  .toolbar {
    justify-content: space-around;
    padding: 4px;
  }

  .tool-btn {
    min-height: 52px;
    width: 58px;
  }

  .tool-btn span {
    font-size: 8px;
  }

  .preview-switcher {
    left: 10px;
    transform: none;
    overflow: auto;
  }

  .preview-switcher button {
    font-size: 9px;
  }

  .zoom-controls {
    left: 8px;
    bottom: 8px;
  }

  .processing-chip {
    right: 8px;
    bottom: 52px;
  }

  .status-toast {
    right: 8px;
    bottom: 52px;
    max-width: calc(100% - 16px);
  }

  .dropzone small {
    max-width: 240px;
  }

  .dropzone p {
    font-size: 13px;
  }

}

/* hidden debe ganar frente a cualquier display:flex/grid del componente. */
[hidden] {
  display: none!important;
}
