:root {
  --bg-0: #0f0e13;
  --bg-1: #17151d;
  --paper: #f7f3ea;
  --ink: #221f28;
  --ink-soft: #6d6675;
  --line: #e4ddce;
  --amber: #e8792b;
  --amber-dk: #c65f18;
  --amber-glow: rgba(232,121,43,0.22);
  --panel: #fbf8f0;
  --ok: #2f8f5b;
}

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

body {
  font-family: "Bricolage Grotesque", sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, #241f2e 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #2a1c17 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  min-height: 100vh;
  color: var(--ink);
  padding: 40px 18px 60px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 0;
  background-image:
    repeating-linear-gradient(0deg, #fff 0, #fff 1px, transparent 1px, transparent 3px);
  mix-blend-mode: overlay;
}

.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 620px;
  background: var(--paper);
  border-radius: 22px;
  padding: 40px 38px 26px;
  box-shadow:
    0 30px 70px rgba(0,0,0,0.45),
    0 2px 0 rgba(255,255,255,0.4) inset;
  border: 1px solid rgba(255,255,255,0.06);
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.hero { text-align: center; margin-bottom: 30px; }
.clapper {
  font-size: 2.4rem;
  display: inline-block;
  animation: tap 2.4s ease-in-out infinite;
  transform-origin: 30% 60%;
}
@keyframes tap {
  0%, 90%, 100% { transform: rotate(0); }
  4% { transform: rotate(-16deg); }
  8% { transform: rotate(2deg); }
  12% { transform: rotate(0); }
}

h1 {
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin: 8px 0 10px;
}
h1 .accent { color: var(--amber-dk); }

.tagline {
  color: var(--ink-soft);
  font-size: 1rem;
  margin: 0 auto;
  max-width: 44ch;
}

.field {
  margin-bottom: 15px;
  animation: fieldIn 0.5s ease both;
}
.field[data-idx="1"] { animation-delay: .08s; }
.field[data-idx="2"] { animation-delay: .14s; }
.field[data-idx="3"] { animation-delay: .20s; }
.field[data-idx="4"] { animation-delay: .26s; }
.field[data-idx="5"] { animation-delay: .32s; }
@keyframes fieldIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}

label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  color: var(--ink);
}
.num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--amber-dk);
  background: rgba(232,121,43,0.12);
  padding: 2px 6px;
  border-radius: 5px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.92rem;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fffdf8;
  color: var(--ink);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input::placeholder { color: #b8ad97; }
input[type="text"]:focus {
  outline: none;
  border-color: var(--amber);
  background: #fff;
  box-shadow: 0 0 0 4px var(--amber-glow);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.actions.primary-row { margin-top: 8px; margin-bottom: 4px; }

.btn {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 20px;
  border-radius: 11px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .1s, background .18s, box-shadow .18s, color .18s;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn.primary {
  flex: 2 1 200px;
  background: var(--amber);
  color: #fff;
  box-shadow: 0 8px 20px var(--amber-glow);
}
.btn.primary:hover { background: var(--amber-dk); box-shadow: 0 10px 26px var(--amber-glow); }

.btn.secondary {
  flex: 1 1 130px;
  background: #fff;
  color: var(--amber-dk);
  border-color: var(--amber);
}
.btn.secondary:hover:not(:disabled) { background: #fef3ea; }
.btn.secondary:disabled { color: #bbb1a2; border-color: var(--line); cursor: not-allowed; background: #f4efe6; }
.btn.secondary.copied { background: var(--ok); color: #fff; border-color: var(--ok); }

.btn.ghost {
  flex: 1 1 auto;
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px dashed var(--line);
  font-size: 0.85rem;
  padding: 8px 14px;
  margin: 4px 0 12px;
}
.btn.ghost:hover { color: var(--amber-dk); border-color: var(--amber); }

.result-wrap { margin-top: 18px; }
.result-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.result {
  background: var(--panel);
  border: 1.5px dashed var(--line);
  border-radius: 13px;
  padding: 18px 20px;
  font-size: 1.02rem;
  line-height: 1.6;
  min-height: 60px;
  white-space: pre-wrap;
  border-left: 4px solid var(--amber);
  transition: background .2s;
}
.result.empty {
  color: var(--ink-soft);
  font-style: italic;
  border-left-color: var(--line);
}
.result.flash { animation: flash .5s ease; }
@keyframes flash {
  0% { background: #fff3e6; }
  100% { background: var(--panel); }
}

.about {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.about h2 {
  font-size: 1.05rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.about p { margin: 0; color: var(--ink-soft); font-size: 0.93rem; line-height: 1.65; }
.about strong { color: var(--ink); font-weight: 600; }
a { color: var(--amber-dk); font-weight: 700; text-decoration: none; border-bottom: 1.5px solid var(--amber-glow); }
a:hover { border-bottom-color: var(--amber-dk); }

.foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

@media (max-width: 500px) {
  .card { padding: 30px 20px 22px; border-radius: 18px; }
  .btn.primary, .btn.secondary { flex: 1 1 100%; }
  .foot { flex-direction: column; text-align: center; }
}