:root {
  --bg: #f7f3ee;
  --ink: #171410;
  --muted: #766f67;
  --line: rgba(23, 20, 16, .1);
  --glass: rgba(255, 255, 255, .58);
  --shadow: 0 32px 90px rgba(78, 55, 33, .16);
  --radius: 34px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 206, 158, .8), transparent 32rem),
    radial-gradient(circle at 88% 16%, rgba(198, 210, 255, .75), transparent 34rem),
    linear-gradient(140deg, #fffaf4, var(--bg) 52%, #ece7df);
  overflow-x: hidden;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-decoration: none; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}

.topbar {
  position: sticky;
  top: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 32px));
  margin: 18px auto 0;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.68);
  border-radius: 999px;
  background: rgba(255,255,255,.48);
  backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 16px 50px rgba(62, 47, 34, .09);
}

.brand, .nav, .modes, .actions, .footer, .lengths, .control-head, .mix-item { display: flex; align-items: center; }
.brand { gap: 10px; padding: 0 10px; font-weight: 700; letter-spacing: -.03em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #191714, #655143);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 14px 28px rgba(23,20,16,.18);
}
.nav { gap: 4px; }
.nav a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  transition: color .35s ease, background .35s ease, transform .35s cubic-bezier(.2,.8,.2,1);
}
.nav a:hover { color: var(--ink); background: rgba(255,255,255,.55); transform: translateY(-1px); }

main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.hero {
  display: grid;
  grid-template-columns: 1fr minmax(420px, .86fr);
  gap: 56px;
  align-items: center;
  min-height: calc(100vh - 92px);
  padding: 72px 0;
}
.hero-copy { max-width: 650px; }
.eyebrow {
  margin: 0 0 18px;
  color: #9b6b3a;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2, .phrase { margin: 0; letter-spacing: -.07em; line-height: .92; }
h1 { max-width: 760px; font-size: clamp(58px, 9vw, 128px); }
h2 { font-size: clamp(40px, 6vw, 78px); }
.lead {
  max-width: 560px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.55;
  letter-spacing: -.03em;
}

.generator-card, .split {
  border: 1px solid rgba(255,255,255,.72);
  background: linear-gradient(145deg, rgba(255,255,255,.72), rgba(255,255,255,.36));
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(145%);
}
.generator-card {
  position: relative;
  padding: 20px;
  border-radius: 42px;
}
.generator-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,.9), rgba(255,255,255,0), rgba(153, 123, 92, .18));
}
.modes {
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.42);
}
.control-head {
  justify-content: space-between;
  gap: 14px;
  margin: 8px 8px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.control-head small {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}
.mode {
  flex: 1 1 auto;
  min-width: max-content;
  border: 0;
  padding: 12px 14px;
  color: var(--muted);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: transform .35s cubic-bezier(.2,1.2,.2,1), color .25s ease, background .25s ease, box-shadow .25s ease;
}
.mode:hover, .icon-button:hover { transform: translateY(-2px); }
.mode.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 12px 32px rgba(68, 50, 35, .11);
}
.lengths {
  gap: 8px;
  margin: 0 0 16px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.42);
}
.lengths button {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  transition: transform .35s cubic-bezier(.2,1.2,.2,1), color .25s ease, background .25s ease, box-shadow .25s ease;
}
.lengths button:hover { transform: translateY(-2px); }
.lengths button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 12px 32px rgba(68, 50, 35, .11);
}
.mix {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}
.mix-item {
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.42);
  animation: historyIn .35s cubic-bezier(.2,1.08,.2,1) both;
}
.mix-item span {
  flex: 1;
  min-width: 0;
  font-weight: 800;
}
.mix-item button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(68, 50, 35, .1);
  transition: transform .3s cubic-bezier(.2,1.2,.2,1);
}
.mix-item button:hover { transform: translateY(-2px); }
.mix-item strong {
  min-width: 34px;
  text-align: center;
}

.result-shell {
  display: grid;
  align-content: center;
  min-height: 340px;
  margin: 16px 0;
  padding: clamp(28px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 24% 20%, rgba(255,255,255,.88), transparent 15rem),
    linear-gradient(145deg, rgba(255,255,255,.5), rgba(237,229,219,.38));
}
.result-label {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.phrase {
  font-size: clamp(42px, 6vw, 78px);
  text-wrap: balance;
}
.phrase.swap { animation: phraseSwap .52s cubic-bezier(.2, 1.05, .2, 1) both; }
@keyframes phraseSwap {
  0% { opacity: 0; filter: blur(12px); transform: translateY(18px) scale(.98); }
  100% { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
}

.actions { gap: 10px; }
.primary, .icon-button {
  border: 0;
  cursor: pointer;
  transition: transform .35s cubic-bezier(.2,1.25,.2,1), box-shadow .35s ease, background .35s ease;
}
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  min-height: 64px;
  padding: 0 26px;
  color: white;
  border-radius: 999px;
  background: linear-gradient(135deg, #191714, #594334);
  box-shadow: 0 22px 48px rgba(49, 36, 26, .22);
  font-weight: 800;
}
.primary svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s ease; }
.primary:hover { transform: translateY(-3px) scale(1.01); box-shadow: 0 28px 58px rgba(49, 36, 26, .27); }
.primary:hover svg { transform: translateX(3px); }
.primary:active, .icon-button:active, .mode:active { transform: scale(.97); }
.icon-button {
  min-height: 64px;
  padding: 0 20px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,255,255,.58);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 700;
}

.split {
  margin: 0 0 24px;
  padding: clamp(24px, 5vw, 54px);
  border-radius: 42px;
}
.split {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 36px;
}
.history {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: item;
}
.history li {
  counter-increment: item;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.42);
  color: #3f3830;
  animation: historyIn .45s cubic-bezier(.2,1.08,.2,1) both;
}
.history li::before {
  content: counter(item, decimal-leading-zero);
  color: #a58d75;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}
@keyframes historyIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
}
code {
  padding: .18em .42em;
  border-radius: .5em;
  background: rgba(23,20,16,.07);
  color: #574130;
}
.footer {
  justify-content: space-between;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 42px;
  color: var(--muted);
  font-size: 14px;
}
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .8s ease, transform .8s cubic-bezier(.2,.8,.2,1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .hero, .split { grid-template-columns: 1fr; }
  .hero { gap: 28px; padding: 54px 0 32px; }
  .nav { display: none; }
}
@media (max-width: 560px) {
  main, .topbar, .footer { width: min(100% - 20px, 1120px); }
  .topbar { top: 10px; margin-top: 10px; }
  .hero { min-height: auto; padding-top: 42px; }
  .generator-card { padding: 12px; border-radius: 30px; }
  .modes, .lengths { border-radius: 26px; }
  .mode { flex-basis: calc(50% - 4px); padding: 11px 10px; font-size: 14px; }
  .result-shell { min-height: 280px; border-radius: 24px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .primary { grid-column: 1 / -1; }
  .icon-button { padding: 0 12px; }
  .split { border-radius: 30px; }
  .control-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .footer { align-items: flex-start; flex-direction: column; gap: 8px; }
}

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