:root {
  --bg: #f1ebdf;
  --paper: #f7f2e8;
  --ink: #12100d;
  --muted: rgba(18, 16, 13, 0.55);
  --accent: #b44f2d;
  --accent-soft: rgba(180, 79, 45, 0.14);
  --line: rgba(18, 16, 13, 0.1);
  --surface-strong: rgba(18, 16, 13, 0.92);
  --surface-shadow: rgba(18, 16, 13, 0.16);
}

body[data-theme="dark"] {
  --bg: #11100e;
  --paper: #181614;
  --ink: #f4efe5;
  --muted: rgba(244, 239, 229, 0.62);
  --accent: #f18a61;
  --accent-soft: rgba(241, 138, 97, 0.12);
  --line: rgba(244, 239, 229, 0.1);
  --surface-strong: rgba(244, 239, 229, 0.92);
  --surface-shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100svh;
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.12)),
    var(--bg);
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  transition:
    background-color 220ms ease,
    color 220ms ease;
}

body[data-theme="dark"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(18, 16, 13, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 16, 13, 0.035) 1px, transparent 1px);
  background-size: 84px 84px;
  opacity: 0.4;
  pointer-events: none;
}

body[data-theme="dark"]::before {
  background:
    linear-gradient(rgba(244, 239, 229, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 239, 229, 0.04) 1px, transparent 1px);
}

.frame {
  position: relative;
  min-height: 100svh;
  padding: clamp(18px, 3vw, 32px);
  overflow: hidden;
}

.theme-toggle,
.code-link {
  position: fixed;
  z-index: 3;
  border-radius: 999px;
  backdrop-filter: blur(12px);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease,
    color 180ms ease;
}

.theme-toggle {
  right: 32px;
  top: 42px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.theme-toggle-track {
  display: inline-flex;
  width: 42px;
  height: 20px;
  padding: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 28%, transparent);
  box-shadow: 0 12px 24px var(--surface-shadow);
}

.theme-toggle-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--paper);
  transform: translateX(0);
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    opacity 180ms ease;
}

body[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(22px);
  color: var(--paper);
}

body[data-theme="dark"] .theme-toggle-track {
  background: color-mix(in srgb, var(--ink) 16%, transparent);
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.code-link:hover,
.code-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 20px 34px color-mix(in srgb, var(--surface-shadow) 120%, transparent);
  outline: none;
}

.theme-icon {
  width: 10px;
  height: 10px;
  fill: currentColor;
  position: absolute;
  transition: opacity 180ms ease;
}

.theme-icon-moon {
  opacity: 0;
}

body[data-theme="dark"] .theme-icon-sun {
  opacity: 0;
}

body[data-theme="dark"] .theme-icon-moon {
  opacity: 1;
}

.code-link {
  left: 32px;
  top: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  color: color-mix(in srgb, var(--ink) 38%, transparent);
  text-decoration: none;
  box-shadow: none;
  opacity: 0.58;
  transition:
    opacity 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.code-link-icon {
  width: 17px;
  height: 17px;
  fill: currentColor;
  position: relative;
  z-index: 1;
}

body[data-theme="dark"] .code-link {
  color: #d8d1c4;
  opacity: 0.92;
}

.code-link:hover,
.code-link:focus-visible {
  opacity: 1;
}

.wash {
  position: absolute;
  pointer-events: none;
}

.wash-left {
  width: 42vw;
  height: 42vw;
  min-width: 320px;
  min-height: 320px;
  left: -8vw;
  top: -8vw;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  filter: blur(10px);
}

.wash-right {
  width: 30vw;
  height: 30vw;
  min-width: 260px;
  min-height: 260px;
  right: -6vw;
  bottom: -8vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(18, 16, 13, 0.08), transparent 72%);
  filter: blur(10px);
}

.rule {
  position: absolute;
  left: 32px;
  right: 32px;
  height: 1px;
  background: var(--line);
}

.rule-top {
  top: 32px;
}

.rule-bottom {
  bottom: 32px;
}

.layout {
  position: relative;
  min-height: calc(100svh - 2 * clamp(20px, 4vw, 40px));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(40px, 7vw, 88px) clamp(10px, 2vw, 20px);
}

.intro {
  display: block;
}

h1 {
  margin: 0;
  max-width: 8ch;
  font-family: "Syne", sans-serif;
  font-size: clamp(4rem, 11vw, 9.2rem);
  line-height: 0.9;
  letter-spacing: -0.07em;
  text-transform: none;
}

.response {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: clamp(8rem, 20vw, 12rem);
  width: 100%;
}

.answer-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.answer {
  margin: 0;
  font-family: "Syne", sans-serif;
  width: min(100%, 10ch);
  font-size: clamp(3.3rem, 9vw, 6.4rem);
  line-height: 0.94;
  letter-spacing: -0.08em;
  color: var(--accent);
  text-align: right;
  text-wrap: nowrap;
  white-space: nowrap;
}

.answer-group.is-hidden {
  opacity: 0;
}

.answer-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.cta {
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 18px 28px;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.cta:hover,
.cta:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(18, 16, 13, 0.18);
  outline: none;
}

.cta:active {
  transform: translateY(1px);
}

.answer.is-refreshing {
  animation: pulse 420ms ease;
}

@keyframes pulse {
  0% {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@media (max-width: 900px) {
  .layout {
    justify-content: center;
    gap: 48px;
  }

  .response {
    justify-content: center;
    min-height: 9rem;
  }

  .answer {
    width: min(100%, 8ch);
    text-align: center;
    text-wrap: balance;
    white-space: normal;
  }

  .answer-group {
    align-items: center;
  }

  .actions {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .frame {
    padding: 14px;
  }

  .theme-toggle {
    right: 14px;
    top: 30px;
  }

  .code-link {
    left: 14px;
    top: 30px;
    width: 18px;
    height: 18px;
  }

  .code-link-label {
    display: none;
  }

  .rule {
    left: 14px;
    right: 14px;
  }

  .rule-top {
    top: 14px;
  }

  .rule-bottom {
    bottom: 14px;
  }

  .layout {
    min-height: calc(100svh - 28px);
    padding: 54px 8px 28px;
    gap: 22px;
  }

  .intro {
    display: block;
  }

  h1 {
    max-width: 7ch;
    font-size: clamp(2.7rem, 13vw, 4.2rem);
    line-height: 0.94;
  }

  .response {
    min-height: 7rem;
  }

  .answer {
    max-width: 100%;
    font-size: clamp(2.5rem, 11vw, 4.1rem);
    line-height: 0.96;
    width: min(100%, 8ch);
    text-align: center;
    text-wrap: balance;
    white-space: normal;
  }

  .answer-note {
    font-size: 0.76rem;
    text-align: center;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .cta {
    width: 100%;
    padding: 16px 20px;
  }
}
