:root {
  --bg: #0b0f16;
  --bg-glow: #131a26;
  --surface: #121824;
  --surface-2: #171f2e;
  --border: #243044;
  --border-soft: #1c2534;
  --text: #e8edf6;
  --text-dim: #93a1b8;
  --text-faint: #65758f;
  --accent: #5eead4;
  --accent-deep: #14b8a6;
  --danger: #f87171;
  --danger-bg: #2a1518;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 580px at 50% -18%, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- masthead ----------------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(94, 234, 212, 0.16), rgba(20, 184, 166, 0.06));
  border: 1px solid rgba(94, 234, 212, 0.26);
  color: var(--accent);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.875rem;
  color: var(--text-dim);
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(20, 184, 166, 0.09);
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 999px;
}

.privacy-pill svg {
  width: 14px;
  height: 14px;
  flex: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- panels ------------------------------------------------------------- */

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.15rem;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hint {
  font-size: 0.78rem;
  color: var(--text-faint);
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
}

.note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-faint);
  min-width: 0;
}

.note.error {
  color: var(--danger);
}

.note.success {
  color: var(--accent);
}

textarea,
input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.8rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.925rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#secrets {
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.16);
}

textarea::placeholder {
  color: #3f4c63;
}

/* --- buttons ------------------------------------------------------------ */

.btn,
.btn-ghost {
  flex: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 550;
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn {
  color: #052e2b;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.btn:hover:not(:disabled) {
  background: #7ff0dd;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: #33415c;
  background: var(--surface-2);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- code cards --------------------------------------------------------- */

.empty-state {
  margin: 0;
  padding: 2.25rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-faint);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state[hidden] {
  display: none;
}

.codes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.code-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  animation: rise 0.22s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.code-main {
  min-width: 0;
}

.code-key {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-value {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: clamp(1.6rem, 7vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.code-value .group-gap {
  display: inline-block;
  width: 0.42em;
}

.code-card.expiring .code-value {
  color: #fbbf24;
}

/* countdown ring */
.countdown {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
}

.countdown svg {
  width: 42px;
  height: 42px;
  transform: rotate(-90deg);
}

.countdown circle {
  fill: none;
  stroke-width: 3;
}

.countdown .track {
  stroke: var(--border);
}

.countdown .progress {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.95s linear, stroke 0.3s ease;
}

.code-card.expiring .countdown .progress {
  stroke: #fbbf24;
}

.countdown-text {
  position: absolute;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.copy-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.4);
}

.copy-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(20, 184, 166, 0.12);
}

/* invalid key card */
.code-card.invalid {
  grid-template-columns: 1fr;
  border-color: rgba(248, 113, 113, 0.35);
  background: var(--danger-bg);
}

.code-card.invalid .code-key {
  color: #fca5a5;
}

.code-error {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.85rem;
  color: var(--danger);
}

/* --- feedback ----------------------------------------------------------- */

.feedback .field {
  margin-bottom: 0.75rem;
}

.feedback label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
}

/* --- footer & toast ----------------------------------------------------- */

.site-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.site-foot a {
  color: var(--text-faint);
  text-decoration: none;
}

.site-foot a:hover {
  color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --- responsive --------------------------------------------------------- */

@media (max-width: 560px) {
  .page {
    padding: 1.75rem 1rem 2.5rem;
  }

  .masthead {
    gap: 0.85rem;
  }

  .code-card {
    gap: 0.7rem;
    padding: 0.85rem 0.9rem;
  }

  .code-value {
    letter-spacing: 0.06em;
  }

  .panel-foot {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
