:root {
  --q-red: #ee1c25;
  --q-blue: #2e75b6;
  --q-green: #92c062;
  --q-yellow: #edb233;
  --ink: #121212;
  --paper: #f3f4f6;
  --muted: #5a5e66;
  --line: rgba(18, 18, 18, 0.1);
  --shadow: 0 20px 48px rgba(18, 18, 18, 0.1);
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --ok: #2f7d4a;
  --bad: #c43b32;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.55;
  background:
    radial-gradient(ellipse 70% 45% at 8% -8%, rgba(238, 28, 37, 0.07), transparent 55%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(243, 244, 246, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--q-red) 0 25%,
    var(--q-blue) 25% 50%,
    var(--q-green) 50% 75%,
    var(--q-yellow) 75% 100%
  );
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.25s ease;
}

.brand-link:hover {
  transform: rotate(-4deg) scale(1.04);
}

.brand-mark {
  width: 48px;
  height: 48px;
  padding: 4px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  border: 2px solid var(--q-red);
  box-shadow: 0 6px 16px rgba(18, 18, 18, 0.08);
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.04em;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.15rem;
}

.nav a,
.nav-live {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.4rem 0.6rem;
  opacity: 0.78;
}

.nav a:hover {
  opacity: 1;
  color: var(--q-blue);
}

.nav-live {
  font-weight: 800;
  opacity: 1;
  color: var(--q-red);
}

.shell {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.6rem, 4vw, 2.6rem) 0 2.5rem;
  animation: rise 0.7s ease both;
}

.eyebrow {
  margin: 0 0 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.title {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.title span {
  color: var(--q-blue);
}

.lead {
  margin: 0 0 1.1rem;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.chip-score {
  border-color: rgba(238, 28, 37, 0.25);
  color: var(--q-red);
}

.stage {
  min-height: 220px;
  padding: 1.25rem 1.3rem 1.4rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.idle {
  margin: 2.4rem 0;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.qblock {
  animation: rise 0.4s ease both;
}

.hidden {
  display: none !important;
}

.dl {
  margin-bottom: 0.7rem;
  color: var(--q-blue);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.media {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.media img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.qtext {
  white-space: pre-wrap;
  font-size: 1.12rem;
  line-height: 1.55;
  font-weight: 600;
}

.mask {
  margin-top: 0.9rem;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--q-blue);
}

.feedback {
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-weight: 700;
}

.feedback.ok {
  border-color: rgba(146, 192, 98, 0.55);
  color: var(--ok);
  background: rgba(146, 192, 98, 0.12);
}

.feedback.bad {
  border-color: rgba(238, 28, 37, 0.35);
  color: var(--bad);
  background: rgba(238, 28, 37, 0.06);
}

.feedback .ans {
  margin-top: 0.35rem;
  color: var(--ink);
  font-weight: 600;
}

.composer {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
}

.composer input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.9rem 1.15rem;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
}

.composer input:focus {
  outline: none;
  border-color: var(--q-blue);
  box-shadow: 0 0 0 3px rgba(46, 117, 182, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.9rem 1.35rem;
  font: inherit;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--q-red);
  color: #fff;
  box-shadow: 0 12px 28px rgba(238, 28, 37, 0.22);
}

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--ink);
  color: var(--ink);
}

.actions {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.diff-block {
  margin-top: 1.4rem;
}

.diff-label {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.diff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.diff-row button {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.diff-row button:hover {
  transform: translateY(-1px);
  color: var(--ink);
  border-color: var(--ink);
}

.diff-row button.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.donate {
  margin-top: 1.6rem;
  padding: 1.1rem 1.15rem 1.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.donate-lead {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.donate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.donate-hint {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.footer {
  margin-top: auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 1.35rem;
  border-top: 1px solid var(--line);
  background:
    linear-gradient(180deg, transparent 0%, rgba(237, 178, 51, 0.06) 40%, rgba(46, 117, 182, 0.05) 100%),
    var(--paper);
}

.footer-stripe {
  height: 2px;
  margin: 0 calc(-1 * clamp(1rem, 4vw, 2.5rem)) 1rem;
  background: linear-gradient(
    90deg,
    var(--q-red) 0 25%,
    var(--q-blue) 25% 50%,
    var(--q-green) 50% 75%,
    var(--q-yellow) 75% 100%
  );
}

.footer-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.footer-meta a {
  color: var(--q-blue);
  font-weight: 700;
  text-decoration: none;
}

.footer-meta a:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 560px) {
  .brand-text {
    display: none;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .composer input,
  .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
