:root {
  --bg: #08090d;
  --bg-elevated: #101119;
  --panel: #151722;
  --panel-soft: #1c1e2b;
  --ink: #f8f4ec;
  --muted: #a7a8b4;
  --subtle: #737684;
  --line: rgba(255, 255, 255, 0.11);
  --strong-line: rgba(255, 255, 255, 0.18);
  --accent: #d7ff68;
  --accent-ink: #101205;
  --hot: #ff4f9a;
  --blue: #70d6ff;
  --danger: #ff776d;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 18px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(140deg, rgba(215, 255, 104, 0.08), transparent 32%),
    linear-gradient(220deg, rgba(255, 79, 154, 0.08), transparent 36%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 11px 15px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

button:active,
.button-link:active,
.bottom-nav a:active {
  transform: scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.secondary {
  background: #2c3242;
  color: var(--ink);
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.danger {
  color: var(--danger);
}

.full {
  width: 100%;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  outline: none;
}

input::placeholder {
  color: #777a86;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 255, 104, 0.14);
}

select option {
  background: #151722;
  color: var(--ink);
}

.app-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 108px;
}

.app-screen {
  scroll-margin-top: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-mark {
  font-size: 18px;
  font-weight: 950;
}

.beta-pill,
.count-pill,
.usage-pill {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.app-hero {
  min-height: 520px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(8, 9, 13, 0.3), rgba(8, 9, 13, 0.92)),
    url("https://images.unsplash.com/photo-1515886657613-9f3515b0c78f?auto=format&fit=crop&w=1800&q=82") center 24% / cover;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.55fr);
  gap: 28px;
  align-items: end;
  min-height: 420px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 920;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0;
  max-width: 780px;
  font-size: 64px;
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 670px;
  margin: 18px 0 0;
  color: rgba(248, 244, 236, 0.78);
  font-size: 18px;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.hero-phone {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: rgba(10, 11, 17, 0.72);
  backdrop-filter: blur(18px);
}

.home-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(230px, 0.75fr) minmax(190px, 0.55fr);
  gap: 12px;
  margin-top: 18px;
}

.daily-look-card,
.retention-card,
.mini-stats-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: rgba(10, 11, 17, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
}

.daily-look-card h2 {
  margin: 0;
  font-size: 24px;
}

.daily-look-card p:not(.eyebrow),
.retention-card p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.daily-look-stack {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  min-height: 118px;
}

.daily-look-stack:empty::before {
  content: "Tu outfit del día aparecerá aquí";
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 118px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.daily-look-stack img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.retention-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.retention-grid span,
.mini-stat-line {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.retention-grid strong,
.mini-stat-line strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.mini-stats-card {
  align-content: start;
}

.mini-stat-line {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.mini-stat-line strong {
  font-size: 22px;
}

.phone-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.phone-status strong {
  color: var(--ink);
}

.look-stack {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hero-garment {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.hero-phone p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.onboarding {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.onboarding article,
.surface,
.garment-card,
.draft-card,
.outfit-piece,
.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 23, 34, 0.9);
  box-shadow: var(--shadow);
}

.surface,
.garment-card,
.draft-card,
.outfit-piece,
.history-item,
.onboarding article {
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.garment-card:hover,
.draft-card:hover,
.outfit-piece:hover,
.history-item:hover,
.onboarding article:hover {
  border-color: rgba(215, 255, 104, 0.2);
  transform: translateY(-2px);
}

.onboarding article {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.onboarding span {
  color: var(--hot);
  font-weight: 950;
}

.onboarding strong {
  font-size: 18px;
}

.onboarding p,
.section-copy,
.status-note,
.collection-bar p,
.explanation {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
  align-items: start;
}

.surface {
  padding: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2,
.result-head h3 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0;
}

.section-heading.inline,
.result-head,
.collection-bar,
.garment-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.inline-actions,
.stats-strip,
.result-actions,
.card-actions,
.crop-actions,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stats-strip span {
  display: grid;
  gap: 2px;
  min-width: 92px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.stats-strip strong {
  color: var(--ink);
  font-size: 22px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.segmented-control button {
  min-height: 40px;
  background: transparent;
  color: var(--muted);
}

.segmented-control button.active {
  background: var(--ink);
  color: #11131b;
}

.capture-mode {
  display: none;
  gap: 13px;
}

.capture-mode.active {
  display: grid;
}

.upload-drop {
  position: relative;
  display: grid;
  min-height: 112px;
  place-items: center;
  padding: 18px;
  border: 1px dashed rgba(215, 255, 104, 0.42);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(215, 255, 104, 0.12), rgba(112, 214, 255, 0.08));
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.upload-drop:active {
  transform: scale(0.99);
  border-color: var(--accent);
}

.upload-drop span {
  font-size: 16px;
  font-weight: 950;
}

.upload-drop small {
  color: var(--muted);
}

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

.single-preview {
  display: none;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.single-preview.visible {
  display: block;
}

.form-grid,
.outfit-controls,
.wardrobe-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.outfit-controls {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}

.wardrobe-tools {
  grid-template-columns: minmax(220px, 1.3fr) repeat(5, minmax(130px, 1fr));
  margin-bottom: 14px;
}

.status-note {
  padding: 11px 12px;
  border: 1px solid rgba(112, 214, 255, 0.22);
  border-radius: 8px;
  background: rgba(112, 214, 255, 0.08);
}

.status-note.compact {
  margin-top: 10px;
  padding: 9px 11px;
  font-size: 13px;
}

.status-note[hidden] {
  display: none;
}

.closet-workspace {
  display: grid;
  gap: 12px;
}

.crop-guide {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.crop-guide span {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.crop-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0e14;
  touch-action: none;
}

.crop-stage img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  user-select: none;
}

.crop-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.22;
}

.crop-selection {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: rgba(215, 255, 104, 0.16);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.48), 0 0 34px rgba(215, 255, 104, 0.38);
  pointer-events: none;
  z-index: 2;
  animation: cropPulse 1.8s ease-in-out infinite;
}

.crop-selection[hidden] {
  display: none;
}

.crop-selection::before,
.crop-selection::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: white;
  border-style: solid;
}

.crop-selection::before {
  left: -3px;
  top: -3px;
  border-width: 2px 0 0 2px;
}

.crop-selection::after {
  right: -3px;
  bottom: -3px;
  border-width: 0 2px 2px 0;
}

.crop-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  padding: 10px 12px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: rgba(8, 9, 13, 0.72);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.crop-hint[hidden] {
  display: none;
}

.crop-preview-panel {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(215, 255, 104, 0.28);
  border-radius: 8px;
  background: rgba(215, 255, 104, 0.08);
}

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

.crop-preview-panel img {
  width: 92px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.crop-preview-panel strong {
  display: block;
}

.crop-preview-panel small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.draft-section,
.wardrobe-panel,
.history-panel {
  margin-top: 18px;
}

.draft-gallery,
.wardrobe-grid,
.outfit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.draft-gallery:empty::before,
.wardrobe-grid:empty::before,
.history-list:empty::before {
  content: "Listo para empezar. Añade una prenda y Check Fit cobra vida.";
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.history-list:empty::before {
  content: "Guarda tu primer outfit para construir historial y mejorar la rotación.";
}

.draft-gallery:empty::before {
  content: "Los recortes y prendas por revisar aparecerán aquí antes de entrar en tu armario.";
}

.garment-card,
.draft-card,
.outfit-piece {
  overflow: hidden;
}

.garment-card img,
.draft-card img,
.outfit-piece img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--panel-soft);
}

.garment-body,
.draft-fields,
.outfit-piece div {
  display: grid;
  gap: 11px;
  padding: 13px;
}

.garment-copy {
  min-width: 0;
}

.garment-copy strong,
.outfit-piece strong,
.history-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.garment-copy small,
.outfit-piece small,
.history-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.usage-pill {
  color: var(--accent);
  white-space: nowrap;
}

.mini-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.mini-button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.draft-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.outfit-result {
  display: grid;
  gap: 15px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.outfit-result[hidden] {
  display: none;
}

.empty-state {
  grid-column: 1 / -1;
  color: var(--muted);
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  overflow: hidden;
}

.history-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.history-preview img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 6px;
}

.history-copy p {
  display: -webkit-box;
  margin: 9px 0 0;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.45;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.edit-dialog {
  width: min(560px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.edit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.66);
}

.edit-dialog form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 24px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  transform: translate(-50%, 18px);
  max-width: min(420px, calc(100% - 28px));
  padding: 12px 14px;
  border: 1px solid rgba(215, 255, 104, 0.32);
  border-radius: 8px;
  background: rgba(16, 17, 25, 0.94);
  color: var(--ink);
  font-weight: 820;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[hidden] {
  display: none;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  width: min(520px, calc(100% - 22px));
  transform: translateX(-50%);
  padding: 7px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: rgba(16, 17, 25, 0.9);
  backdrop-filter: blur(22px);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.44);
}

.bottom-nav a {
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 48px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.bottom-nav a span {
  width: 18px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.bottom-nav a.active {
  background: rgba(215, 255, 104, 0.12);
  color: var(--ink);
}

.bottom-nav a.active span {
  background: var(--accent);
}

@keyframes cropPulse {
  0%, 100% {
    border-color: var(--accent);
  }

  50% {
    border-color: var(--blue);
  }
}

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

@media (max-width: 980px) {
  .hero-grid,
  .app-grid,
  .home-dashboard {
    grid-template-columns: 1fr;
  }

  .app-hero {
    min-height: 0;
  }

  .hero-grid {
    min-height: 0;
  }

  .hero-copy h1 {
    font-size: 44px;
  }

  .onboarding,
  .crop-guide,
  .outfit-controls,
  .wardrobe-tools {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  body {
    background:
      linear-gradient(160deg, rgba(215, 255, 104, 0.08), transparent 28%),
      linear-gradient(12deg, rgba(112, 214, 255, 0.07), transparent 30%),
      var(--bg);
  }

  .app-shell {
    width: min(100% - 18px, 1220px);
    padding-top: 10px;
    padding-bottom: 112px;
  }

  .app-hero,
  .surface {
    padding: 14px;
  }

  .app-hero {
    border-radius: 8px;
  }

  .hero-copy h1 {
    font-size: 34px;
    line-height: 1;
  }

  .hero-copy p:not(.eyebrow) {
    font-size: 15px;
  }

  .onboarding,
  .crop-guide,
  .form-grid,
  .outfit-controls,
  .wardrobe-tools,
  .section-heading.inline,
  .collection-bar,
  .result-head,
  .quick-actions,
  .retention-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .daily-look-card,
  .retention-card,
  .mini-stats-card {
    padding: 13px;
  }

  .daily-look-stack {
    grid-template-columns: repeat(4, minmax(62px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .inline-actions,
  .stats-strip,
  .result-actions,
  .crop-actions {
    align-items: stretch;
  }

  .inline-actions button,
  .result-actions button,
  .crop-actions button,
  .quick-actions a,
  .quick-actions button {
    width: 100%;
  }

  .bottom-nav {
    width: calc(100% - 18px);
  }
}
