/* Krea - interfaz */
:root {
  --bg: #1f2124;
  --panel: #2b2e33;
  --panel2: #34383e;
  --line: #14161a;
  --line2: #454b53;
  --text: #dfe3e8;
  --text-dim: #9aa2ad;
  --accent: #2d8cf0;
  --accent2: #1c6fd0;
  --canvas-bg: #3d4147;
  --menu-h: 30px;
  --prop-h: 34px;
  --tool-w: 42px;
  --dock-w: 268px;
  --pal-w: 24px;
  --radius: 4px;
  --font: "Segoe UI", Roboto, system-ui, sans-serif;
}
body[data-ws="illustrator"] {
  --bg: #232323; --panel: #2c2c2c; --panel2: #383838; --line: #191919; --line2: #444;
  --canvas-bg: #4a4a4a; --accent: #ff9a00; --accent2: #d98200; --tool-w: 60px; --dock-w: 250px;
}
body[data-ws="canva"] {
  --bg: #ffffff; --panel: #ffffff; --panel2: #f4f5f7; --line: #e3e5e8; --line2: #d8dbe0;
  --text: #1f2430; --text-dim: #6b7280; --canvas-bg: #edeff2; --accent: #7d2ae8; --accent2: #6a1fc4;
  --dock-w: 300px; --menu-h: 46px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font: 12px/1.4 var(--font);
  background: var(--bg); color: var(--text);
  display: grid; grid-template-rows: var(--menu-h) var(--prop-h) 1fr 24px;
  user-select: none; -webkit-user-select: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
.spacer { flex: 1; }

/* ---------------------------------------------------------- barra de menú */
#menubar {
  display: flex; align-items: center; gap: 4px; padding: 0 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 6px; padding-right: 8px; }
.logo {
  width: 20px; height: 20px; border-radius: 5px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.bname { font-weight: 600; letter-spacing: .3px; }
body[data-ws="canva"] .logo { border-radius: 50%; }
#menus { display: flex; }
#menus > .m { padding: 5px 9px; border-radius: var(--radius); cursor: default; position: relative; }
#menus > .m:hover, #menus > .m.open { background: var(--panel2); }
#docname { color: var(--text-dim); }
#wsswitch { display: flex; align-items: center; gap: 3px; }
.wslabel { color: var(--text-dim); margin-right: 3px; }
#wsswitch button {
  background: transparent; border: 1px solid var(--line2); color: var(--text-dim);
  padding: 3px 9px; border-radius: 20px; cursor: pointer;
}
#wsswitch button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.menu-pop {
  position: fixed; z-index: 500; min-width: 210px; padding: 4px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); display: none;
}
.menu-pop.show { display: block; }
.menu-pop .it {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px;
  border-radius: 4px; cursor: default; white-space: nowrap;
}
.menu-pop .it:hover { background: var(--accent); color: #fff; }
.menu-pop .it.dis { opacity: .38; pointer-events: none; }
.menu-pop .it .k { margin-left: auto; color: var(--text-dim); font-size: 11px; }
.menu-pop .it:hover .k { color: #e8eefc; }
.menu-pop .sep { height: 1px; background: var(--line2); margin: 4px 6px; }
.menu-pop .grp { padding: 4px 10px 2px; color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; }

/* ---------------------------------------------------------- barra de propiedades */
#propbar {
  display: flex; align-items: center; gap: 6px; padding: 0 8px; overflow-x: auto;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#propbar::-webkit-scrollbar { height: 0; }
.pgrp { display: flex; align-items: center; gap: 4px; }
.pgrp + .pgrp::before { content: ""; width: 1px; height: 18px; background: var(--line2); margin: 0 5px; }
.plab { color: var(--text-dim); font-size: 11px; }
.num, select.sel, input.txt {
  background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 3px 5px; width: 62px; outline: none;
}
.num:focus, input.txt:focus, select.sel:focus { border-color: var(--accent); }
select.sel { width: auto; padding: 3px 4px; }
.btn {
  background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 3px 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { border-color: var(--accent); }
.btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.icon { padding: 3px 6px; min-width: 26px; justify-content: center; }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ---------------------------------------------------------- área central */
#workspace { display: flex; min-height: 0; overflow: hidden; }
#toolbox {
  width: var(--tool-w); background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; overflow-y: auto;
}
#toolbox::-webkit-scrollbar { width: 0; }
.tool {
  position: relative; width: 32px; height: 32px; border-radius: var(--radius);
  display: grid; place-items: center; cursor: pointer; color: var(--text-dim);
  border: 1px solid transparent; background: transparent;
}
.tool:hover { background: var(--panel2); color: var(--text); }
.tool.on { background: var(--accent); color: #fff; }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tool .fly { position: absolute; right: 1px; bottom: 1px; width: 0; height: 0;
  border-left: 4px solid transparent; border-bottom: 4px solid currentColor; }
.tsep { width: 22px; height: 1px; background: var(--line2); margin: 3px 0; }
body[data-ws="illustrator"] #toolbox { flex-flow: row wrap; justify-content: center; padding: 6px 2px; }
body[data-ws="canva"] #toolbox { display: none; }

#stage { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; background: var(--canvas-bg); }
#rulers { position: relative; height: 18px; }
#rulerCorner { position: absolute; left: 0; top: 0; width: 18px; height: 18px; z-index: 3;
  background: var(--panel); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: 9px; display: grid; place-items: center; color: var(--text-dim); cursor: pointer; }
#rulerH { position: absolute; left: 18px; top: 0; height: 18px; right: 0; cursor: ns-resize; }
#rulerV { position: absolute; left: 0; top: 18px; width: 18px; z-index: 2; cursor: ew-resize; }
#canvasWrap { flex: 1; position: relative; margin-left: 18px; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body.norulers #rulers { display: none; }
body.norulers #canvasWrap { margin-left: 0; }
body.norulers #rulerV { display: none; }

#textEditor {
  position: absolute; display: none; z-index: 20; background: rgba(255,255,255,.06);
  border: 1px dashed var(--accent); color: transparent; caret-color: var(--accent);
  padding: 0; margin: 0; resize: none; overflow: hidden; outline: none;
  transform-origin: 0 0; min-height: 1.2em;
  /* el body lleva user-select:none y se hereda: aquí hay que escribir y seleccionar */
  user-select: text; -webkit-user-select: text;
}
input, textarea { user-select: text; -webkit-user-select: text; }
#floatbar {
  position: absolute; z-index: 15; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: none; gap: 6px; padding: 6px 8px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 30px; box-shadow: 0 6px 22px rgba(0,0,0,.35);
}
body[data-ws="canva"] #floatbar { display: flex; }

/* ---------------------------------------------------------- muelles / paneles */
.dock {
  width: var(--dock-w); background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column;
}
#leftdock { border-left: 0; border-right: 1px solid var(--line); display: none; }
body[data-ws="canva"] #leftdock { display: flex; }
body[data-ws="canva"] #rightdock { display: none; }
.dock::-webkit-scrollbar { width: 9px; }
.dock::-webkit-scrollbar-thumb { background: #4a5058; border-radius: 5px; }
.panel { border-bottom: 1px solid var(--line); }
.panel > h3 {
  margin: 0; padding: 7px 10px; font-size: 11px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; gap: 6px; background: var(--panel);
}
.panel > h3::before { content: "▾"; font-size: 9px; }
.panel.closed > h3::before { content: "▸"; }
.panel.closed > .body { display: none; }
.panel > .body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 6px; }
.row .lab { color: var(--text-dim); width: 58px; flex: none; font-size: 11px; }
.row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.grid8 { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.sw {
  display: inline-block; width: 20px; height: 14px; border: 1px solid var(--line2);
  border-radius: 3px; vertical-align: middle;
  background-image: linear-gradient(45deg,#888 25%,transparent 25%,transparent 75%,#888 75%),
                    linear-gradient(45deg,#888 25%,#fff 25%,#fff 75%,#888 75%);
  background-size: 8px 8px; background-position: 0 0, 4px 4px;
}
.sw i { display: block; width: 100%; height: 100%; border-radius: 2px; }

/* capas */
.layer, .objrow {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; cursor: pointer;
}
.layer { background: var(--panel2); margin-bottom: 3px; }
.layer.on { outline: 1px solid var(--accent); }
.objrow { padding-left: 16px; font-size: 11.5px; color: var(--text-dim); }
.objrow.on { background: var(--accent); color: #fff; }
.objrow:hover { background: rgba(255,255,255,.06); }
.eye, .lock { width: 16px; text-align: center; opacity: .8; }
.eye.off, .lock.off { opacity: .25; }
.lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini { background: none; border: 0; color: var(--text-dim); cursor: pointer; padding: 2px 4px; border-radius: 3px; }
.mini:hover { background: var(--panel2); color: var(--text); }

/* selector de color */
#svbox { width: 100%; height: 120px; border-radius: 4px; cursor: crosshair; display: block; }
#huebar { width: 100%; height: 14px; border-radius: 3px; cursor: pointer; display: block; }
.colorTabs { display: flex; gap: 3px; }
.colorTabs .btn { flex: 1; justify-content: center; }
.stopbar { position: relative; height: 26px; border-radius: 3px; border: 1px solid var(--line2); }
.stopbar .strip { position: absolute; inset: 0 0 10px 0; border-radius: 2px 2px 0 0; }
.stop { position: absolute; bottom: 0; width: 11px; height: 11px; margin-left: -5px; border-radius: 2px;
  border: 1px solid #fff; box-shadow: 0 0 0 1px #000; cursor: pointer; }
.stop.on { outline: 2px solid var(--accent); }

/* paleta lateral estilo Corel */
#palette {
  width: var(--pal-w); background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 2px 0; overflow-y: auto;
}
#palette::-webkit-scrollbar { width: 0; }
#palette .psw { width: 18px; height: 13px; margin-bottom: 1px; border: 1px solid rgba(0,0,0,.35); cursor: pointer; flex: none; }
#palette .psw:hover { outline: 2px solid #fff; z-index: 2; }
body[data-ws="illustrator"] #palette, body[data-ws="canva"] #palette { display: none; }

/* barra de estado */
#statusbar {
  display: flex; align-items: center; gap: 10px; padding: 0 8px;
  background: var(--panel); border-top: 1px solid var(--line); font-size: 11px; color: var(--text-dim);
}
.st-style { display: flex; align-items: center; gap: 5px; }
.st-lab { color: var(--text-dim); }
.st-num { font-variant-numeric: tabular-nums; }
.st-zoom { display: flex; align-items: center; gap: 3px; }
.st-zoom button { background: var(--panel2); border: 1px solid var(--line2); border-radius: 3px;
  width: 20px; height: 17px; cursor: pointer; line-height: 1; }
#zoomInput { width: 42px; background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 3px; padding: 1px 3px; text-align: right; }

/* modales */
#modalbg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none;
  place-items: center; z-index: 900; }
#modalbg.show { display: grid; }
#modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 8px;
  min-width: 380px; max-width: 92vw; max-height: 88vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
#modal h2 { margin: 0; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
#modal .mbody { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
#modal .mfoot { padding: 10px 16px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 5px 14px; }
.card { background: var(--panel2); border: 1px solid var(--line2); border-radius: 6px;
  padding: 8px; cursor: pointer; text-align: center; }
.card:hover { border-color: var(--accent); }
.card b { display: block; font-size: 12px; }
.card span { color: var(--text-dim); font-size: 11px; }

#toast { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%);
  background: #111; color: #fff; padding: 8px 14px; border-radius: 20px; z-index: 1000;
  opacity: 0; transition: opacity .25s; pointer-events: none; }
#toast.show { opacity: .95; }

/* elementos de Canva */
.canva-tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.canva-tabs .btn { flex: 1; justify-content: center; flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 2px; }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; align-content: start; }
.thumb { min-height: 84px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 4px; cursor: pointer; }
.thumb:hover { border-color: var(--accent); }
.thumb svg { width: 34px; height: 34px; color: var(--accent); }
.tprev { height: 48px; display: grid; place-items: center; }
.tprev i { display: block; background: var(--bg); border: 1px solid var(--line2); border-radius: 2px; }
body[data-ws="canva"] .tprev i { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.tname { font-size: 10.5px; color: var(--text-dim); text-align: center; line-height: 1.2; }
