/* Relleu Studio — interfície de l'editor */

:root {
  --ground: #e9ece9;
  --surface: #ffffff;
  --panel: #f5f7f5;
  --text: #121816;
  --muted: #5d6b65;
  --line: #dbe1dd;
  --line-soft: #e8ece9;
  --accent: #1f6b52;
  --accent-soft: #e3efe9;
  --warn: #9a5a12;
  --danger: #a33c2a;
  --shadow: 0 18px 46px -30px rgba(9, 27, 21, .55);
  --r: 10px;
  --ui: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "Archivo", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0c110f;
    --surface: #151b19;
    --panel: #111715;
    --text: #e7ecea;
    --muted: #93a29c;
    --line: #242e2b;
    --line-soft: #1c2422;
    --accent: #55bd9e;
    --accent-soft: #14241f;
    --warn: #d3a251;
    --danger: #e0806c;
    --shadow: 0 18px 46px -30px rgba(0, 0, 0, .8);
  }
}

:root[data-theme="dark"] {
  --ground: #0c110f;
  --surface: #151b19;
  --panel: #111715;
  --text: #e7ecea;
  --muted: #93a29c;
  --line: #242e2b;
  --line-soft: #1c2422;
  --accent: #55bd9e;
  --accent-soft: #14241f;
  --warn: #d3a251;
  --danger: #e0806c;
  --shadow: 0 18px 46px -30px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font-family: var(--ui); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { height: 100%; display: flex; flex-direction: column; }

/* ---------- barra superior ---------- */
.bar {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap;
}
.logo { display: flex; align-items: baseline; gap: 7px; font-family: var(--display); font-weight: 800; font-size: 17px; letter-spacing: -.02em; margin-right: 4px; }
.logo span { font-family: var(--ui); font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.bar .sp { flex: 1 1 auto; }

select.site-pick { max-width: 210px; }
select, input[type="text"], input[type="color"], textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
select { cursor: pointer; }

.btn { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 13px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 9px; font-size: 12px; border-radius: 7px; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { background: none; border: 0; border-radius: 7px; padding: 6px 11px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.state { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 99px; background: var(--accent); }
.dot.off { background: var(--warn); }

/* ---------- estructura ---------- */
.main { flex: 1; display: grid; grid-template-columns: 296px 1fr 320px; min-height: 0; }
.panel { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel.right { border-right: 0; border-left: 1px solid var(--line); }
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 8px; flex: none; }
.panel-head h2 { font-family: var(--display); font-size: 14px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.panel-body { overflow: auto; padding: 12px 14px 60px; display: flex; flex-direction: column; gap: 12px; }

.tabs { display: flex; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); flex: none; }
.tabs button { flex: 1; background: none; border: 0; border-radius: 8px; padding: 7px 4px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- llista de blocs ---------- */
.blk { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 10px; cursor: pointer; }
.blk.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.blk.drag { opacity: .4; }
.blk.over { border-color: var(--accent); border-style: dashed; }
.blk .grip { color: var(--muted); cursor: grab; font-size: 13px; line-height: 1; }
.blk .nm { flex: 1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk .nm small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.blk.hidden .nm { opacity: .5; text-decoration: line-through; }
.iconbtn { background: none; border: 0; padding: 4px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; line-height: 1; }
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); }

.addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.addgrid button { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 11px 9px; text-align: left; font-size: 12px; font-weight: 600; cursor: pointer; }
.addgrid button:hover { border-color: var(--accent); color: var(--accent); border-style: solid; }
.grouplabel { font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* ---------- camps ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field .hint { font-size: 11px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.imgfield { display: flex; gap: 10px; align-items: center; }
.imgfield .thumb { width: 66px; height: 50px; border-radius: 7px; border: 1px solid var(--line); object-fit: cover; background: var(--ground); flex: none; }

.item { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.item > summary { list-style: none; cursor: pointer; padding: 9px 11px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.item > summary::-webkit-details-marker { display: none; }
.item > summary:before { content: "▸"; color: var(--muted); font-size: 11px; }
.item[open] > summary:before { content: "▾"; }
.item .body { padding: 4px 11px 12px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line-soft); }
.item .sum-act { margin-left: auto; display: flex; gap: 2px; }

/* ---------- escenari ---------- */
.stage { background: var(--ground); overflow: auto; display: flex; justify-content: center; padding: 18px; min-height: 0; }
.frame { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; width: 100%; height: 100%; transition: max-width .2s ease; }
.frame.tablet { max-width: 800px; }
.frame.phone { max-width: 412px; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }

/* ---------- targetes de web ---------- */
.sitecard { display: flex; gap: 11px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; cursor: pointer; }
.sitecard.on { border-color: var(--accent); }
.sitecard:hover { border-color: var(--accent); }
.swatch { width: 40px; height: 40px; border-radius: 8px; flex: none; border: 1px solid var(--line); }
.sitecard b { display: block; font-size: 13px; }
.sitecard small { color: var(--muted); font-size: 11px; }

.themecard { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 9px 10px; cursor: pointer; width: 100%; text-align: left; }
.themecard.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.themedots { display: flex; flex: none; }
.themedots i { width: 15px; height: 26px; display: block; border: 1px solid rgba(0, 0, 0, .08); }
.themedots i:first-child { border-radius: 5px 0 0 5px; }
.themedots i:last-child { border-radius: 0 5px 5px 0; }

/* ---------- modals ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 16, 13, .55); display: none; align-items: center; justify-content: center; padding: 18px; z-index: 80; }
.overlay.on { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); width: min(760px, 100%); max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.modal header h3 { margin: 0; font-family: var(--display); font-size: 16px; font-weight: 700; }
.modal .mbody { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal footer { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; justify-content: flex-end; }
.illusgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.illusgrid button { border: 1px solid var(--line); background: none; border-radius: 9px; padding: 0; overflow: hidden; cursor: pointer; }
.illusgrid button:hover { border-color: var(--accent); }
.illusgrid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.illusgrid span { display: block; font-size: 11px; font-weight: 600; padding: 6px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
pre.code { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 11px; line-height: 1.5; max-height: 42vh; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
.note { background: var(--accent-soft); border-radius: 9px; padding: 11px 13px; font-size: 12.5px; color: var(--text); }
.note b { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(16px); background: #11201c; color: #fff; padding: 11px 17px; border-radius: 10px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: .22s ease; z-index: 99; }
.toast.on { opacity: 1; transform: translateX(-50%); }

.iconpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.iconpick button { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 4px; font-size: 9px; cursor: pointer; color: var(--muted); }
.iconpick button.on, .iconpick button:hover { border-color: var(--accent); color: var(--accent); }
.iconpick svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 22px 10px; }

/* ---------- responsiu ---------- */
.mobtabs { display: none; }
@media (max-width: 1180px) {
  .main { grid-template-columns: 268px 1fr 296px; }
}
@media (max-width: 1000px) {
  .main { grid-template-columns: 1fr; position: relative; }
  .panel { position: absolute; inset: 0 auto 0 0; width: min(340px, 86%); z-index: 20; box-shadow: var(--shadow); transform: translateX(-102%); transition: transform .2s ease; }
  .panel.right { inset: 0 0 0 auto; transform: translateX(102%); border-left: 1px solid var(--line); }
  .panel.open { transform: none; }
  .mobtabs { display: inline-flex; }
  .stage { padding: 10px; }
}
@media (max-width: 620px) {
  .bar { padding: 8px 10px; gap: 7px; }
  .logo span, .state span { display: none; }
  .btn { padding: 7px 10px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
