/* Cota — interfaz.
 * Diseño: mesa de dibujo. Paneles de carbón cálido, acento ámbar y lienzo de papel claro
 * (el dibujo se ve como en papel, el resto descansa la vista).
 * Tema "Carbón" por defecto; el tema todo claro se activa con data-theme="light". */

:root {
  --bg: #141517;
  --panel: #1b1c1f;
  --panel-2: #242529;
  --line: #34363b;
  --line-soft: #2a2b2f;
  --text: #ebe8e2;
  --muted: #9b988f;
  --accent: #f2a93b;
  --accent-ink: #1d1405;
  --accent-soft: rgba(242, 169, 59, 0.15);
  --danger: #ef6a5b;
  --canvas: #f1ede4;
  --grid-minor: rgba(70, 58, 40, 0.09);
  --grid-major: rgba(70, 58, 40, 0.2);
  --axis-x: rgba(190, 60, 48, 0.6);
  --axis-y: rgba(40, 125, 88, 0.6);
  --ink: #26231f;
  --sel: #0f766e;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
  --radius: 10px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ebe8e1;
  --panel: #faf8f4;
  --panel-2: #f0ede6;
  --line: #d8d3c8;
  --line-soft: #e6e2d9;
  --text: #25231f;
  --muted: #6b675e;
  --accent: #c47a08;
  --accent-ink: #ffffff;
  --accent-soft: rgba(196, 122, 8, 0.13);
  --danger: #c0392b;
  --canvas: #fbf9f4;
  --grid-minor: rgba(70, 58, 40, 0.09);
  --grid-major: rgba(70, 58, 40, 0.2);
  --axis-x: rgba(190, 60, 48, 0.6);
  --axis-y: rgba(40, 125, 88, 0.6);
  --ink: #26231f;
  --sel: #0f766e;
  --shadow: 0 8px 24px rgba(50, 40, 25, 0.16);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "SF Pro Text", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01", "tnum" 0;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app {
  height: 100%;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 292px;
  grid-template-rows: 52px minmax(0, 1fr) auto;
  grid-template-areas:
    "top top top"
    "tools stage panel"
    "status status status";
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  background: var(--bg);
}

/* ---------- barra superior ---------- */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.04em; margin-right: 6px; }
.brand svg { color: var(--text); }
.group { display: flex; align-items: center; gap: 4px; }
.spacer { flex: 1; }

.icon-btn, .txt-btn {
  height: 38px;
  min-width: 38px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.txt-btn { padding: 0 12px; color: var(--muted); }
.icon-btn:hover, .txt-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:disabled:hover { background: transparent; }
.icon-btn svg, .tool-btn svg, .sc-ico > svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { height: 34px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); }
.seg-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* ---------- herramientas ---------- */
.tools {
  grid-area: tools;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.tool-btn {
  width: 48px;
  min-height: 48px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
}
.tool-btn:hover { background: var(--panel-2); color: var(--text); }
.tool-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tool-sep { width: 28px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }
.tool-grp { width: 52px; flex: none; display: flex; align-items: center; justify-content: center; gap: 2px; margin-top: 6px; padding: 4px 0 2px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; }
.tool-grp:hover { color: var(--text); }
.tool-grp .tg-chev { display: inline-block; transition: transform 0.15s; font-size: 9px; }
.tool-grp.closed .tg-chev { transform: rotate(-90deg); }
.tool-grp.closed { color: var(--accent); }
.tool-btn[hidden] { display: none; }

/* ---------- lienzo ---------- */
.stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; background: var(--canvas); overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#cv.pan { cursor: grab; }
#cv.panning { cursor: grabbing; }
#cv.select { cursor: default; }

.float { position: absolute; display: flex; align-items: center; gap: 8px; z-index: 2; }
.top-left { top: 12px; left: 12px; right: 12px; flex-wrap: wrap; pointer-events: none; }
.top-left > * { pointer-events: auto; }
.top-right { top: 12px; right: 12px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 24px); }
.bottom-center { bottom: 18px; left: 50%; transform: translateX(-50%); }

.opt {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--muted); font-size: 13px;
}
.opt input { width: 84px; height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-variant-numeric: tabular-nums; }
.opt .opt-name { color: var(--text); font-weight: 600; }
.opt select { height: 32px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 0 6px; max-width: 160px; }

.sel-count { padding: 0 10px; color: var(--muted); font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; height: 38px; display: inline-flex; align-items: center; box-shadow: var(--shadow); }
.chip-btn {
  height: 38px; padding: 0 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow);
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.danger { color: var(--danger); }
.panel .chip-btn { box-shadow: none; height: 30px; padding: 0 10px; font-size: 13px; }

.pill {
  height: 44px; padding: 0 22px; border-radius: 22px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: var(--shadow);
}
.pill.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-weight: 500; }

.toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 8px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: var(--text); font-size: 13px; z-index: 3;
}

/* ---------- panel derecho ---------- */
.panel {
  grid-area: panel;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  min-width: 0;
}
.panel section { padding: 12px 14px 14px; border-bottom: 1px solid var(--line-soft); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel h2 { margin: 0; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.layers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.layer {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) 34px 34px; align-items: center; gap: 6px;
  padding: 2px 4px 2px 8px; border-radius: 8px; border: 1px solid transparent;
}
.layer.active { background: var(--accent-soft); border-color: var(--accent); }
.layer .sw { width: 12px; height: 12px; border-radius: 3px; }
.layer input[type="text"] { width: 100%; min-width: 0; height: 32px; border: 0; background: transparent; color: var(--text); padding: 0 2px; }
.layer input[type="text"]:focus { background: var(--panel-2); border-radius: 6px; }
.layer .lbtn { width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.layer .lbtn[aria-pressed="false"] { color: var(--text); }
.layer .lbtn.off { opacity: 0.4; }
.layer .lbtn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.props { display: flex; flex-direction: column; gap: 8px; }
.props .empty { color: var(--muted); font-size: 13px; }
.prop-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; align-items: center; }
.prop-row label { color: var(--muted); font-size: 13px; }
.prop-row .val { font-variant-numeric: tabular-nums; }
.prop-row input, .prop-row select {
  width: 100%; height: 34px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-variant-numeric: tabular-nums;
}

.help dl { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.help dt { color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; margin-top: 8px; }
.help dd { margin: 0; color: var(--muted); }

/* ---------- barra inferior ---------- */
.statusbar {
  grid-area: status;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-height: 46px;
}
.cmd { display: flex; align-items: center; gap: 10px; flex: 1 1 320px; min-width: 0; margin: 0; }
.cmd-hint { color: var(--muted); white-space: nowrap; font-size: 13px; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.cmd-hint b { color: var(--accent); font-weight: 600; }
#cmd-input {
  flex: 1; min-width: 90px; height: 36px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px;
}
#cmd-input:focus { border-color: var(--accent); outline: none; }
.status-right { display: flex; align-items: center; gap: 8px; }
.tog { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.tog[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.readout { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; }
.readout.dim { color: var(--muted); min-width: 44px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; box-shadow: var(--shadow); max-width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(5, 10, 18, 0.6); }
.dlg-body { padding: 20px; }
.dlg-body h3 { margin: 0 0 6px; font-size: 17px; }
.dlg-body p { margin: 0 0 18px; color: var(--muted); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- pantallas medianas e iPad vertical: el panel se abre encima ---------- */
@media (max-width: 960px) {
  #app { grid-template-columns: 60px minmax(0, 1fr); grid-template-areas: "top top" "tools stage" "status status"; }
  .panel {
    position: fixed; z-index: 20;
    top: calc(52px + env(safe-area-inset-top, 0px)); right: 0;
    bottom: calc(46px + env(safe-area-inset-bottom, 0px));
    width: min(320px, 92vw);
    transform: translateX(105%); transition: transform 0.18s ease;
    box-shadow: var(--shadow);
  }
  #app.panel-open .panel { transform: none; }
}

/* ---------- teléfono: herramientas abajo ---------- */
@media (max-width: 640px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 52px minmax(0, 1fr) auto auto; grid-template-areas: "top" "stage" "tools" "status"; }
  .tools { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-top: 1px solid var(--line); padding: 6px 8px; justify-content: flex-start; }
  .tool-sep { width: 1px; height: 28px; margin: 0 4px; }
  .tool-grp { width: auto; min-width: 40px; margin: 0 2px; padding: 0 6px; border-top: 0; border-left: 1px solid var(--line); flex-direction: column; }
  .file-group { display: none; }
  .brand span { display: none; }
  .panel { top: calc(52px + env(safe-area-inset-top, 0px)); bottom: 0; }
  .cmd-hint { max-width: 100%; flex: 1 1 100%; }
  .cmd { flex-wrap: wrap; }
  .status-right { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }

/* ---------- modo 3D ---------- */
.only-3d { display: none; }
#app.mode-3d .only-3d { display: block; }
#app.mode-3d .only-2d { display: none !important; }
#app.mode-3d { grid-template-columns: 0 minmax(0, 1fr) 292px; }
#app.mode-3d #tools { display: none; }
#cv3 { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#cv3:active { cursor: grabbing; }
.cam3bar .seg { background: var(--panel); box-shadow: var(--shadow); border-radius: 10px; }
.cam3bar .seg-btn { height: 38px; padding: 0 14px; }
.hint3 { flex: 1 1 320px; min-width: 0; color: var(--muted); font-size: 13px; padding: 6px 0; }
.dual { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.prop-row input[type="range"] { padding: 0; height: 28px; accent-color: var(--accent); }
.prop-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); justify-self: start; }
.info3 { color: var(--muted); font-size: 13px; line-height: 1.5; padding-top: 2px; }
.info3 b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 960px) { #app.mode-3d { grid-template-columns: 0 minmax(0, 1fr); } }
@media (max-width: 640px) { #app.mode-3d { grid-template-columns: minmax(0, 1fr); } }

/* ajustes de la barra superior */
.topbar .seg, .topbar .group, .topbar .brand { flex: none; }
.short { display: none; }
.dual { align-items: center; }
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .brand { margin-right: 0; }
  .long { display: none; }
  .short { display: inline; }
  .seg-btn { padding: 0 10px; }
  .cam3bar .seg-btn { padding: 0 10px; }
  .cam3bar .chip-btn { padding: 0 10px; }
  .top-left { gap: 6px; }
}

/* ---------- pisos, plantillas y proyectos ---------- */
.bottom-left { left: 12px; bottom: 14px; }
#levelbar { gap: 6px; pointer-events: none; flex-wrap: wrap; max-width: calc(100% - 24px); }
#levelbar > * { pointer-events: auto; }
.lvl-chip { height: 34px; padding: 0 12px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); box-shadow: var(--shadow); font-size: 13px; }
.lvl-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.level-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#levels .layer { grid-template-columns: 14px minmax(0, 1fr) 34px; }
#levels .lvl-n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }

dialog.wide { max-width: min(640px, calc(100% - 24px)); width: 100%; }
dialog.wide .dlg-body { max-height: min(86vh, 720px); overflow-y: auto; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tpl { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.tpl:hover, .tpl:focus-visible { border-color: var(--accent); }
.tpl canvas { width: 100%; aspect-ratio: 16 / 11; border-radius: 8px; background: var(--canvas); display: block; }
.tpl b { font-size: 14px; }
.tpl span { color: var(--muted); font-size: 12px; line-height: 1.35; }

.proj-head { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; }
.proj-head h3 { margin: 0 0 6px; }
.plan-tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: normal; }
.proj-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.proj { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.proj.current { border-color: var(--accent); background: var(--accent-soft); }
.proj canvas, .proj img { width: 96px; height: 66px; border-radius: 8px; background: var(--canvas); object-fit: cover; display: block; }
.proj input { width: 100%; height: 32px; border: 1px solid transparent; background: transparent; color: var(--text); font-weight: 600; border-radius: 6px; padding: 0 6px; }
.proj input:hover, .proj input:focus { border-color: var(--line); background: var(--panel); }
.proj .meta { color: var(--muted); font-size: 12px; padding: 0 6px; }
.proj-actions { display: flex; flex-direction: column; gap: 6px; }
.proj-actions .chip-btn { height: 30px; padding: 0 10px; font-size: 13px; box-shadow: none; }
.pro-note { font-size: 13px; }
.proj-ico svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.proj-btn { gap: 8px; }
@media (max-width: 640px) {
  .proj { grid-template-columns: 72px minmax(0, 1fr); }
  .proj canvas, .proj img { width: 72px; height: 52px; }
  .proj-actions { grid-column: 1 / -1; flex-direction: row; }
  .proj-btn { padding: 0 8px; }
}

.opt-dim { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.opt-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); white-space: nowrap; }
.opt-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.opt .chip-btn { height: 32px; padding: 0 10px; box-shadow: none; font-size: 13px; }
.opt { flex-wrap: wrap; row-gap: 4px; }
.prop-row .opt-check input { width: 18px; height: 18px; }
#ask-input { width: 100%; height: 40px; padding: 0 12px; margin: 0 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px; }
#app.mode-3d #levelbar { display: none; }

/* ---------- modo clase: hoja, minas y escuadras ---------- */
.only-clase { display: none; }
#app.ws-clase .only-clase { display: block; }
#app.ws-clase .only-libre { display: none; }
.ws-seg .seg-btn { min-width: 52px; }
.mid-right { right: 12px; top: 64px; flex-direction: column; align-items: stretch; gap: 6px; max-height: calc(100% - 140px); overflow-y: auto; padding: 2px; }
#draftbar .chip-btn { height: 34px; padding: 0 12px; font-size: 13px; text-align: left; }
#draftbar .chip-btn.small { height: 30px; font-size: 12px; color: var(--muted); }
#draftbar .chip-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
#draftbar .chip-btn:disabled { opacity: 0.45; }
#draftbar .db-head { font-weight: 600; }
.db-sep { height: 1px; background: var(--line); margin: 2px 4px; }
#app.mode-3d #draftbar { display: none; }
.opt.pencil select { max-width: 150px; }
canvas.swatch { width: 60px; height: 10px; border-radius: 3px; border: 1px solid var(--line); }
.props .hint { color: var(--muted); font-size: 12px; line-height: 1.35; margin: -2px 0 8px; }
.props .btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tpl-h { margin: 14px 0 2px; font-size: 14px; }
.tpl-p { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
@media (max-width: 640px) {
  .mid-right { top: auto; bottom: 64px; max-height: 50%; }
  #draftbar .chip-btn { height: 32px; padding: 0 10px; }
}

/* ---------- editar medidas ---------- */
.xy { display: flex; gap: 6px; align-items: center; min-width: 0; }
.xy input { min-width: 0; flex: 1 1 0; width: 100%; }
.xy .chip-btn { flex: none; }
.xy-in { display: flex; align-items: center; gap: 4px; flex: 1 1 0; min-width: 0; }
.xy-in span { color: var(--muted); font-size: 11px; width: 10px; }
.field-pair { display: flex; gap: 6px; min-width: 0; }
.field-pair input { flex: 1 1 auto; min-width: 0; }
.field-pair .mini-sel { flex: none; width: 44px; }

/* ---------- inicio y cuenta ---------- */
button.brand { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
button.brand:hover { background: var(--panel-2); }
.home { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; }
.home-top { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1; }
.home-top .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.home-body { max-width: 1040px; margin: 0 auto; padding: 24px 16px 60px; }
.home-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.home-head h1 { margin: 0 0 4px; font-size: 26px; }
.home-head-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.home h2 { font-size: 15px; margin: 28px 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.home .muted, .muted { color: var(--muted); }
.small { font-size: 12px; }
.start-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 10px; }
.start-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.start-card:hover, .start-card:focus-visible { border-color: var(--accent); }
.start-card b { font-size: 15px; }
.start-card > span:last-child { color: var(--muted); font-size: 12.5px; }
.sc-ico { color: var(--accent); margin-bottom: 4px; }
.home-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.home-row h2 { margin-bottom: 10px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.proj-card { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.proj-card.current { border-color: var(--accent); }
.pc-open { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 8px; overflow: hidden; }
.pc-open img, .thumb-empty { width: 100%; aspect-ratio: 16 / 11; object-fit: cover; display: block; background: var(--canvas); border-radius: 8px; }
.pc-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); flex: none; }
.badge.clase { color: var(--accent); border-color: var(--accent); }
.pc-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.pc-acts .chip-btn { height: 30px; padding: 0 10px; font-size: 12.5px; box-shadow: none; }
.log { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.log li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.log li:first-child { border-top: 0; }
.home-skip { margin-top: 22px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.acc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.acc-stats div { display: flex; flex-direction: column; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.acc-stats b { font-size: 17px; }
.acc-stats span { font-size: 11.5px; color: var(--muted); }
#acc-body .prop-row { margin-bottom: 8px; }
.sub-head { margin: 10px 0 2px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.level-seg { margin-bottom: 4px; align-self: flex-start; }
.grid-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grid-opt { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 11.5px; }
.grid-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.gi { display: inline-flex; color: var(--text); }
.swatches { display: flex; gap: 6px; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
.grid-size select { flex: 1 1 auto; min-width: 74px; }
.grid-size input { flex: 0 1 76px; min-width: 56px; }
.field-pair > .chip-btn { flex: none; height: 34px; padding: 0 10px; box-shadow: none; }
.prop-row .chip-btn { box-shadow: none; }
.tpl-pick { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.tpl-pick label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tpl-pick select { height: 32px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 0 6px; }
@media (max-width: 640px) { .acc-stats { grid-template-columns: repeat(2, 1fr); } .home-head h1 { font-size: 22px; } }

/* ---------- iniciar sesión ---------- */
.login { z-index: 30; display: flex; align-items: flex-start; justify-content: center; }
.login[hidden] { display: none; }
.login-body { width: 100%; max-width: 420px; margin: 8vh 16px 40px; padding: 28px 24px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin-bottom: 14px; }
.login-brand h1 { margin: 0; font-size: 28px; letter-spacing: .04em; }
.login-brand p { margin: 0; }
.login h2 { font-size: 15px; margin: 16px 0 10px; }
.user-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.user-btn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); text-align: left; }
.user-btn:hover, .user-btn:focus-visible { border-color: var(--accent); }
.user-btn > span:last-child { display: flex; flex-direction: column; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; flex: none; }
.avatar.big { width: 64px; height: 64px; font-size: 24px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input { height: 42px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 15px; }
.login-err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 13px; }
.login-note { margin-top: 18px; line-height: 1.4; }
.btn-row.tight { margin: 0; }

#draftbar .db-sel { height: 30px; max-width: 150px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12px; padding: 0 4px; }
#draftbar .db-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 4px; }

/* ---------- Google y nube ---------- */
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 46px; border-radius: 10px; border: 1px solid #dadce0; background: #fff; color: #1f1f1f; font-weight: 600; font-size: 15px; cursor: pointer; }
.google-btn:hover { box-shadow: 0 1px 6px rgba(0,0,0,.18); }
.google-btn:disabled { opacity: .6; cursor: wait; }
.center { text-align: center; }
.avatar.g { background: #4285f4; color: #fff; }
.cloud-status { color: var(--muted); margin: 4px 0 0; min-height: 1em; }
.cloud-status[data-state="ok"] { color: #2f9e62; }
.cloud-status[data-state="out"], .cloud-status[data-state="err"] { color: var(--danger); }
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0 10px; }
.or-sep::before, .or-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- láminas y cuadros ---------- */
.sheet-list li { gap: 4px; }
.sheet-list input.sheet-no { width: 48px; flex: none; font-weight: 700; }
.sheet-list input { min-width: 0; }
.icon-mini { flex: none; width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 12px; padding: 0; }
.icon-mini:disabled { opacity: .35; }
.icon-mini.danger { color: var(--danger); }
.sheet-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 10px 0 14px; }
.sheet-type[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
table.tk { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
table.tk th, table.tk td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
table.tk th { background: var(--panel-2); font-weight: 600; }
#gen-body h4 { margin: 14px 0 6px; }

.sheet-list li.layer { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto auto auto; align-items: center; gap: 4px; }
.sheet-list li.layer .lvl-n { display: none; }
.sheet-list li.layer input { width: 100%; }

/* ===== inicio v2: categorías, mosaicos y tarjetas ===== */
.home-body { max-width: 1120px; }
.home-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; padding: 22px; border-radius: 18px; border: 1px solid var(--line);
  background: radial-gradient(120% 140% at 0% 0%, var(--accent-soft), transparent 60%), var(--panel); }
.home-hero h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.01em; }
.home-hero p { margin: 0; }
.hh-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hs { display: flex; flex-direction: column; min-width: 92px; padding: 8px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.hs b { font-size: 20px; line-height: 1.1; }
.hs span { font-size: 11.5px; color: var(--muted); }
.hs.owner { border-color: var(--accent); }
.hs.owner b, .hs.owner span { color: var(--accent); }
.home-hero .cloud-status { margin-top: 10px; }
.home-hero .home-head-btns { align-self: flex-start; }

.start-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.start-card { position: relative; padding: 14px 14px 16px; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
.start-card:hover, .start-card:focus-visible { border-color: var(--c, var(--accent)); transform: translateY(-2px); box-shadow: var(--shadow); }
.start-card .sc-ico { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--cs, var(--accent-soft)); color: var(--c, var(--accent)); margin-bottom: 8px; }
.start-card .sc-ico > svg, .ct-ico > svg, .ch-ico > svg, .pc-chip > svg, .pc-star > svg, .pb-search > svg, .fav-filter > svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.cat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cat-tile { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; min-height: 52px; padding: 8px 10px; text-align: left;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; transition: border-color .12s, background .12s; }
.cat-tile b { font-size: 13px; line-height: 1.2; }
.cat-tile:hover { border-color: var(--c); }
.cat-tile.on { border-color: var(--c); background: var(--cs); box-shadow: inset 0 0 0 1px var(--c); }
.cat-tile.empty b { color: var(--muted); font-weight: 600; }
.ct-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--cs); color: var(--c); }
.ct-n { font-size: 12px; font-weight: 700; color: var(--c); min-width: 20px; text-align: right; }
.cat-tile.empty .ct-n { color: var(--muted); opacity: .6; }
.cat-tile.add { border-style: dashed; color: var(--muted); grid-template-columns: 34px 1fr; }
.cat-tile.add .ct-ico { background: var(--panel-2); color: var(--muted); font-size: 20px; font-weight: 600; }
.cat-tile.add:hover { border-color: var(--accent); color: var(--text); }
.cat-tile.more { border-style: dashed; color: var(--muted); grid-template-columns: 34px 1fr; }
.cat-tile.more .ct-ico { background: var(--panel-2); color: var(--muted); font-size: 20px; font-weight: 600; }
.cat-tile.more:hover { border-color: var(--accent); color: var(--text); }

.proj-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 22px 0 4px; }
.pb-search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); }
.pb-search:focus-within { border-color: var(--accent); }
.pb-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; height: 100%; }
.proj-bar select { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 0 8px; }
.fav-filter { height: 38px; display: inline-flex; align-items: center; gap: 4px; }
.fav-filter[aria-pressed="true"] { border-color: hsl(45, 90%, 50%); color: hsl(40, 90%, 42%); background: hsla(45, 90%, 50%, .12); }
.fav-filter[aria-pressed="true"] svg { fill: currentColor; }

.cat-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.cat-head .ch-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--cs, var(--accent-soft)); color: var(--c, var(--accent)); flex: none; }
.ch-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.cat-head h3 { margin: 0; font-size: 16px; }
.ch-tools { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.cat-head .cnt { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--cs, var(--panel-2)); color: var(--c, var(--muted)); font-size: 11px; font-weight: 700; text-align: center; vertical-align: 2px; }

.proj-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.proj-card { position: relative; overflow: hidden; border-top: 3px solid var(--c, var(--line)); transition: transform .12s ease, box-shadow .12s ease; }
.proj-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.proj-card.current { border-color: var(--accent); border-top-color: var(--c, var(--accent)); box-shadow: 0 0 0 1px var(--accent); }
.pc-thumb { position: relative; }
.pc-star { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; opacity: .9; }
.pc-star:hover { color: hsl(40, 90%, 45%); }
.pc-star.on { color: hsl(42, 95%, 48%); border-color: hsla(45, 90%, 50%, .6); }
.pc-star.on svg { fill: currentColor; }
.pc-chip { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px 2px 6px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--panel); color: var(--c); border: 1px solid var(--cs); max-width: calc(100% - 12px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pc-cat { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cat-sel { height: 26px; font-size: 12px; padding: 0 4px; max-width: 130px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.empty-cat { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 28px 16px; margin-top: 12px; border-radius: 14px; border: 1px dashed var(--c); background: var(--cs); }
.empty-cat p { margin: 0; }
.empty-cat .ch-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--panel); color: var(--c); margin-bottom: 6px; }
.empty-note { margin-top: 12px; }
.plan-tag.owner, .plan-owner { color: var(--accent); font-weight: 600; }
.tpl-kind { font-size: 11px; color: var(--muted); }
.tpl-kind.clase { color: var(--accent); }
.tpl-pick > .muted { align-self: center; }
@media (max-width: 640px) {
  .home-hero { padding: 16px; }
  .home-hero h1 { font-size: 23px; }
  .hs { min-width: 0; flex: 1 1 40%; }
  .cat-tiles { grid-template-columns: repeat(2, 1fr); }
  .proj-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .pc-acts .chip-btn { padding: 0 8px; }
}
@media (max-width: 420px) { .proj-grid { grid-template-columns: 1fr; } }
.pc-thumb .pc-open { display: block; width: 100%; }

/* ===== maqueta ===== */
.mq-body { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.mq-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.mq-side { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); }
.mq-side h3 { margin: 0 0 2px; font-size: 16px; }
.mq-f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.mq-f select, .mq-f input { height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 0 8px; font-size: 14px; }
.mq-hint { margin: -4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.35; }
.mq-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.mq-main h3 { margin: 26px 0 8px; font-size: 16px; }
.mq-main h3:first-of-type { margin-top: 22px; }
.mq-sum { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mq-sum .hs { background: var(--panel); }
.mq-sum .hs b { font-size: 17px; }
.mq-warn { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; border: 1px solid hsla(40, 90%, 50%, .6); background: hsla(45, 90%, 50%, .1); font-size: 13px; }
.mq-sheets { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.mq-sheets figure { margin: 0; }
.mq-sheet { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.mq-sheet svg { display: block; width: 100%; height: auto; }
.mq-sheets figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.mq-table td:first-child b { color: var(--accent); }
.mq-list { margin: 0; padding-left: 20px; line-height: 1.55; font-size: 14px; }
.mq-steps { margin: 0; padding: 0; list-style: none; counter-reset: st; display: grid; gap: 8px; }
.mq-steps li { counter-increment: st; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 14px; }
.mq-steps li::before { content: counter(st); grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.mq-steps li span { color: var(--muted); line-height: 1.4; }
@media (max-width: 820px) { .mq-grid { grid-template-columns: 1fr; } .mq-side { position: static; } }

/* ===== escaneos y foto ===== */
.scan-steps { margin: 6px 0 14px; padding: 0; list-style: none; counter-reset: st; display: grid; gap: 8px; }
.scan-steps li { counter-increment: st; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: 14px; }
.scan-steps li::before { content: counter(st); grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.scan-steps li span { color: var(--muted); line-height: 1.4; }
.scan-prev { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); margin: 4px 0 8px; }
#refcfg input[type="range"] { width: 100%; accent-color: var(--accent); }
.align-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.icon-chip { padding: 0 !important; min-width: 0; height: 32px; font-size: 16px; justify-content: center; }
.scx-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.scx-tools .chip-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.scx-sel { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 10px; border: 1px solid #0a7cc2; background: rgba(10,124,194,.06); font-size: 13px; }
.scx-main { min-width: 0; }
.scx-cv { display: block; width: 100%; border-radius: 14px; border: 1px solid var(--line); touch-action: none; cursor: crosshair; }
.mq-side input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ===== colores y catálogo ===== */
.swatches { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: 330px; }
.sw { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.18); padding: 0; cursor: pointer; flex: none; }
.sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.sw.none { background: linear-gradient(135deg, var(--panel-2) 45%, #e03131 46%, #e03131 54%, var(--panel-2) 55%); }
.sw-custom { width: 30px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.opt .swatches { max-width: 420px; }
.chip-btn.primary-soft { border-color: var(--accent); color: var(--accent); }
.cat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cat-top h3 { margin: 0; }
.cat-search { width: 100%; height: 40px; margin: 10px 0 8px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 15px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cat-chips .chip-btn { height: 30px; font-size: 12.5px; box-shadow: none; }
.cat-chips .chip-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 58vh; overflow-y: auto; padding: 2px; }
.cat-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-align: left; cursor: pointer; transition: border-color .12s, transform .12s; }
.cat-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.cat-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cat-card img { width: 100%; aspect-ratio: 220 / 160; object-fit: contain; border-radius: 8px; background: var(--panel-2); margin-bottom: 4px; }
.cat-card b { font-size: 13px; line-height: 1.2; }
.stepper { display: flex; align-items: stretch; gap: 3px; min-width: 0; }
.stepper input { flex: 1; min-width: 0; text-align: center; }
.step-btn { width: 30px; flex: none; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px; font-weight: 600; cursor: pointer; padding: 0; }
.step-btn:hover { border-color: var(--accent); color: var(--accent); }
.zone-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }

/* mis bloques */
.blk-list { display: grid; gap: 8px; margin: 10px 0 4px; }
.blk-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line, rgba(128,128,128,.25)); border-radius: 10px; }
.blk-name { display: grid; gap: 2px; min-width: 0; }
.blk-name b { overflow-wrap: anywhere; }

/* ---------- retoque "slick" (carbón + ámbar) ---------- */
::selection { background: var(--accent-soft); color: var(--text); }
.icon-btn, .txt-btn, .tool-btn, .seg-btn, .chip-btn, .pill, .layer, .tog, .tpl, .start-card, .proj-card, .cat-tile {
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.topbar { border-bottom-color: var(--line-soft); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.brand { letter-spacing: 0.14em; font-size: 13px; }
.brand svg { color: var(--accent); }
.tools, .panel { border-color: var(--line-soft); }
.tool-btn { border-radius: 12px; }
.tool-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 4px 14px rgba(242, 169, 59, 0.28); }
:root[data-theme="light"] .tool-btn[aria-pressed="true"] { box-shadow: 0 4px 12px rgba(196, 122, 8, 0.25); }
.chip-btn, .opt, .sel-count, .toast { border-radius: 12px; }
.chip-btn:hover { background: var(--panel-2); }
.pill { box-shadow: 0 6px 18px rgba(242, 169, 59, 0.3); }
.pill:hover { transform: translateY(-1px); }
.panel h2 { letter-spacing: 0.14em; }
.layer.active { border-color: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 1px var(--line-soft); }
:root:not([data-theme="light"]) .stage::after { box-shadow: inset 0 0 0 1px var(--line-soft), inset 0 0 36px rgba(0, 0, 0, 0.16); }
.start-card:hover, .start-card:focus-visible, .proj-card:hover { box-shadow: var(--shadow); }

/* barras de desplazamiento finas */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* botones activos que flotan sobre el papel: fondo sólido para que se lean siempre */
.lvl-chip[aria-pressed="true"],
#draftbar .chip-btn[aria-pressed="true"],
.float .chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- bienvenida ---------- */
.corner-btn { position: absolute; top: 12px; right: 12px; z-index: 3; border-color: var(--line); background: var(--panel); }
.corner-btn:hover { border-color: var(--accent); }
.home-top .group { gap: 8px; }
.welcome { z-index: 40; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: opacity 0.28s ease; }
.welcome[hidden] { display: none; }
.welcome.out { opacity: 0; pointer-events: none; }
.wl-bg {
  position: absolute; inset: 0; opacity: 0.8;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px), linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 44px 44px; background-position: center;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 18%, transparent 70%); mask-image: radial-gradient(ellipse at center, #000 18%, transparent 70%);
}
.wl-glow { position: absolute; left: 50%; top: 46%; width: 70vmin; height: 70vmin; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, var(--accent-soft), transparent 62%); pointer-events: none; }
.wl-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px; max-width: 480px; animation: wl-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.wl-mark { color: var(--text); line-height: 0; }
.wl-title { margin: 18px 0 6px; padding-left: 0.2em; font-size: clamp(46px, 11vw, 76px); font-weight: 700; letter-spacing: 0.2em; line-height: 1; }
.wl-sub { margin: 0 0 18px; color: var(--muted); font-size: 16px; }
.wl-dim { color: var(--accent); line-height: 0; max-width: 80vw; }
.wl-dim svg { max-width: 100%; height: auto; }
.wl-tags { margin: 14px 0 30px; color: var(--muted); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; }
.wl-enter { height: 50px; padding: 0 34px; border-radius: 25px; font-size: 16px; }
.wl-other { margin-top: 12px; }
.wl-foot { position: absolute; bottom: 20px; left: 0; right: 0; margin: 0; text-align: center; color: var(--muted); font-size: 12px; opacity: 0.8; }
.wl-p1, .wl-p2, .wl-line { stroke-dasharray: 300; stroke-dashoffset: 0; animation: wl-draw 1.1s ease-out both; }
.wl-p2 { animation-delay: 0.25s; }
.wl-line { stroke-dasharray: 300; animation-delay: 0.5s; animation-duration: 1.2s; }
@keyframes wl-draw { from { stroke-dashoffset: 300; } to { stroke-dashoffset: 0; } }
@keyframes wl-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .wl-card, .wl-p1, .wl-p2, .wl-line { animation: none; } .welcome { transition: none; } }

/* ---------- panel que se esconde (pantallas grandes) ---------- */
#btn-panel[aria-pressed="true"] { color: var(--accent); }
@media (min-width: 961px) {
  #app.panel-collapsed { grid-template-columns: 60px minmax(0, 1fr) 0; }
  #app.mode-3d.panel-collapsed { grid-template-columns: 0 minmax(0, 1fr) 0; }
  #app.panel-collapsed .panel { display: none; }
}

/* ---------- teclas, tooltip, buscar ---------- */
kbd { font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; white-space: nowrap; }
.tip { position: fixed; z-index: 80; display: inline-flex; align-items: center; gap: 8px; max-width: 280px; padding: 6px 10px; border-radius: 9px; background: var(--text); color: var(--bg); font-size: 12.5px; line-height: 1.3; box-shadow: var(--shadow); pointer-events: none; animation: tip-in 0.12s ease-out; }
.tip kbd { background: rgba(127, 127, 127, 0.22); border-color: rgba(127, 127, 127, 0.35); color: inherit; }
@keyframes tip-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.pal-btn { display: inline-flex; align-items: center; gap: 8px; margin-left: 6px; padding: 0 8px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--muted); }
.pal-btn:hover { color: var(--text); border-color: var(--accent); }
.pal-btn svg { flex: none; }
@media (max-width: 960px) { .pal-btn .long, .pal-btn kbd { display: none; } .pal-btn { padding: 0 10px; } }

/* ---------- paleta de comandos y atajos ---------- */
.pal-back { position: fixed; inset: 0; z-index: 60; background: rgba(10, 10, 12, 0.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 12px 12px; animation: pal-fade 0.14s ease-out; }
@keyframes pal-fade { from { opacity: 0; } to { opacity: 1; } }
.pal { width: min(580px, 100%); max-height: 70vh; display: flex; flex-direction: column; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); overflow: hidden; }
.pal-input { height: 54px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; color: var(--text); font-size: 16px; outline: none; }
.pal-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; cursor: pointer; color: var(--text); }
.pal-item.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.pal-g { flex: none; min-width: 78px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pal-l { flex: 1; min-width: 0; }
.pal-empty { padding: 18px 12px; color: var(--muted); text-align: center; }
.pal-foot { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11.5px; }
.help-card { width: min(860px, 100%); max-height: 80vh; overflow-y: auto; margin-top: -4vh; padding: 18px 22px 22px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); }
.help-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.help-head h2 { margin: 0; font-size: 18px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 28px; }
.help-grid h3 { margin: 16px 0 6px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.help-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }

/* ---------- tour de primera vez ---------- */
.tour { position: fixed; inset: 0; z-index: 70; }
.tour-hole { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(8, 8, 10, 0.62), 0 0 0 2px var(--accent); transition: all 0.25s ease; pointer-events: none; }
.tour-card { position: fixed; padding: 16px 18px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); transition: left 0.25s ease, top 0.25s ease; }
.tour-card h3 { margin: 2px 0 6px; font-size: 17px; }
.tour-card p { margin: 0 0 14px; color: var(--muted); line-height: 1.5; font-size: 14px; }
.tour-step { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.tour-btns { display: flex; align-items: center; gap: 8px; }
.tour-btns .chip-btn { box-shadow: none; height: 34px; }
@media (prefers-reduced-motion: reduce) { .tour-hole, .tour-card, .pal-back, .tip { transition: none; animation: none; } }

/* ---------- íconos más finos y parejos ---------- */
.icon-btn svg, .tool-btn svg, .sc-ico > svg { stroke-width: 1.6; shape-rendering: geometricPrecision; }
.tool-btn { font-weight: 500; font-size: 10.5px; }
.tool-grp { font-size: 9.5px; letter-spacing: 0.1em; }
.tool-grp.closed { background: var(--panel-2); border-radius: 8px; border-top-color: transparent; padding: 6px 0; }
.tool-grp.closed::after { content: ""; }

/* barra superior en pantallas medianas: Nuevo, Abrir, Guardar, PNG y Maqueta están en la búsqueda (Buscar) */
@media (max-width: 1380px) { .file-group { display: none; } }
@media (max-width: 960px) { .proj-btn .long { display: none; } .topbar { gap: 6px; padding: 0 8px; } .brand { margin-right: 0; } }

/* ---------- gustos del perfil ---------- */
.acc-sub { margin: 18px 0 2px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.acc-lab { margin: 18px 0 8px; }
.tag-row + .tag-row { margin-top: 4px; }
.acc-sub + .muted + .tag-row { margin-top: 12px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { height: 32px; padding: 0 13px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 13px; transition: all 0.12s ease; }
.tag-chip:hover { color: var(--text); border-color: var(--accent); }
.tag-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.hh-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.hh-tags .tag { padding: 3px 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 12px; }
.hh-tags .tag.role { border-color: var(--accent); color: var(--accent); }
.hh-motto { margin: 8px 0 0; color: var(--muted); font-style: italic; font-size: 13.5px; }

/* Inspiración */
.insp-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:12px;margin:8px 0 22px}
.insp-card{display:flex;flex-direction:column;gap:8px;padding:14px;border:1px solid var(--line,#33343a);border-radius:14px;background:var(--panel,#1b1c1f)}
.insp-card>b{font-size:16px}
.insp-pal{display:flex;height:26px;border-radius:8px;overflow:hidden}
.insp-pal i{flex:1}
.insp-tips{margin:0;padding-left:18px;font-size:13px;line-height:1.4;color:var(--muted,#9a9aa2)}
.insp-furn{display:flex;flex-wrap:wrap;gap:6px}
.insp-card .btn{margin-top:auto}

/* Aprender */
.learn-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:10px;margin:8px 0 22px}
.learn-card{display:flex;flex-direction:column;gap:6px;text-align:left;padding:14px;border:1px solid var(--line,#33343a);border-radius:14px;background:var(--panel,#1b1c1f);color:inherit;font:inherit;cursor:pointer;transition:border-color .15s,transform .15s}
.learn-card:hover{border-color:var(--accent,#f2a93b);transform:translateY(-1px)}
.learn-card.done{opacity:.8}
.learn-card b{font-size:15px}
.lc-top{display:flex;justify-content:space-between;align-items:center;gap:8px}

.share-out{width:100%;box-sizing:border-box;resize:none;font:11px/1.35 ui-monospace,Menlo,monospace;padding:8px;border-radius:8px;border:1px solid var(--line,#33343a);background:var(--bg,#141517);color:inherit;word-break:break-all}

@media (max-width:1500px){#btn-share .long{display:none}}
.lc-top .tag-chip{line-height:1.3;padding:3px 10px}

/* ? de la barra de medidas */
.cmd-help{flex:none;width:26px;height:26px;border-radius:50%;border:1px solid var(--line,#33343a);background:transparent;color:var(--muted,#9a9aa2);font:600 13px/1 inherit;cursor:pointer}
.cmd-help:hover{color:var(--accent,#f2a93b);border-color:var(--accent,#f2a93b)}
.practice{border-style:dashed}
/* Lección con práctica */
.lesson{position:fixed;z-index:60;right:304px;bottom:64px;width:min(340px,calc(100vw - 24px));padding:14px 16px;border-radius:16px;background:var(--panel,#1b1c1f);color:var(--text,inherit);border:1px solid var(--accent,#f2a93b);box-shadow:0 12px 36px rgba(0,0,0,.35);transition:border-color .2s,box-shadow .2s}
.lesson.ok{border-color:#2f9e6b;box-shadow:0 0 0 3px rgba(47,158,107,.35),0 12px 36px rgba(0,0,0,.35)}
.lesson.ok .ls-text::after{content:' ✓';color:#2f9e6b;font-weight:700}
.lesson h3{margin:6px 0}
.lesson p{margin:6px 0;font-size:14px;line-height:1.45}
.ls-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
.ls-badge{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--accent,#f2a93b)}
.ls-dots{display:flex;gap:4px}
.ls-dots i{width:7px;height:7px;border-radius:50%;background:var(--line,#33343a)}
.ls-dots i.on{background:#2f9e6b}.ls-dots i.cur{background:var(--accent,#f2a93b)}
.ls-btns{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:8px}
.ls-btns .spacer{flex:1}
.lesson.done{left:50%;bottom:50%;transform:translate(-50%,50%);width:min(380px,calc(100vw - 24px))}
@media (max-width:960px){.lesson:not(.done){left:12px;right:12px;width:auto;bottom:calc(76px + env(safe-area-inset-bottom))}}

/* Personalizar inicio */
.home-editor{border:1px dashed var(--line,#999);border-radius:12px;padding:12px 14px;margin:12px 0;display:grid;gap:6px}
.home-editor .he-row{display:flex;justify-content:space-between;align-items:center;gap:8px}
.home-editor .he-mv{display:flex;gap:4px}
.pencil-btn[aria-pressed="true"]{background:var(--accent,#f2a93b);color:#1b1c1f}
.cloud-dot{width:9px;height:9px;border-radius:50%;background:#7a7a80;flex:none}
.cloud-dot[data-state="ok"]{background:#2f9e6b;box-shadow:0 0 0 3px rgba(47,158,107,.25)}
.cloud-dot[data-state="sync"],.cloud-dot[data-state="wait"]{background:var(--accent,#f2a93b);animation:cdp 1s infinite}
.cloud-dot[data-state="err"],.cloud-dot[data-state="out"],.cloud-dot[data-state="offline"]{background:#d9534f}
@keyframes cdp{50%{opacity:.35}}

/* Ajustes */
#settings{z-index:25}   /* encima del inicio (z-index 20, va después en el HTML): si no, Ajustes abría escondido detrás */
#settings .home-body{max-width:720px;margin:0 auto}
.set-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:8px 0;flex-wrap:wrap}
.accent-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.accent-sw{width:30px;height:30px;border-radius:50%;border:2px solid transparent;cursor:pointer;padding:0}
.accent-sw.on{border-color:var(--text);box-shadow:0 0 0 2px var(--bg)}
.accent-custom{width:34px;height:30px;padding:0;border:1px solid var(--line);border-radius:8px;background:none;cursor:pointer}

.legal{margin:28px 0 12px;text-align:center;font-size:11px;color:var(--muted,#9a9aa2);opacity:.8}
.home-top-btns{flex-wrap:wrap;justify-content:flex-end}
@media (max-width:700px){.home-top-btns .chip-btn:not(#home-close){padding:4px 8px;font-size:12px}}
.lang-corner{position:fixed;top:14px;right:62px;z-index:25}
