:root {
  --fg: #ffffff;
  --bg-stage: #101014;
  --ink: #17171c;
  --ink-soft: #55555f;
  --paper: #ffffff;
  --paper-2: #f6f6f8;
  --line: #e7e7ec;
  --accent: #4a7dff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(20, 20, 30, .06), 0 8px 24px rgba(20, 20, 30, .08);
  --shadow-2: 0 2px 4px rgba(20, 20, 30, .08), 0 16px 48px rgba(20, 20, 30, .14);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; border-radius: 4px; }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 36px);
  z-index: 10;
  color: var(--fg);
  transition: color .5s var(--ease);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .04em;
  text-decoration: none;
}
.brand-dot { opacity: .5; margin: 0 1px; }

.topbar-actions { display: flex; gap: 10px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(127, 127, 127, .14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.icon-btn:hover { background: rgba(127, 127, 127, .28); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }

/* ---------- Stage (hero = el color) ---------- */
.stage {
  min-height: 100svh;
  background-color: var(--bg-stage);
  transition: background-color .55s var(--ease);
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.10), transparent 60%);
  pointer-events: none;
}

.stage-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--fg);
  transition: color .45s var(--ease);
  padding: 96px 20px 40px;
  max-width: 720px;
  width: 100%;
}

.color-name {
  font-size: clamp(.85rem, 2vw, 1.05rem);
  font-weight: 600;
  letter-spacing: .32em;
  text-transform: uppercase;
  opacity: .82;
  animation: rise .5s var(--ease) both;
}
.color-name.swap { animation: rise .5s var(--ease) both; }

.hex-display {
  font-size: clamp(3rem, 12vw, 7.5rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
  margin: 10px 0 6px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .08);
  animation: rise .5s var(--ease) both;
}
.hex-display.swap { animation: rise .5s var(--ease) both; }

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

.stage-hint {
  font-size: .82rem;
  letter-spacing: .06em;
  opacity: .68;
  margin-bottom: 26px;
}
.stage-hint kbd {
  font-family: inherit;
  font-size: .78em;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 1px 7px;
  opacity: .9;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .05em;
  font-size: .95rem;
  color: var(--ink);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-2);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.btn-generate:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,.10), 0 22px 56px rgba(0,0,0,.18); }
.btn-generate:active { transform: scale(.97); }

/* ---------- Chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 30px;
}

.chip {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 46px;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: rgba(127, 127, 127, .16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.chip:hover { background: rgba(127, 127, 127, .3); transform: translateY(-1px); }
.chip:active { transform: scale(.97); }

.chip-label {
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .18em;
  opacity: .62;
}
.chip-value {
  font-size: .92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip-check {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}
.chip.copied .chip-check { opacity: 1; }

/* ---------- Historial ---------- */
.history-wrap {
  margin-top: 34px;
  animation: rise .5s var(--ease) both;
}
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 520px;
  margin: 0 auto 8px;
}
.history-title {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
  opacity: .6;
}
.history-clear {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .06em;
  opacity: .6;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
  padding: 0 8px;
}
.history-clear:hover { opacity: 1; }

.history {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}
.history li button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  transition: transform .18s var(--ease), border-color .18s var(--ease);
}
.history li button:hover { transform: scale(1.15); border-color: #fff; }
.history li button:active { transform: scale(.95); }

/* ---------- Contenido ---------- */
.content {
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(48px, 8vw, 88px) 22px 40px;
  display: grid;
  gap: clamp(44px, 7vw, 72px);
}

.block h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin-bottom: 16px;
}
.block h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 26px 0 10px;
}
.block p { color: var(--ink-soft); margin-bottom: 12px; }
.block strong { color: var(--ink); }

.steps { list-style: none; counter-reset: paso; display: grid; gap: 14px; }
.steps li {
  counter-increment: paso;
  position: relative;
  padding-left: 54px;
  color: var(--ink-soft);
  min-height: 40px;
}
.steps li::before {
  content: counter(paso);
  position: absolute;
  left: 0;
  top: 2px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: .9rem;
}
.steps strong { color: var(--ink); }

.table-scroll { overflow-x: auto; }
.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: .93rem;
  margin: 6px 0 8px;
}
.compare th, .compare td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.compare th {
  font-size: .7rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.compare td:first-child { font-weight: 700; white-space: nowrap; }
.compare code {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: .86em;
  white-space: nowrap;
}

.code-sample {
  background: #17171d;
  color: #e8e8f0;
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.7;
  box-shadow: var(--shadow-1);
  margin: 10px 0 14px;
}
.code-sample .cmt { color: #7d7d90; }

.tips { list-style: none; display: grid; gap: 12px; }
.tips li {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--ink-soft);
}
.tips strong { color: var(--ink); }

details {
  border-bottom: 1px solid var(--line);
  padding: 4px 0;
}
details summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 0;
  list-style: none;
  position: relative;
  padding-right: 34px;
  min-height: 44px;
  display: flex;
  align-items: center;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: translateY(-70%) rotate(45deg);
  transition: transform .25s var(--ease);
}
details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
details p { padding-bottom: 14px; }

.cta {
  text-align: center;
  background: linear-gradient(135deg, #17171d, #33334a);
  color: #fff;
  border-radius: calc(var(--radius) * 1.4);
  padding: clamp(36px, 6vw, 60px) 26px;
}
.cta h2 { color: #fff; }
.cta p { color: rgba(255, 255, 255, .75); max-width: 480px; margin: 0 auto 24px; }
.btn-up {
  display: inline-block;
  min-height: 50px;
  line-height: 50px;
  padding: 0 30px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
  box-shadow: var(--shadow-2);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.btn-up:hover { transform: translateY(-2px); }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 34px 22px 44px;
  text-align: center;
  color: var(--ink-soft);
  font-size: .88rem;
}
.footer nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 26px;
  margin-bottom: 14px;
}
.footer a {
  text-decoration: none;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.footer a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #17171d;
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .chip { padding: 8px 12px; gap: 7px; }
  .chip-value { font-size: .8rem; }
  .stage-inner { padding-top: 84px; }
  .history li button { width: 34px; height: 34px; }
}
