/* Shared tokens and components for Ambientes 3D */
:root {
  --bg: #f5f3ef; --surface: #ffffff; --surface-2: #faf8f5; --ink: #221f1b; --muted: #6d675e; --faint: #9a938a;
  --line: #e4dfd7; --line-strong: #d3ccc1;
  --accent: #8a5a35; --accent-ink: #ffffff; --accent-soft: #f3e9df;
  --danger: #b4382c; --danger-soft: #fbe9e6; --ok: #2f7a4b; --ok-soft: #e5f3ea;
  --canvas: #e9e6e0; --shadow: 0 1px 2px rgba(30, 25, 20, .06), 0 4px 16px rgba(30, 25, 20, .06);
  --shadow-lg: 0 12px 40px rgba(30, 25, 20, .18);
  --r: 10px; --r-sm: 7px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181715; --surface: #22201d; --surface-2: #1d1b19; --ink: #efebe5; --muted: #a8a197; --faint: #7d776e;
    --line: #34312c; --line-strong: #45413a; --accent: #d39c6c; --accent-ink: #1b140e; --accent-soft: #3a2c21;
    --danger: #ef7c6f; --danger-soft: #3d221e; --ok: #7ccb98; --ok-soft: #1f3327; --canvas: #2a2825;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #181715; --surface: #22201d; --surface-2: #1d1b19; --ink: #efebe5; --muted: #a8a197; --faint: #7d776e;
  --line: #34312c; --line-strong: #45413a; --accent: #d39c6c; --accent-ink: #1b140e; --accent-soft: #3a2c21;
  --danger: #ef7c6f; --danger-soft: #3d221e; --ok: #7ccb98; --ok-soft: #1f3327; --canvas: #2a2825;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 500 14px/1 var(--font); height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { border-color: var(--faint); }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }

/* form */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=search], select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 90px; }
.req { color: var(--danger); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20, 16, 12, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .18s; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal header h2 { font-size: 18px; }
.modal .body { padding: 10px 20px 4px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* toast */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 80; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r-sm); box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 10px; align-items: center; animation: pop .18s; }
.toast.error { background: var(--danger); color: #fff; }
.toast a { color: inherit; font-weight: 600; margin-left: auto; }

/* menu */
.menu { position: absolute; z-index: 60; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); padding: 4px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; color: var(--ink); font: inherit; border-radius: 5px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* file drop areas (new ambiente / update files) */
.drops { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.drop { position: relative; border: 1.5px dashed var(--line-strong); border-radius: var(--r); padding: 14px 12px; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color .12s, background .12s; min-height: 116px; display: grid; place-items: center; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.ok { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.drop.bad { border-color: var(--danger); background: var(--danger-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .t { font-weight: 600; margin-top: 4px; }
.drop .s { font-size: 12px; color: var(--muted); word-break: break-all; }
.drop svg { width: 22px; height: 22px; color: var(--muted); }
.drop.ok svg { color: var(--ok); }
.xml-info { font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; margin: -4px 0 14px; }
.xml-info.warn { color: var(--ink); background: var(--danger-soft); border-color: var(--danger); }
.keep-list { font-size: 13px; color: var(--muted); margin: 0 0 4px; padding-left: 18px; }
.keep-list li { margin: 2px 0; }
.changes { font-size: 13px; max-height: 260px; overflow: auto; }
.changes h3 { font-size: 13px; margin: 10px 0 4px; }
.changes ul { margin: 0; padding-left: 18px; }
.changes .plus { color: var(--ok); } .changes .minus { color: var(--danger); }
@media (max-width: 720px) { .drops { grid-template-columns: 1fr; } }

/* user chip (top bars) */
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; height: auto; }
.user-chip .av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-chip .lbl { display: grid; text-align: left; line-height: 1.15; }
.user-chip .lbl b { font-size: 13px; font-weight: 600; }
.user-chip .lbl small { font-size: 11px; color: var(--muted); }
@media (max-width: 720px) { .user-chip .lbl { display: none; } .user-chip { padding: 4px; } }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.badge svg { width: 12px; height: 12px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, #e8a33d 18%, transparent); color: #b06d0a; }
.badge.muted { background: var(--surface-2); color: var(--muted); }
