:root {
  --ink: #35251b;
  --ink-soft: #4f3b2d;
  --cream: #f8f1e5;
  --cream-2: #eddfcd;
  --paper: #fffaf2;
  --gold: #b4874f;
  --gold-soft: #ddc39a;
  --rose: #c58e7b;
  --clay: #a65f46;
  --clay-dark: #8c4d39;
  --canvas: #d8c3a7;
  --canvas-2: #e8d9c3;
  --muted: #7c6a59;
  --line: rgba(53, 37, 27, 0.12);
  --line-strong: rgba(53, 37, 27, 0.2);
  --shadow: 0 24px 60px rgba(39, 28, 17, 0.12);
  --shadow-soft: 0 10px 30px rgba(39, 28, 17, 0.07);
  --serif: "Didot", "Bodoni 72", "Playfair Display", Georgia, "DejaVu Serif", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 24px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  background:
    radial-gradient(900px 620px at 8% -12%, #fffaf0 0%, rgba(255, 250, 240, 0) 62%),
    radial-gradient(820px 620px at 106% -4%, #f3ded6 0%, rgba(243, 222, 214, 0) 56%),
    radial-gradient(760px 520px at 50% 112%, #efe2cc 0%, rgba(239, 226, 204, 0) 60%),
    var(--cream);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }
img, video { max-width: 100%; }

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ---------- Login ---------- */

.login-page {
  display: grid;
  place-items: center;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  text-align: center;
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.brand-mark {
  width: 76px;
  height: 76px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.7);
  color: var(--gold);
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.12em;
  box-shadow: inset 0 0 0 4px rgba(255, 253, 248, 0.8);
}

.login-shell h1 {
  margin: 12px 0 6px;
  font-family: var(--serif);
  font-size: clamp(38px, 9vw, 56px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.login-shell h1 em {
  display: block;
  font-style: italic;
  color: var(--gold);
}

.lede {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 26px;
  text-align: left;
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid rgba(173, 133, 72, 0.24);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.field { display: grid; gap: 7px; }
.field > span {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

input, textarea, select {
  width: 100%;
  padding: 13px 15px;
  color: var(--ink);
  font-size: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(173, 133, 72, 0.16);
}

textarea { min-height: 104px; resize: vertical; line-height: 1.5; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--clay);
  color: var(--cream);
  border-color: var(--clay);
}
.btn-primary:hover:not(:disabled) { background: var(--clay-dark); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

.fineprint {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.error {
  margin: 0;
  padding: 10px 12px;
  color: #8a2f25;
  background: rgba(201, 143, 134, 0.16);
  border: 1px solid rgba(201, 143, 134, 0.35);
  border-radius: 12px;
  font-size: 13px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 242, 233, 0.8);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-inner {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.logo .mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.08em;
  background: rgba(255, 253, 248, 0.7);
}

.logo .name {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.logo .name em { color: var(--gold); font-style: italic; }

.header-actions { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Layout ---------- */

main {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 26px 20px calc(70px + env(safe-area-inset-bottom));
}

.hero { padding: 14px 0 26px; }

.hero h2 {
  margin: 12px 0 12px;
  font-family: var(--serif);
  font-size: clamp(34px, 6.4vw, 60px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.025em;
  max-width: 760px;
}
.hero h2 em { color: var(--gold); font-style: italic; }

.hero p {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Editor ---------- */

.editor-card {
  display: grid;
  gap: 20px;
  padding: 22px;
  background: rgba(255, 253, 248, 0.84);
  border: 1px solid rgba(173, 133, 72, 0.22);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: rise 0.6s 0.08s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  border: 1.5px dashed rgba(173, 133, 72, 0.5);
  border-radius: 20px;
  background:
    radial-gradient(340px 160px at 50% 0%, rgba(217, 187, 142, 0.2), transparent 70%),
    rgba(255, 253, 248, 0.5);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--gold);
  background-color: rgba(255, 250, 240, 0.9);
  outline: none;
}
.dropzone.drag { transform: scale(1.005); }

.drop-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--clay);
  color: var(--cream);
}
.drop-icon svg { width: 22px; height: 22px; }

.dropzone .big {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: -0.01em;
}
.dropzone .hint { margin: 0; }

.hint { color: var(--muted); font-size: 12px; }

.selected {
  display: grid;
  gap: 8px;
}

.selected-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.selected-thumb {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--cream-2);
}

.selected-meta { min-width: 0; flex: 1; }
.selected-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selected-size { font-size: 11px; color: var(--muted); }

.selected-thumb.video {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.mini-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.mini-btn:hover { border-color: var(--rose); color: var(--rose); }

.section-label {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}
.chip:hover { border-color: var(--gold-soft); }
.chip:active { transform: scale(0.98); }
.chip[aria-pressed="true"] {
  background: var(--clay);
  border-color: var(--clay);
  color: var(--cream);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.submit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.submit-row .hint { max-width: 300px; }

/* ---------- Results ---------- */

.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 42px 0 16px;
}
.results-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.jobs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 18px;
}

.job-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.job-media {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--cream-2);
  overflow: hidden;
}
.job-media img, .job-media video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.job-media video { object-fit: contain; background: #2d2118; }

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(24, 20, 16, 0.82);
  color: var(--cream);
  backdrop-filter: blur(6px);
}
.badge.done { background: rgba(58, 92, 64, 0.9); }
.badge.error { background: rgba(138, 47, 37, 0.9); }
.badge.running { background: rgba(173, 133, 72, 0.95); color: #1f1913; }

.job-body { display: grid; gap: 10px; padding: 14px; }
.job-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.job-sub { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.job-plan { margin: 0; font-size: 11px; color: var(--gold); line-height: 1.4; }

.job-actions { display: flex; flex-wrap: wrap; gap: 7px; }

.btn-small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.btn-small:hover { border-color: var(--gold); color: var(--gold); }
.btn-small.solid { background: var(--clay); border-color: var(--clay); color: var(--cream); }
.btn-small.danger:hover { border-color: var(--rose); color: var(--rose); }

.skeleton {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 20px;
  text-align: center;
  background: linear-gradient(110deg, #efe4d3 8%, #f8f0e4 18%, #efe4d3 33%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  margin: 26px 0;
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  font-size: 14px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font-size: 13px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
  animation: rise 0.25s ease both;
}
.toast.bad { background: #7d2b22; }

/* ---------- Animations ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .header-inner { padding: 12px 16px; }
  .logo .name { font-size: 17px; }
  .logo .mark { width: 34px; height: 34px; font-size: 10px; }
  main { padding: 18px 16px calc(60px + env(safe-area-inset-bottom)); }
  .hero { padding: 8px 0 20px; }
  .editor-card { padding: 16px; border-radius: 24px; gap: 16px; }
  .dropzone { padding: 26px 14px; }
  .dropzone .big { font-size: 19px; }
  .form-row { grid-template-columns: 1fr; }
  .jobs { grid-template-columns: 1fr; }
  .job-media { aspect-ratio: 1 / 1; }
  .submit-row { align-items: stretch; }
  .submit-row .btn-primary { width: 100%; }
  .submit-row .hint { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Idioma, asesor y generativa ---------- */

.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.55);
}

.lang-switch button {
  min-width: 34px;
  padding: 5px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.lang-switch button.active {
  background: var(--clay);
  color: var(--cream);
}

.login-lang {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  z-index: 30;
}

.header-actions {
  align-items: center;
}

.advice {
  padding: 18px;
  border: 1px solid rgba(173, 133, 72, 0.36);
  border-radius: 20px;
  background:
    radial-gradient(420px 180px at 0% 0%, rgba(217, 187, 142, 0.22), transparent 70%),
    rgba(255, 253, 248, 0.78);
  animation: rise 0.35s ease both;
}

.advice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.advice-kicker {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.advice-loading {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.advice-score {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--clay);
  color: var(--cream);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.advice-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.advice-list li {
  position: relative;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

.advice-list li::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.advice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn-small.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #1f1913;
}

.gen-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.45);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 42px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.2s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--gold);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:disabled + .switch-track {
  opacity: 0.4;
}

.gen-row .hint {
  flex: 1;
  min-width: 190px;
  margin: 0;
}

@media (max-width: 430px) {
  .logo-brand { display: none; }
  .logo .name { font-size: 18px; }
  .lang-switch button { min-width: 30px; padding: 5px 6px; }
  .advice { padding: 14px; }
  .advice-list li { font-size: 12.5px; }
}

/* ---------- Motor de IA y gasto ---------- */

.engine {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(173, 133, 72, 0.3);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(217, 187, 142, 0.14), rgba(255, 253, 248, 0.6));
}

.engine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.engine-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.engine-mode {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.engine .hint {
  margin: 0;
}

.spend {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.spend-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#spend-value {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.spend-note {
  font-size: 10px;
  color: var(--muted);
}

.job-ai {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.spend-deepseek {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Editor manual ---------- */

.manual {
  scroll-margin-top: 84px;
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(24, 20, 16, 0.16);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.72);
  animation: rise 0.35s ease both;
}

.manual-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.manual-kicker {
  margin: 0 0 3px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: -0.01em;
}

.manual-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.manual-stage {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 14px;
  background: #2d2118;
  line-height: 0;
  touch-action: pan-y;
}

.manual-stage img {
  display: block;
  width: 100%;
  height: auto;
}

.manual-stage.loading img {
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.crop-overlay {
  position: absolute;
  z-index: 2;
  touch-action: none;
}

.crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 9999px rgba(53, 37, 27, 0.52);
  cursor: move;
  touch-action: none;
}

.crop-handle {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  touch-action: none;
}

.crop-handle.nw { top: -10px; left: -10px; cursor: nwse-resize; }
.crop-handle.ne { top: -10px; right: -10px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -10px; left: -10px; cursor: nesw-resize; }
.crop-handle.se { bottom: -10px; right: -10px; cursor: nwse-resize; }

.crop-controls {
  display: grid;
  gap: 10px;
}

.crop-aspects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crop-aspects .chip {
  padding: 7px 11px;
  font-size: 12px;
}

.crop-aspects .chip[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: #1f1913;
}

.crop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manual-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sliders {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.slider-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
}

.slider-name {
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.slider-row input[type="range"] {
  width: 100%;
  min-width: 0;
  margin: 0;
  accent-color: var(--gold);
  appearance: auto;
  -webkit-appearance: auto;
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}

.slider-row output {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (max-width: 520px) {
  .manual { padding: 14px; }
  .slider-row { grid-template-columns: 78px minmax(0, 1fr) 42px; gap: 8px; }
  .slider-name { font-size: 11px; }
  .manual-head { align-items: stretch; }
  .manual-tools { width: 100%; }
  .manual-tools .btn-small { flex: 1; }
}

.manual-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.45);
}

.manual-toggle-row .hint {
  margin: 0;
  text-align: right;
  flex: 1;
}

@media (max-width: 520px) {
  .manual-toggle-row { align-items: flex-start; flex-direction: column; }
  .manual-toggle-row .hint { text-align: left; }
}

/* ---------- Workspace: foto fija + controles ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 22px;
  align-items: start;
}

.workspace.no-preview {
  grid-template-columns: minmax(0, 1fr);
}

.workspace-preview {
  position: sticky;
  top: 80px;
  z-index: 12;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(173, 133, 72, 0.3);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.workspace-preview[hidden] {
  display: none;
}

.preview-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.preview-title {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.preview-caption {
  color: var(--muted);
  font-size: 11px;
}

.workspace-preview .manual-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 72vh;
  border-radius: 16px;
  background: #2d2118;
}

.workspace-preview .manual-stage img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.has-photo .hero {
  display: none;
}

.has-photo main {
  padding-top: 18px;
}

#change-photo {
  justify-self: start;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .workspace-preview {
    top: 64px;
    padding: 8px;
    border-radius: 18px;
    max-height: 48vh;
  }

  .workspace-preview .manual-stage {
    max-height: 38vh;
  }

  .workspace-preview .manual-stage img {
    max-height: 38vh;
  }

  .has-photo main {
    padding-top: 10px;
  }
}

/* ---------- Comparador antes/después ---------- */

.compare-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(53, 37, 27, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.compare-modal[hidden] {
  display: none !important;
}

.compare-dialog {
  width: min(920px, 100%);
  max-height: 94vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}

.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compare-head p {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
}

.compare-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 68vh;
  overflow: hidden;
  border-radius: 14px;
  background: #2d2118;
}

.compare-stage > img,
.compare-after-clip > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.compare-after-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  clip-path: inset(0 0 0 var(--split, 50%));
}

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 50%);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.compare-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#compare-range {
  width: 100%;
  accent-color: var(--gold);
}

.compare-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 640px) {
  .compare-modal { padding: 8px; }
  .compare-dialog { padding: 12px; max-height: 96vh; }
  .compare-stage { aspect-ratio: 3 / 4; max-height: 62vh; }
}

.badge.kept {
  left: auto;
  right: 10px;
  background: rgba(173, 133, 72, 0.95);
  color: #1f1913;
}

.compare-actions a {
  text-decoration: none;
}

/* ---------- Studio shell ---------- */

.studio-main {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(350px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.canvas {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100vh - 112px);
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(180, 135, 79, 0.28);
  border-radius: 28px;
  background: linear-gradient(145deg, var(--canvas-2) 0%, #ddcab0 58%, var(--canvas) 100%);
  box-shadow: 0 24px 60px rgba(90, 60, 35, 0.16);
}

.canvas-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.canvas .preview-title {
  color: var(--gold);
}

.canvas .preview-caption {
  color: var(--ink-soft);
}

.canvas .dropzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 320px;
  margin: 0;
  padding: 28px;
  border: 1.5px dashed rgba(180, 135, 79, 0.5);
  border-radius: 20px;
  background: rgba(255, 250, 242, 0.36);
  color: var(--ink);
}

.canvas .dropzone:hover,
.canvas .dropzone:focus-visible,
.canvas .dropzone.drag {
  border-color: var(--gold);
  background: rgba(255, 250, 242, 0.62);
}

.canvas .drop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-bottom: 4px;
  border: 1px solid rgba(180, 135, 79, 0.5);
  border-radius: 50%;
  background: rgba(255, 250, 242, 0.55);
  color: var(--gold);
}

.canvas .drop-icon svg { width: 22px; height: 22px; }

.canvas .dropzone .big {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
}

.canvas .dropzone .hint {
  color: var(--muted);
  font-size: 11px;
}

.canvas .selected {
  gap: 8px;
}

.canvas .selected-row {
  border-color: rgba(53, 37, 27, 0.12);
  background: rgba(255, 250, 242, 0.52);
}

.canvas .selected-name { color: var(--ink); }
.canvas .selected-size { color: var(--muted); }

.canvas #change-photo {
  align-self: flex-start;
  border-color: rgba(53, 37, 27, 0.2);
  color: var(--ink-soft);
}

.canvas .manual-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  max-height: calc(100vh - 240px);
  border-radius: 18px;
  background: transparent;
}

.canvas .manual-stage img {
  max-width: 100%;
  max-height: calc(100vh - 240px);
  width: auto;
  height: auto;
}

.canvas-note {
  margin: 0;
  color: rgba(53, 37, 27, 0.52);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-align: center;
}

.inspector {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(173, 133, 72, 0.22);
  border-radius: 28px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 18px 46px rgba(40, 28, 16, 0.12);
  scrollbar-width: thin;
}

.inspector-tabs {
  position: sticky;
  top: -14px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: -2px -2px 0;
  padding: 5px;
  border-radius: 15px;
  background: #eee5d7;
}

.inspector-tabs button {
  min-width: 0;
  padding: 9px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.inspector-tabs button[aria-selected="true"] {
  background: var(--clay);
  color: var(--cream);
  box-shadow: 0 4px 12px rgba(33, 27, 21, 0.2);
}

.inspector-panels,
.inspector-panel {
  display: grid;
  gap: 14px;
}

.inspector-panels {
  padding-bottom: 64px;
}

.inspector-panel[hidden] {
  display: none !important;
}

.inspector .manual-toggle-row {
  background: rgba(247, 242, 233, 0.6);
}

.inspector .advice,
.inspector .manual {
  padding: 14px;
  border-radius: 18px;
}

.inspector .manual-kicker {
  font-size: 18px;
}

.inspector .manual-stage {
  display: none !important;
}

.inspector .sliders {
  gap: 8px;
}

.inspector .engine {
  padding: 14px;
}

.inspector .form-row {
  gap: 10px;
}

.inspector .submit-row {
  position: sticky;
  bottom: -14px;
  z-index: 4;
  margin: 0 -2px -2px;
  padding: 12px 2px 2px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0), rgba(255, 253, 248, 0.98) 28%);
}

.inspector .submit-row .btn {
  width: 100%;
}

.studio-main > section[aria-label="Jobs"] {
  margin-top: 26px;
}

.studio-main .jobs {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  scroll-snap-type: x mandatory;
}

.studio-main .job-card {
  flex: 0 0 250px;
  scroll-snap-align: start;
}

@media (max-width: 1000px) {
  .studio {
    grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.8fr);
  }
}

@media (max-width: 900px) {
  .studio-main {
    width: 100%;
    padding: 10px 10px 88px;
  }

  .studio {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .canvas {
    top: 58px;
    z-index: 12;
    min-height: 0;
    padding: 10px;
    border-radius: 20px;
  }

  .canvas .manual-stage {
    max-height: 38vh;
  }

  .canvas .manual-stage img {
    max-height: 38vh;
  }

  .canvas .dropzone {
    min-height: 36vh;
    padding: 18px;
  }

  .canvas-note {
    display: none;
  }

  .inspector {
    position: relative;
    top: 0;
    max-height: none;
    overflow: visible;
    padding: 12px;
    border-radius: 20px;
  }

  .inspector-tabs {
    top: -12px;
  }

  .inspector .submit-row {
    bottom: -12px;
  }

  .studio-main .job-card {
    flex-basis: 220px;
  }
}

@media (max-width: 900px) {
  .canvas {
    height: 46vh;
    max-height: 46vh;
    min-height: 0;
    padding: 8px;
    gap: 6px;
  }

  .canvas .manual-stage {
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  .canvas .manual-stage img {
    max-height: 100%;
  }

  .canvas .selected-row {
    padding: 4px 6px;
  }

  .canvas .selected-thumb {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .canvas .selected-name { font-size: 11px; }
  .canvas .selected-size { font-size: 9px; }

  .canvas #change-photo {
    padding: 5px 9px;
    font-size: 10px;
  }

  .canvas .dropzone {
    min-height: 0;
    padding: 14px;
  }

  .canvas .dropzone .big { font-size: 20px; }

  .canvas .dropzone .hint {
    font-size: 9px;
    max-width: 280px;
  }

  .canvas .drop-icon {
    width: 34px;
    height: 34px;
  }

  .canvas .drop-icon svg {
    width: 18px;
    height: 18px;
  }

  .canvas .selected {
    gap: 4px;
  }

  .inspector-tabs {
    top: calc(58px + 46vh - 1px);
    z-index: 13;
  }

  .inspector-panels {
    padding-bottom: 76px;
  }
}

.canvas-head-name,
.canvas-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.canvas-file {
  max-width: 190px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-clear {
  width: 25px;
  min-width: 25px;
  height: 25px;
  padding: 0;
  border-color: rgba(53, 37, 27, 0.18);
  background: transparent;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1;
}

.inspector .submit-row .btn {
  min-height: 48px;
  padding: 12px 18px;
}

@media (max-width: 900px) {
  .inspector .submit-row .hint {
    display: none;
  }

  .inspector-panels {
    padding-bottom: 64px;
  }
}

@media (max-width: 900px) {
  .inspector .submit-row {
    position: sticky;
    bottom: 8px;
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding: 0;
    background: transparent;
  }

  .inspector .submit-row .btn {
    width: auto;
    min-width: 150px;
    min-height: 46px;
    padding: 11px 20px;
    box-shadow: 0 12px 28px rgba(28, 20, 12, 0.28);
  }
}

.studio-main .job-media {
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

.studio-main .job-media img,
.studio-main .job-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.studio-main .job-card .job-plan {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@media (max-width: 900px) {
  body.library-visible .canvas,
  body.library-visible .inspector {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }
}

.logo .name {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.logo-title {
  white-space: nowrap;
}

.app-version {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.7);
  color: var(--gold);
  font-family: var(--sans);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.25;
  text-transform: lowercase;
  white-space: nowrap;
}

.login-version {
  margin-left: 8px;
  vertical-align: middle;
  font-size: 9px;
}

@media (max-width: 520px) {
  .logo .name { gap: 6px; }
  .app-version { padding: 1px 5px; font-size: 7px; }
}

.inspector-empty {
  display: grid;
  gap: 6px;
  padding: 28px 18px;
  border: 1px dashed var(--gold-soft);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.55);
  text-align: center;
}

.inspector-empty-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
}

.inspector-empty .hint {
  max-width: 260px;
  margin: 0 auto;
}

.login-title-a,
.login-title-b {
  display: block;
}

.login-title-b {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.login-shell h1 em {
  display: inline;
}

.login-title-b .login-version {
  margin-left: 0;
}

.logo .mark {
  object-fit: cover;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

img.brand-mark {
  object-fit: cover;
  border: 0;
  background: transparent;
  box-shadow: 0 10px 24px rgba(90, 60, 35, 0.16);
}

/* ---------- App de una sola pantalla + biblioteca ---------- */

body.app-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.app-page .site-header { flex: 0 0 auto; }

.app-page main.studio-main {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: flex;
  padding: 12px 16px 14px;
  overflow: hidden;
}

.app-page .studio {
  flex: 1;
  height: 100%;
  min-height: 0;
}

.app-page .canvas {
  position: relative;
  top: auto;
  height: 100%;
  min-height: 0;
  max-height: none;
}

.app-page .canvas .manual-stage {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.app-page .canvas .manual-stage img {
  max-height: 100%;
}

.app-page .inspector {
  position: relative;
  top: auto;
  height: 100%;
  max-height: none;
  overflow: hidden;
  padding: 12px;
}

.app-page .inspector-tabs {
  position: static;
  top: auto;
  margin: 0;
}

.app-page .inspector-panels {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: 0;
  align-content: start;
}

.app-page .inspector .submit-row {
  position: static;
  bottom: auto;
  margin-top: 8px;
  padding: 8px 0 0;
  background: transparent;
  flex: 0 0 auto;
}

.library-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
}

.library-trigger svg {
  width: 18px;
  height: 18px;
}

.library-count {
  position: absolute;
  top: -1px;
  right: -1px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--clay);
  color: var(--cream);
  font-size: 8px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

.library-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(53, 37, 27, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.library-drawer[hidden] { display: none !important; }

.library-dialog {
  width: min(1100px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(180, 135, 79, 0.3);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(53, 37, 27, 0.28);
}

.library-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.library-head h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
}

.library-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.library-dialog .jobs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  overflow: auto;
  padding: 2px 4px 12px;
  max-height: calc(90vh - 128px);
}

.library-dialog .job-card {
  min-width: 0;
}

.library-dialog .job-media {
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

.library-dialog .job-media img,
.library-dialog .job-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 900px) {
  .app-page main.studio-main {
    padding: 6px 8px 8px;
  }

  .app-page .studio {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 40%) minmax(0, 60%);
    gap: 8px;
  }

  .app-page .canvas {
    height: 100%;
    max-height: none;
    padding: 8px;
    gap: 5px;
  }

  .app-page .canvas .dropzone {
    min-height: 0;
    padding: 12px;
  }

  .app-page .canvas .manual-stage {
    max-height: none;
    flex: 1;
  }

  .app-page .canvas .manual-stage img {
    max-height: 100%;
  }

  .app-page .inspector {
    height: 100%;
    padding: 9px;
    gap: 7px;
  }

  .app-page .inspector-tabs {
    position: static;
    top: auto;
    padding: 4px;
  }

  .app-page .inspector-tabs button {
    padding: 8px 4px;
    font-size: 10px;
  }

  .app-page .inspector-panels {
    overflow: auto;
    padding-bottom: 0;
    gap: 8px;
  }

  .app-page .inspector .submit-row {
    position: static;
    bottom: auto;
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
    padding: 4px 0 0;
    background: transparent;
  }

  .app-page .inspector .submit-row .btn {
    min-height: 40px;
    min-width: 140px;
    padding: 9px 16px;
  }

  .app-page .manual-toggle-row {
    padding: 7px 9px;
  }

  .app-page .manual-toggle-row .hint {
    display: none;
  }

  .app-page .manual {
    padding: 10px;
    gap: 8px;
  }

  .app-page .manual-head {
    align-items: center;
  }

  .app-page .manual-kicker {
    font-size: 16px;
  }

  .app-page .manual-tools {
    gap: 4px;
  }

  .app-page .manual-tools .btn-small,
  .app-page .manual-actions .btn-small {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 10px;
  }

  .app-page .sliders {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 8px;
  }

  .app-page .slider-row {
    grid-template-columns: 58px minmax(0, 1fr) 28px;
    gap: 3px;
  }

  .app-page .slider-name { font-size: 9px; }
  .app-page .slider-row output { font-size: 8px; }

  .app-page .inspector .advice {
    padding: 10px;
  }

  .app-page .advice-list {
    font-size: 11px;
  }

  .library-dialog {
    max-height: 94vh;
    padding: 12px;
    border-radius: 20px;
  }

  .library-head h2 { font-size: 24px; }

  .library-dialog .jobs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: calc(94vh - 110px);
  }

  .library-dialog .job-body {
    padding: 10px;
  }

  .library-dialog .job-plan,
  .library-dialog .job-ai {
    display: none;
  }

  .library-dialog .job-actions {
    gap: 4px;
  }

  .library-dialog .job-actions .btn-small {
    padding: 5px 8px;
    font-size: 10px;
  }
}

.advice-toggle,
.advice-close {
  display: none;
}

@media (max-width: 900px) {
  .app-page .studio {
    grid-template-rows: minmax(0, 35%) minmax(0, 65%);
  }

  .app-page .advice-toggle,
  .app-page .advice-close {
    display: inline-flex;
  }

  .app-page .advice-toggle {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 10px;
  }

  .app-page #advice {
    display: none;
  }

  .app-page.advice-open #advice {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 70;
    display: grid;
    max-height: 58vh;
    overflow: auto;
    padding: 14px;
    border-radius: 20px;
    background: var(--paper);
    box-shadow: 0 24px 70px rgba(53, 37, 27, 0.3);
  }
}

/* El asesor es un panel flotante opcional: no empuja el layout. */
.app-page .advice-toggle,
.app-page .advice-close {
  display: inline-flex;
}

.app-page #advice {
  display: none;
}

.app-page.advice-open #advice {
  position: fixed;
  right: 20px;
  bottom: 20px;
  left: auto;
  top: auto;
  z-index: 70;
  display: grid;
  width: min(460px, calc(100vw - 20px));
  max-height: 70vh;
  overflow: auto;
  padding: 16px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 28px 80px rgba(53, 37, 27, 0.3);
}

.app-page .sliders {
  gap: 4px;
}

@media (max-width: 900px) {
  .app-page.advice-open #advice {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: 58vh;
  }
}

.draft-saved {
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Sliders compactos en dos columnas: caben sin scroll en el panel. */
.app-page .sliders {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
}

.app-page .slider-row {
  grid-template-columns: 58px minmax(0, 1fr) 28px;
  gap: 3px;
}

.app-page .slider-name {
  font-size: 9px;
}

.app-page .slider-row output {
  font-size: 8px;
}

.app-page .submit-row #library-button {
  margin-right: auto;
}

.render-review {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.render-review[hidden] {
  display: none !important;
}

.render-review .btn {
  min-height: 46px;
}

@media (max-width: 900px) {
  .app-page .submit-row #library-button {
    min-width: 40px;
    padding: 8px 10px;
  }

  .render-review {
    justify-content: flex-end;
  }

  .render-review .btn {
    min-height: 40px;
    padding: 9px 14px;
  }
}

/* El asesor aparece solo cuando hay datos, sin ocupar layout. */
.app-page #advice {
  position: fixed;
  left: 20px;
  right: auto;
  bottom: 20px;
  z-index: 70;
  display: grid;
  width: min(460px, calc(100vw - 20px));
  max-height: 70vh;
  overflow: auto;
  padding: 16px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 28px 80px rgba(53, 37, 27, 0.3);
}

.app-page #advice[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-page #advice {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 58vh;
  }
}

/* El asesor se abre arriba, sobre el lienzo, para no tapar las acciones. */
.app-page #advice {
  top: 92px;
  bottom: auto;
}

@media (max-width: 900px) {
  .app-page #advice {
    top: calc(58px + 8px);
    bottom: auto;
    max-height: 50vh;
  }
}

.render-note {
  display: grid;
  gap: 8px;
  padding: 22px 18px;
  border: 1px dashed var(--gold-soft);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.6);
}

.render-note-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 24px;
}

.app-page .submit-row #library-button {
  margin-right: 0;
}

/* El asesor vive en el flujo del panel, bajo el switch, sin tapar la foto. */
.app-page #advice {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  z-index: auto;
  display: grid;
  width: auto;
  max-height: none;
  overflow: visible;
  padding: 14px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgba(53, 37, 27, 0.09);
}

.app-page #advice[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-page #advice {
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: auto;
    max-height: none;
  }

  .app-page .manual-toggle-row {
    flex-wrap: wrap;
  }

  .app-page .advice-toggle {
    margin-left: auto;
  }
}

@media (max-width: 900px) {
  .app-page .manual-toggle-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
  }

  .app-page .advice-toggle {
    margin-left: auto;
  }
}
