:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f7f7f8;
  background: #111216;
  font-synthesis: none;
  --orange: #ff7a1a;
  --panel: #1a1c22;
  --panel-2: #23262e;
  --line: #323640;
  --muted: #a6abb7;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; min-height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: radial-gradient(circle at 20% -20%, rgba(255, 122, 26, .15), transparent 35%), #111216;
}
button, input, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  color: #f6f6f7;
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  transition: .16s ease;
}
button:hover { border-color: #555b69; transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.primary { border-color: var(--orange); background: var(--orange); color: #1d0e02; font-weight: 800; }
button.accent { border-color: rgba(255, 122, 26, .7); background: rgba(255, 122, 26, .15); color: #ffb27a; }
button.ghost { background: transparent; }

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(19, 20, 25, .92);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px;
  color: #211004; background: linear-gradient(145deg, #ffae70, var(--orange)); font-weight: 950; font-size: 21px;
}
.brand div:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.brand span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.top-actions { display: flex; gap: 8px; }

.workspace { height: calc(100vh - 64px); display: grid; grid-template-columns: 84px minmax(0, 1fr) 300px; }
.leftbar {
  border-right: 1px solid var(--line); background: rgba(24, 26, 32, .96); padding: 12px 8px;
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
}
.tool {
  min-height: 63px; padding: 8px 3px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; background: transparent;
}
.tool span { font-size: 21px; line-height: 1; }
.tool small { font-size: 10px; color: #c6cad3; }
.tool.active { border-color: rgba(255, 122, 26, .75); background: rgba(255, 122, 26, .14); }

.stage-area { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) 42px; }
.drop-zone {
  min-width: 0; min-height: 0; padding: 22px; display: flex; align-items: center; justify-content: center;
  overflow: auto; position: relative;
}
.drop-zone.dragover::after {
  content: "Suelta la imagen"; position: absolute; inset: 18px; display: grid; place-items: center;
  border: 2px dashed var(--orange); border-radius: 18px; background: rgba(12, 13, 16, .82);
  color: #ffc69c; font-size: 24px; font-weight: 800; z-index: 20;
}

.canvas-container {
  flex: 0 0 auto;
  position: relative !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .38);
  background-color: white;
  background-image:
    linear-gradient(45deg, #dedede 25%, transparent 25%),
    linear-gradient(-45deg, #dedede 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dedede 75%),
    linear-gradient(-45deg, transparent 75%, #dedede 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  transform-origin: center center;
  border-radius: 3px;
  overflow: hidden;
}
.canvas-container > canvas { width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; }
.mask-canvas { position: absolute; inset: 0; z-index: 5; pointer-events: none; touch-action: none; }
.mask-canvas.enabled { pointer-events: auto; cursor: crosshair; }

.empty-state {
  position: absolute; z-index: 8; width: min(440px, calc(100% - 40px)); text-align: center; padding: 38px;
  border: 1px solid var(--line); border-radius: 20px; background: rgba(26, 28, 34, .93); box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.empty-state.hidden { display: none; }
.empty-state h1 { margin: 10px 0 5px; font-size: 28px; }
.empty-state p { margin: 0 0 20px; color: var(--muted); }
.upload-icon { font-size: 54px; }

.statusbar {
  border-top: 1px solid var(--line); background: var(--panel); display: flex; align-items: center;
  justify-content: space-between; padding: 0 14px; color: var(--muted); font-size: 12px;
}
.zoom-controls { display: flex; align-items: center; gap: 7px; }
.zoom-controls button { padding: 4px 8px; border-radius: 7px; }
.zoom-controls span { min-width: 60px; text-align: center; }

.rightbar { border-left: 1px solid var(--line); background: rgba(24, 26, 32, .98); overflow-y: auto; padding-bottom: 26px; }
.panel { padding: 17px; border-bottom: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; }
.panel h3 { margin: 0 0 13px; font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: #f1f2f5; }
.panel-heading h3 { margin-bottom: 0; }
.badge { font-size: 10px; color: #ffbd8c; border: 1px solid rgba(255,122,26,.35); background: rgba(255,122,26,.1); border-radius: 99px; padding: 4px 7px; }
.panel label { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 5px; color: #d4d7de; font-size: 12px; }
.panel output { color: #ffb27a; }
.panel input[type="range"] { width: 100%; accent-color: var(--orange); }
.panel textarea {
  width: 100%; resize: vertical; min-height: 72px; color: #f6f6f7; background: #111318;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; outline: none;
}
.panel textarea:focus { border-color: rgba(255,122,26,.75); box-shadow: 0 0 0 3px rgba(255,122,26,.1); }
.color-row input { width: 44px; height: 28px; padding: 0; border: none; background: transparent; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
.wide { width: 100%; margin-top: 8px; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.5; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 100;
  background: #2a2d35; border: 1px solid #434855; padding: 11px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading {
  position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; justify-items: center;
  gap: 16px; background: rgba(10, 11, 14, .75); backdrop-filter: blur(7px);
}
.loading.hidden { display: none; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  body { overflow: auto; }
  .workspace { height: auto; min-height: calc(100vh - 64px); grid-template-columns: 66px minmax(0, 1fr); }
  .rightbar { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { border-right: 1px solid var(--line); }
  .leftbar, .stage-area { min-height: 620px; }
  .top-actions .ghost { display: none; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 10px; }
  .brand span { display: none; }
  .top-actions .primary { padding: 8px; font-size: 12px; }
  .workspace { grid-template-columns: 58px minmax(0, 1fr); }
  .tool { min-height: 56px; }
  .tool small { display: none; }
  .drop-zone { padding: 8px; }
  .stage-area, .leftbar { min-height: 500px; }
  .rightbar { grid-template-columns: 1fr; }
  .panel { border-right: 0; }
}
