@font-face { font-family: Geist; src: url(fonts/geist.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: Fraunces; src: url(fonts/fraunces.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  --bg: #f6f3ee; --paper: #fffdf9; --ink: #1d1a16; --soft: #6d645a; --line: #e4ddd2; --line2: #d4cabb;
  --accent: #b4623f; --accent-ink: #fff; --ok: #3d7a4f; --bad: #b23a2c;
  --serif: Fraunces, Georgia, serif; --sans: Geist, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --top: 60px; --left: 330px; --right: 310px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--soft); }
.small { font-size: 12px; }

/* Barra superior */
.top { position: fixed; inset: 0 0 auto 0; height: var(--top); display: flex; align-items: center; gap: 18px; padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--line); z-index: 20; }
.brand { text-decoration: none; color: var(--ink); white-space: nowrap; }
.logo { font-family: var(--serif); font-size: 21px; letter-spacing: -0.01em; }
.logo em { font-style: italic; }
.title { font: 500 13px/1 var(--sans); color: var(--soft); margin: 0; padding-left: 18px; border-left: 1px solid var(--line); white-space: nowrap; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-left: auto; }
.seg button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; font-weight: 500; color: var(--soft); white-space: nowrap; }
.seg button[aria-selected='true'] { background: var(--ink); color: #fff; }
.actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; }
.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon:disabled { opacity: 0.35; cursor: default; }
.icon:not(:disabled):hover { border-color: var(--line2); background: #fff; }
#lang { height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); padding: 0 8px; text-transform: uppercase; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--ink); background: var(--paper); font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: var(--line2); background: transparent; }
.btn.wide { width: 100%; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }

/* Distribución */
.app { position: fixed; inset: var(--top) 0 0 0; display: grid; grid-template-columns: var(--left) 1fr var(--right); }
.panel { background: var(--paper); overflow: auto; overscroll-behavior: contain; }
.left { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.right { border-left: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 22px; }
.stage { position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; }
#plan2d canvas { display: block; touch-action: none; cursor: grab; }
#view3d canvas { display: block; touch-action: none; }

.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 2; }
.tabs button { flex: 1; border: 0; background: none; padding: 14px 8px 12px; font-weight: 500; color: var(--soft); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }

input[type='search'], input[type='number'], .field input, .field textarea, .field select { width: 100%; height: 40px; border: 1px solid var(--line2); border-radius: 10px; background: #fff; padding: 0 12px; }
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--soft); text-transform: uppercase; letter-spacing: 0.04em; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line2); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { position: relative; display: flex; flex-direction: column; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0; overflow: hidden; cursor: grab; transition: border-color 0.15s, transform 0.15s; }
.card:hover { border-color: var(--line2); transform: translateY(-1px); }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #efebe4; display: block; }
.card .ct { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.card strong { font-weight: 600; font-size: 13px; line-height: 1.25; }
.card span { font-size: 11.5px; color: var(--soft); }
.card .plus { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-size: 17px; line-height: 1; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.card .new { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 999px; }

.elements { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.elements button { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--line2); background: #fff; border-radius: 10px; padding: 9px 10px; font-size: 13px; text-align: left; }
.elements i { width: 16px; height: 16px; border-radius: 4px; flex: none; }

/* Panel derecho */
.right h2 { font: 400 22px/1.15 var(--serif); margin: 0 0 4px; }
.right h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--soft); margin: 14px 0 8px; }
#sel { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; }
#sel .thumb { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; background: #efebe4; margin-bottom: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line2); padding: 0; }
.swatches button.on { box-shadow: 0 0 0 2px var(--accent); }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tools .btn { flex: 1 1 auto; }
.link { color: var(--accent); font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; }
.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lines li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); cursor: pointer; }
.lines li:hover strong { color: var(--accent); }
.lines .q { font-weight: 600; min-width: 26px; text-align: center; background: var(--bg); border-radius: 6px; padding: 2px 6px; font-size: 12px; }
.lines strong { font-weight: 500; display: block; font-size: 13px; }
.lines span { font-size: 12px; color: var(--soft); }
.lines .pr { font-size: 12px; white-space: nowrap; }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--ink); padding-top: 10px; margin-top: 4px; }
.total b { font: 400 20px var(--serif); }
.empty { color: var(--soft); border: 1px dashed var(--line2); border-radius: 12px; padding: 18px; text-align: center; }

/* Escenario */
.help { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; background: rgba(255, 253, 249, 0.92); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 12px; color: var(--soft); white-space: nowrap; pointer-events: none; }
.warn { position: absolute; top: 12px; left: 12px; max-width: min(420px, calc(100% - 24px)); background: #fff4f1; border: 1px solid #efc6bd; color: var(--bad); border-radius: 12px; padding: 8px 12px; font-size: 12.5px; }
.warn p { margin: 2px 0; }
.hour { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; gap: 10px; background: rgba(255, 253, 249, 0.94); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 12px; color: var(--soft); }
.hour input { width: 150px; accent-color: var(--accent); }
.hour output { font-weight: 600; color: var(--ink); min-width: 38px; }

/* Modales */
.modal { border: 0; border-radius: 18px; padding: 26px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.modal::backdrop { background: rgba(29, 26, 22, 0.45); }
.modal h2 { font: 400 26px/1.15 var(--serif); margin: 0 0 8px; padding-right: 30px; }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.close { position: absolute; top: 14px; right: 16px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--soft); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check a { color: var(--accent); }
.hp { position: absolute; left: -9999px; }
.qsum { background: var(--bg); border-radius: 12px; padding: 10px 14px; font-size: 13px; max-height: 150px; overflow: auto; }
.qsum p { margin: 2px 0; }
.status { margin: 0; font-size: 13px; min-height: 1em; }
.status.ok { color: var(--ok); } .status.bad { color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: 0.25s; z-index: 50; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.dock { display: none; }
.sh { display: none; }

@media (max-width: 1180px) { :root { --left: 290px; --right: 270px; } .title { display: none; } }
@media (max-width: 900px) {
  :root { --top: 56px; }
  .top { gap: 8px; padding: 0 10px; }
  .logo { font-size: 18px; }
  .seg { margin-left: 0; }
  .seg button { padding: 6px 12px; font-size: 13px; }
  .lg { display: none; }
  .sh { display: inline !important; }
  .actions { gap: 4px; }
  #image, #redo, #lang { display: none; }
  #quote { padding: 0 12px; height: 36px; font-size: 13px; }
  .app { grid-template-columns: 1fr; bottom: 56px; }
  .panel { position: fixed; left: 0; right: 0; bottom: 56px; max-height: 62dvh; border: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12); transform: translateY(105%); transition: transform 0.25s; z-index: 15; }
  .panel.open { transform: none; }
  .help { display: none; }
  .dock { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; inset: auto 0 0 0; height: 56px; background: var(--paper); border-top: 1px solid var(--line); z-index: 16; padding-bottom: env(safe-area-inset-bottom); }
  .dock button { border: 0; background: none; font-weight: 500; color: var(--soft); }
  .dock button.on { color: var(--accent); }
  .hour input { width: 100px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (max-width: 420px) { .brand { display: none; } }
/* Piezas de un conjunto en el panel de la selección */
#sel .pieces { margin-top: 2px; }
#sel .pieces button { font-size: 12px; padding: 5px 10px; }
#sel .hint { margin: 7px 0 0; line-height: 1.4; }
