/* Dalays AI Design Studio — estilos */
:root {
  --paper: #F7F0E4;
  --paper-2: #EFE4D2;
  --card: #FFFBF4;
  --ink: #2E2521;
  --ink-soft: #6B5D54;
  --line: #DCCBB3;
  --clay: #A64B2A;
  --clay-deep: #853A1F;
  --clay-tint: #F3DDD0;
  --on-clay: #FFF8EF;
  --sage: #4F6343;
  --sage-tint: #E3E9DA;
  --danger: #A12B2B;
  --focus: #1F5F8B;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 999px;
  --shadow: 0 1px 0 rgba(78, 52, 35, .06), 0 10px 30px -18px rgba(78, 52, 35, .35);
  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1E1814; --paper-2: #2A221D; --card: #28201B;
    --ink: #F2E8DA; --ink-soft: #C2B2A2; --line: #46392F;
    --clay: #E08A63; --clay-deep: #F0A27F; --clay-tint: #4A2C1F; --on-clay: #1E1814;
    --sage: #A9C097; --sage-tint: #2F3A28; --danger: #F08A8A; --focus: #8CC4F0;
    --shadow: 0 10px 30px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1E1814; --paper-2: #2A221D; --card: #28201B;
  --ink: #F2E8DA; --ink-soft: #C2B2A2; --line: #46392F;
  --clay: #E08A63; --clay-deep: #F0A27F; --clay-tint: #4A2C1F; --on-clay: #1E1814;
  --sage: #A9C097; --sage-tint: #2F3A28; --danger: #F08A8A; --focus: #8CC4F0;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 80px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
h1, h2 { font-family: var(--serif); font-weight: 400; line-height: 1.2; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: var(--card); padding: .5rem 1rem; z-index: 50; border-radius: var(--radius); }

/* Encabezado */
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--paper);
}
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .75rem; }
.brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.brand-mark {
  flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--clay); color: var(--on-clay); font: 400 1.4rem/1 var(--serif);
  box-shadow: inset 0 0 0 4px var(--clay), inset 0 0 0 5.5px var(--on-clay);
}
.brand-name { font: 400 1.15rem/1.2 var(--serif); }
.brand-by { font-size: .82rem; color: var(--ink-soft); }
.top-actions { display: flex; gap: .5rem; flex: none; }

/* Intro */
.intro { padding: 2.5rem 0 1.75rem; max-width: 46rem; }
.intro h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.7rem); letter-spacing: -.01em; }
.intro p { margin-top: .75rem; color: var(--ink-soft); font-size: 1.05rem; max-width: 40rem; }
.req { color: var(--clay); font-weight: 700; }

/* Distribución */
.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
.side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); display: grid; gap: 1.25rem; }

/* Formulario */
.form { display: grid; gap: 1.25rem; }
.step {
  margin: 0; padding: 1.25rem 1.25rem 1.4rem; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--card); min-width: 0;
}
.step legend { font: 400 1.2rem/1.2 var(--serif); padding: 0 .5rem; margin-left: -.5rem; display: flex; align-items: center; gap: .6rem; }
.step-n {
  display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  border: 1.5px dashed var(--clay); color: var(--clay); font: 600 .9rem/1 var(--sans);
}
.field { display: grid; gap: .35rem; margin-top: 1rem; min-width: 0; }
.field:first-of-type { margin-top: .5rem; }
.field > label, .label { font-weight: 600; font-size: .95rem; }
.hint { font-size: .85rem; color: var(--ink-soft); }
.err { font-size: .85rem; color: var(--danger); font-weight: 600; }
input[type="text"], textarea, select {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--paper); padding: .65rem .8rem; line-height: 1.45;
  transition: border-color .15s;
}
textarea { resize: vertical; min-height: 2.9rem; }
select { appearance: none; padding-right: 2.25rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
input[type="text"]:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--clay) 45%, var(--line)); }
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--clay); outline: none; box-shadow: 0 0 0 3px var(--clay-tint); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
::placeholder { color: color-mix(in srgb, var(--ink-soft) 75%, transparent); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid-2 .field:first-of-type, .grid-2 .field:nth-of-type(2) { margin-top: 1rem; }

/* Chips (radios) */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; padding: .25rem 0; border-radius: var(--radius); }
.chips.invalid { outline: 2px solid var(--danger); outline-offset: 4px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: .45rem .85rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); font-size: .9rem; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s;
}
.chip input:hover + span { border-color: var(--clay); }
.chip input:checked + span { background: var(--clay); border-color: var(--clay); color: var(--on-clay); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.segmented label { position: relative; text-align: center; font-size: .88rem; font-weight: 500; cursor: pointer; }
.segmented label + label { border-left: 1px solid var(--line); }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: .62rem .25rem; }
.segmented input:checked + span { background: var(--clay-tint); color: var(--clay-deep); font-weight: 700; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

.check { grid-template-columns: auto 1fr; align-items: center; column-gap: .6rem; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--clay); margin: 0; }
.check label { font-weight: 600; }
.check .hint { grid-column: 2; }
.check-inline { display: flex; gap: .5rem; align-items: flex-start; font-size: .92rem; }
.check-inline input { accent-color: var(--clay); margin-top: .3rem; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1.5px solid transparent; border-radius: var(--radius-sm); padding: .6rem 1.1rem;
  font-weight: 600; font-size: .95rem; cursor: pointer; transition: background .15s, border-color .15s, color .15s; min-height: 44px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--clay); color: var(--on-clay); }
.btn-primary:not(:disabled):hover { background: var(--clay-deep); }
.btn-quiet { background: var(--paper-2); border-color: var(--line); }
.btn-quiet:not(:disabled):hover { border-color: var(--clay); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:not(:disabled):hover { border-color: var(--clay); color: var(--clay-deep); }
.btn-lg { padding: .85rem 1.6rem; font-size: 1.05rem; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: .25rem; color: var(--clay-deep); font-weight: 600; font-size: .88rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Resultado: etiqueta cosida */
.result {
  position: relative; background: var(--card); border-radius: var(--radius-lg); padding: 1.4rem;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.result::before {
  content: ""; position: absolute; inset: 7px; border: 1.5px dashed color-mix(in srgb, var(--clay) 55%, transparent);
  border-radius: calc(var(--radius-lg) - 6px); pointer-events: none;
}
.result-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.result-head h2 { font-size: 1.35rem; }
.lang { display: inline-flex; background: var(--paper-2); border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--line); }
.lang label { position: relative; padding: .3rem .75rem; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; cursor: pointer; }
.lang input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.lang label:has(input:checked) { background: var(--card); color: var(--clay-deep); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.lang label:has(input:focus-visible) { outline: 3px solid var(--focus); }
.result-body { margin-top: 1rem; min-height: 9rem; max-height: 50vh; overflow: auto; padding-right: .25rem; outline: none; }
.empty { color: var(--ink-soft); }
.empty.small { font-size: .9rem; }
.prompt { white-space: pre-wrap; word-wrap: break-word; font-size: .97rem; line-height: 1.7; }
.prompt.flash { animation: flash .6s ease-out; }
@keyframes flash { from { background: var(--clay-tint); } to { background: transparent; } }
.notes { margin-top: 1rem; background: var(--sage-tint); color: var(--ink); border-radius: var(--radius); padding: .75rem .9rem; font-size: .88rem; }
.notes-title { font-weight: 700; color: var(--sage); }
.notes ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; }

/* Recientes */
.recent { background: var(--paper-2); border-radius: var(--radius-lg); padding: 1.2rem 1.25rem; border: 1px solid var(--line); }
.recent-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.recent-head h2 { font-size: 1.1rem; }
.recent-note { font-size: .82rem; color: var(--ink-soft); margin-top: .2rem; }
.recent-list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .5rem; max-height: 22rem; overflow: auto; }
.recent-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .8rem; }
.recent-title { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.recent-meta { font-size: .8rem; color: var(--ink-soft); }
.recent-actions { display: flex; gap: .25rem; margin-top: .25rem; }

/* Imagen */
.image-gen { margin-top: 2.5rem; padding: 1.4rem; border: 1.5px dashed var(--line); border-radius: var(--radius-lg); max-width: 52rem; }
.image-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.image-head h2 { font-size: 1.25rem; }
.image-gen > p { margin-top: .6rem; color: var(--ink-soft); max-width: 44rem; }
.pill { font-size: .8rem; font-weight: 700; padding: .2rem .65rem; border-radius: var(--radius-sm); background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-soft); }
.pill.on { background: var(--sage-tint); color: var(--sage); border-color: transparent; }
.image-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1rem; }
.image-result { margin-top: 1rem; }
.image-result img { border-radius: var(--radius); border: 1px solid var(--line); max-height: 520px; background: repeating-conic-gradient(var(--paper-2) 0 25%, var(--card) 0 50%) 0 0 / 20px 20px; }

/* Ayuda */
.help { margin: 2rem 0 3rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); max-width: 52rem; }
.help summary { cursor: pointer; padding: 1rem 1.25rem; font: 400 1.15rem/1.3 var(--serif); list-style-position: inside; }
.help-body { padding: 0 1.25rem 1.25rem; max-width: 44rem; }
.help-body ol { padding-left: 1.2rem; margin: 0 0 1rem; display: grid; gap: .4rem; }
.help-body p + p { margin-top: .6rem; }

.foot { border-top: 1px solid var(--line); padding: 1.25rem 0 2rem; color: var(--ink-soft); font-size: .85rem; }

/* Aviso flotante */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem); transform: translate(-50%, 1rem);
  background: var(--ink); color: var(--paper); padding: .7rem 1.15rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30;
  max-width: calc(100% - 2rem); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* Responsive */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .result-body { max-height: none; }
}
@media (max-width: 560px) {
  .wrap { width: min(1180px, 100% - 1.5rem); }
  .brand-by { display: none; }
  .hide-sm { display: none; }
  .brand-name { font-size: 1.02rem; }
  .brand-mark { width: 36px; height: 36px; font-size: 1.2rem; }
  .top-actions .btn { padding: .5rem .8rem; font-size: .88rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .field:nth-of-type(2) { margin-top: 1rem; }
  .step { padding: 1rem 1rem 1.2rem; }
  .intro { padding-top: 1.75rem; }
  .form-actions .btn { flex: 1 1 100%; }
  .result-actions .btn { flex: 1 1 auto; }
  .segmented span { font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Inicio de sesión */
.login-page { min-height: 100%; }
.login-wrap { width: min(440px, 100% - 2rem); margin: 0 auto; padding: 3rem 0 4rem; }
.login-brand { margin-bottom: 1.5rem; }
.login-card { padding: 1.75rem; }
.login-card h1 { font-size: 1.6rem; }
.login-lead { margin-top: .5rem; color: var(--ink-soft); }
.login-card input[type="email"], .login-card input[type="text"] {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: .75rem .85rem; font-size: 1.05rem;
}
.login-card input:focus { border-color: var(--clay); outline: none; box-shadow: 0 0 0 3px var(--clay-tint); }
.code-input { letter-spacing: .5em; font-size: 1.5rem !important; text-align: center; font-weight: 700; }
.login-btn { width: 100%; margin-top: 1.25rem; }
.login-links { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.login-buy { text-align: center; margin-top: 1.5rem; color: var(--ink-soft); }
.login-buy a { color: var(--clay-deep); font-weight: 600; }
