/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf7f1;
  --surface: #ffffff;
  --surface-2: #f2ece0;
  --border: #e2d8c3;
  --text: #22201b;
  --text-muted: #6f6656;
  --accent: #9c7526;
  --accent-strong: #7d5c17;
  --accent-soft: #f0e2c0;
  --accent-contrast: #ffffff;
  --positive: #2f6b52;
  --negative: #a3432f;
  --stone: #4d5f8a;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.06), 0 8px 24px -12px rgba(40, 30, 10, 0.18);

  --serif: "Fraunces", Georgia, serif;
  --sans: "Public Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1815;
    --surface: #24211c;
    --surface-2: #2d2924;
    --border: #423c33;
    --text: #f3ede0;
    --text-muted: #a89d89;
    --accent: #d9ac4c;
    --accent-strong: #f0c264;
    --accent-soft: #3a2f1c;
    --accent-contrast: #1b1815;
    --positive: #57a483;
    --negative: #dd8367;
    --stone: #8298c2;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #1b1815; --surface: #24211c; --surface-2: #2d2924; --border: #423c33;
  --text: #f3ede0; --text-muted: #a89d89; --accent: #d9ac4c; --accent-strong: #f0c264;
  --accent-soft: #3a2f1c; --accent-contrast: #1b1815; --positive: #57a483;
  --negative: #dd8367; --stone: #8298c2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans);
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { font-family: var(--serif); text-wrap: balance; line-height: 1.1; margin: 0; }
ul { list-style: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono, input[type="number"], .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem;
  background: var(--accent); color: var(--accent-contrast); z-index: 9999;
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.demo-badge {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft);
  color: var(--accent-strong); border: 1px solid var(--accent); border-radius: 999px;
  padding: 5px 12px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em;
}

/* =============================================================
   4. Typography
   ============================================================= */
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--accent-strong); font-weight: 700; }
.lede { color: var(--text-muted); font-size: 1.05rem; max-width: 56ch; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 10px; font-weight: 700; font-size: 0.94rem;
  transition: transform 0.15s var(--ease-out), background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: progress; transform: none; }
.btn-block { width: 100%; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.card h2, .summary-panel h2 { display: flex; align-items: center; gap: 9px; }
.section-icon { color: var(--accent-strong); flex: none; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.75rem; color: var(--text-muted); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 0.92rem; width: 100%;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input[type="file"] { padding: 8px; font-size: 0.85rem; color: var(--text-muted); }
.field input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 0.82rem; color: var(--accent-contrast);
  background: var(--accent); border: none; border-radius: 6px; padding: 7px 12px; margin-right: 10px;
  cursor: pointer; transition: transform 0.15s var(--ease-out);
}
.field input[type="file"]::file-selector-button:hover { transform: translateY(-1px); }
.fields-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 0.85rem; font-weight: 700;
}
.pill.low { border-color: var(--negative); color: var(--negative); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px;
  font-size: 0.88rem; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 300; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 16, 8, 0.5); display: none;
  align-items: center; justify-content: center; padding: 20px; z-index: 200;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; padding: 26px; max-width: 440px; width: 100%;
  box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 1.3rem; margin-bottom: 6px; }
.modal .close-modal { position: absolute; }

/* =============================================================
   6. Sections — shared chrome (topbar / footer)
   ============================================================= */
.topbar {
  position: sticky; top: 0; z-index: 100; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.brand-mark { color: var(--accent); flex: none; }
.topbar nav { display: flex; align-items: center; gap: 22px; margin-left: auto; font-size: 0.92rem; }
.topbar nav a:hover { color: var(--accent-strong); }
.credits-pill { font-family: var(--mono); }

footer.site {
  border-top: 1px solid var(--border); margin-top: 60px; padding: 40px 0 30px;
  color: var(--text-muted); font-size: 0.88rem;
}
footer.site .foot-grid { display: grid; gap: 24px; grid-template-columns: 2fr 1fr 1fr; margin-bottom: 24px; }
footer.site a:hover { color: var(--accent-strong); }
footer.site .foot-links { display: flex; flex-direction: column; gap: 8px; }

/* =============================================================
   7. Landing sections
   ============================================================= */
.hero { padding-block: 64px 40px; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2.1rem, 4vw, 3rem); margin: 10px 0 16px; }
.hero-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.hero-visual { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 30px; box-shadow: var(--shadow); }
.hero-visual figcaption { font-size: 0.78rem; color: var(--text-muted); margin-top: 10px; text-align: center; }

.steps { padding-block: 50px; }
.steps h2 { font-size: 1.8rem; margin-bottom: 8px; }
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 30px; }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.step-num {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong);
  display: grid; place-items: center; font-family: var(--mono); font-weight: 700; margin-bottom: 14px;
}
.step-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.step-card p { color: var(--text-muted); font-size: 0.9rem; }

.pricing { padding-block: 60px; }
.pricing h2 { font-size: 1.8rem; text-align: center; }
.pricing .lede { text-align: center; margin: 8px auto 0; }
.plans-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 34px; align-items: stretch; }
.plan-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 26px;
  display: flex; flex-direction: column; gap: 14px;
}
.plan-card.featured { border-color: var(--accent); box-shadow: var(--shadow); position: relative; }
.plan-card.featured::before {
  content: "Más elegido"; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-contrast); font-size: 0.72rem; font-weight: 700;
  padding: 4px 12px; border-radius: 999px;
}
.plan-offer-badge {
  display: inline-block; align-self: flex-start; background: var(--accent-soft); color: var(--accent-strong);
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.plan-name { font-family: var(--serif); font-size: 1.2rem; }
.plan-price { font-size: 2.1rem; font-family: var(--serif); font-weight: 700; }
.plan-price span { font-size: 0.95rem; color: var(--text-muted); font-family: var(--sans); }
.plan-price-old { font-size: 1.2rem; color: var(--text-muted); text-decoration: line-through; font-weight: 500; margin-right: 6px; }
.plan-credits { color: var(--text-muted); font-size: 0.88rem; }
.plan-features { display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem; flex: 1; }
.plan-features li { display: flex; gap: 8px; align-items: flex-start; }
.plan-features li::before { content: "✓"; color: var(--positive); font-weight: 700; }
.plan-features li.no { color: var(--text-muted); }
.plan-features li.no::before { content: "✕"; color: var(--text-muted); }

.faq { padding-block: 50px 70px; max-width: 760px; margin: 0 auto; }
.faq h2 { font-size: 1.8rem; margin-bottom: 24px; text-align: center; }
.faq-item { border-bottom: 1px solid var(--border); padding: 16px 0; }
.faq-item summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.faq-item summary::after { content: "+"; color: var(--accent-strong); font-size: 1.2rem; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { color: var(--text-muted); margin-top: 10px; font-size: 0.92rem; }

.legal-note { font-size: 0.8rem; color: var(--text-muted); text-align: center; margin-top: 20px; }

/* =============================================================
   8. Auth pages / cards
   ============================================================= */
.auth-wrap { min-height: calc(100vh - 130px); display: grid; place-items: center; padding: 40px 20px; }
.auth-card { max-width: 380px; width: 100%; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.auth-switch { text-align: center; font-size: 0.88rem; color: var(--text-muted); margin-top: 16px; }
.auth-switch a { color: var(--accent-strong); font-weight: 600; }
.form-error { color: var(--negative); font-size: 0.85rem; min-height: 1.2em; }
.ia-soon { background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; color: var(--text); font-size: 0.95rem; }
.ia-soon strong { color: var(--accent-strong); }
.btn.is-soon:disabled { cursor: not-allowed; }
.form-ok { color: var(--positive); font-size: 0.9rem; }
.form-ok:empty { display: none; }
.auth-forgot { text-align: right; font-size: 0.85rem; margin: 2px 0 6px; }
.auth-forgot a { color: var(--accent-strong); }
.reset-wrap { max-width: 440px; margin: 0 auto; padding: 50px 20px 70px; }
.reset-wrap h1 { font-size: 1.7rem; margin-bottom: 8px; }
.reset-wrap .field { margin-bottom: 12px; }

/* =============================================================
   9. App shell (app.html)
   ============================================================= */
.app-body { background: var(--bg); }
.app-topbar .topbar-inner { gap: 14px; }
.app-main { padding-block: 24px 60px; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 22px; width: fit-content; }
.tab-btn { border: none; background: transparent; color: var(--text-muted); padding: 9px 16px; border-radius: 7px; font-weight: 600; font-size: 0.88rem; }
.tab-btn.active { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); }
.modo-btn { border: none; background: transparent; color: var(--text-muted); padding: 9px 16px; border-radius: 7px; font-weight: 600; font-size: 0.88rem; }
.modo-btn.active { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.calc-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.line-row { display: grid; grid-template-columns: 1.3fr 0.8fr 0.9fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.line-row:last-of-type { border-bottom: none; }
.line-row select, .line-row input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 0.87rem; }
.line-row .subtotal { text-align: right; font-size: 0.87rem; color: var(--text-muted); white-space: nowrap; min-width: 74px; }
.row-head { display: grid; gap: 8px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; grid-template-columns: 1.3fr 0.8fr 0.9fr auto auto; }
.icon-btn { border: none; background: transparent; color: var(--text-muted); cursor: pointer; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--negative); }
.btn-add { margin-top: 10px; border: 1px dashed var(--border); background: transparent; color: var(--accent-strong); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 0.85rem; width: 100%; }
.btn-add:hover { background: var(--accent-soft); }
.hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 8px; }

.summary-panel { position: sticky; top: 76px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.summary-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 0.88rem; color: var(--text-muted); border-bottom: 1px dashed var(--border); }
.summary-row span:last-child { color: var(--text); }
.summary-row.profit span:last-child { color: var(--positive); }
.price-tag { margin-top: 16px; background: var(--accent-soft); border-radius: 12px; padding: 16px; text-align: center; }
.price-tag .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-strong); }
.price-tag .amount { font-family: var(--serif); font-weight: 700; font-size: 1.9rem; color: var(--accent-strong); margin-top: 4px; }

.saved-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.saved-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface-2); padding: 10px 12px; border-radius: 9px; font-size: 0.85rem; }
.saved-item .name { font-weight: 600; }
.saved-item .meta { color: var(--text-muted); font-size: 0.78rem; }
.saved-item button { border: none; background: transparent; color: var(--accent-strong); font-size: 0.8rem; font-weight: 600; }
.saved-item button.del { color: var(--negative); }

.design-grid, .image-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.cost-note { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }
.ai-disclaimer { font-size: 0.76rem; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }

.design-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.concept-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.concept-card h3 { font-size: 1.05rem; color: var(--accent-strong); }
.concept-meta { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--text-muted); border-top: 1px dashed var(--border); padding-top: 10px; }
.concept-meta .stone-line { color: var(--stone); }
.concept-cost { font-family: var(--mono); font-size: 0.95rem; }
.use-btn { border: 1px solid var(--accent); background: transparent; color: var(--accent-strong); padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 0.82rem; }
.use-btn:hover { background: var(--accent-soft); }

.image-result { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.image-result img { border-radius: 10px; width: 100%; }
.image-result .actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.image-placeholder {
  border: 1px dashed var(--border); border-radius: 14px; padding: 50px 20px; text-align: center;
  color: var(--text-muted); font-size: 0.9rem;
}

.loading-state { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.9rem; padding: 20px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { padding: 14px 16px; background: var(--accent-soft); border-radius: 10px; color: var(--negative); font-size: 0.88rem; }

/* =============================================================
   10. Account page
   ============================================================= */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.history-table th, .history-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

/* =============================================================
   11. Legal pages
   ============================================================= */
.legal-page { max-width: 760px; margin: 0 auto; padding: 50px 20px 70px; }
.legal-page h1 { font-size: 2rem; margin-bottom: 20px; }
.legal-page h2 { font-size: 1.2rem; margin: 28px 0 10px; }
.legal-page p, .legal-page li { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 10px; }
.legal-page li { list-style: disc; margin-left: 20px; }

/* =============================================================
   12. Responsive
   ============================================================= */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .steps-grid, .plans-grid { grid-template-columns: 1fr; }
  .calc-grid, .design-grid, .image-grid { grid-template-columns: 1fr; }
  footer.site .foot-grid { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .topbar nav { gap: 14px; font-size: 0.85rem; }
}
@media (max-width: 540px) {
  .row-head { display: none; }
  .line-row { grid-template-columns: 1fr; gap: 6px; padding: 12px 0; }
  .line-row .subtotal { text-align: left; }

  .topbar-inner { flex-wrap: wrap; gap: 10px 16px; padding-block: 12px; }
  .brand { font-size: 0.95rem; }
  .brand-text h1 { font-size: 1.3rem; }
  .topbar nav { flex-basis: 100%; margin-left: 0; justify-content: space-between; gap: 10px; font-size: 0.82rem; }

  .tabs { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; max-width: 100%; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn, .modo-btn { flex: none; white-space: nowrap; }
}

/* =============================================================
   13. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation: none; }
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
