:root {
  color-scheme: light;
  --paper: #ede4d3;
  --paperDeep: #e3d7be;
  --ink: #2a1f18;
  --inkSoft: #5a4636;
  --accent: #7a2e2a;
  --accentDeep: #5a1f1c;
  --secondary: #3a4a3a;
  --rule: #3a2a22;
  --grain: #1a0f08;
  --font-body: "Noto Serif SC", "Cormorant Garamond", "Songti SC", Georgia, serif;
  --font-display: "Cormorant Garamond", "Noto Serif SC", "Songti SC", Georgia, serif;
  --font-mono: "JetBrains Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0, 0, 0, 0.06), transparent 60%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(0, 0, 0, 0.04), transparent 60%),
    var(--paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.32;
  z-index: 100;
  mix-blend-mode: multiply;
}

.paper-edge {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  background: radial-gradient(ellipse 100% 85% at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.18) 100%);
}

.cursor-halo {
  position: fixed;
  top: -160px;
  left: -160px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 98;
  background: radial-gradient(circle, rgba(122, 46, 42, 0.08), transparent 65%);
  mix-blend-mode: multiply;
  opacity: 0.9;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 64px 96px;
  position: relative;
  z-index: 1;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 18px;
  margin-bottom: 64px;
  position: relative;
}

.masthead::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
  opacity: 0.4;
}

.masthead-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--accent);
  animation: spin 24s linear infinite;
}

.masthead-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
}

.masthead-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--inkSoft);
  text-transform: uppercase;
}

.masthead-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--inkSoft);
  text-transform: uppercase;
}

.meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--inkSoft);
  opacity: 0.6;
}

.hero {
  text-align: left;
  margin-bottom: 56px;
  max-width: 760px;
}

.hero-eyebrow {
  margin: 0 0 28px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  opacity: 0.85;
  animation: fadeUp 0.9s ease both;
}

.hero-title {
  margin: 0 0 28px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 76px;
  font-weight: 400;
  line-height: 1.05;
  animation: fadeUp 1s 0.1s ease both;
}

.hero-title em {
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
}

.hero-desc {
  max-width: 620px;
  margin: 0;
  color: var(--inkSoft);
  font-size: 17px;
  line-height: 1.75;
  animation: fadeUp 1s 0.2s ease both;
}

.input-panel {
  margin-bottom: 64px;
  animation: fadeUp 1s 0.3s ease both;
}

.paper-card {
  background: var(--paperDeep);
  border: 1px solid var(--rule);
  padding: 44px 48px 40px;
  position: relative;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 12px 40px -20px rgba(0, 0, 0, 0.2);
}

.paper-card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--rule);
  opacity: 0.25;
  pointer-events: none;
}

.card-header {
  position: relative;
  margin-bottom: 32px;
}

.card-stamp {
  display: inline-block;
  margin-bottom: 14px;
  padding: 3px 10px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  transform: rotate(-1.5deg);
}

.card-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
}

.card-desc {
  margin: 0;
  color: var(--inkSoft);
  font-size: 14px;
  line-height: 1.7;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 36px;
  margin-bottom: 28px;
}

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: 14px;
  cursor: text;
}

.field-wide {
  margin-bottom: 22px;
}

.field-label {
  margin-bottom: 4px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
}

.field-hint {
  margin-bottom: 14px;
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.field input,
.field textarea {
  width: 100%;
  padding: 4px 0 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
  font-family: var(--font-display);
  font-size: 28px;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
  font-size: 20px;
  line-height: 1.65;
}

.field textarea.theme-textarea {
  min-height: 92px;
  font-size: 28px;
  line-height: 1.35;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--inkSoft);
  opacity: 0.45;
  font-style: italic;
}

.field-rule {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--rule);
  opacity: 0.5;
}

.field-rule::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.field.is-focused .field-rule::after,
.field.is-filled .field-rule::after {
  transform: scaleX(1);
}

.suggest-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 20px 0 22px;
  padding-top: 20px;
  border-top: 1px dashed var(--rule);
  opacity: 0.95;
}

.suggest-label {
  margin-right: 8px;
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  transition: all 0.25s ease;
}

.chip:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-1px);
}

.preference-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 26px;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--inkSoft);
  font-size: 13px;
}

.check-line input {
  accent-color: var(--accent);
}

.submit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.submit-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.25s ease;
}

.submit-btn {
  position: relative;
  overflow: hidden;
  padding: 16px 28px;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 16px;
}

.submit-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-101%);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.submit-btn:hover:not(:disabled)::before {
  transform: translateX(0);
}

.submit-label,
.submit-arrow {
  position: relative;
  z-index: 1;
}

.submit-arrow {
  font-size: 18px;
  transition: transform 0.3s ease;
}

.submit-btn:hover:not(:disabled) .submit-arrow {
  transform: translateX(4px);
}

.submit-btn:disabled,
.ghost-btn:disabled,
.chip:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.submit-hint {
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
}

.ghost-btn {
  padding: 12px 22px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
}

.ghost-btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
}

.ghost-btn.small {
  padding: 10px 16px;
  font-size: 13px;
}

.result-panel {
  margin-top: 24px;
  animation: fadeUp 0.6s ease both;
}

.result-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: start;
  padding: 36px 0 28px;
  border-top: 2px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  position: relative;
}

.result-head::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
  opacity: 0.4;
}

.result-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rm-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-size: 14px;
}

.rm-key {
  min-width: 50px;
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.rm-val {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 20px;
}

.rm-val.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.result-stamp {
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
  position: relative;
}

.stamp-circle {
  width: 110px;
  height: 110px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  color: var(--accent);
  transform: rotate(-6deg);
  animation: stampDrop 0.6s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  opacity: 0.85;
}

.stamp-circle::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed var(--accent);
  border-radius: 50%;
  opacity: 0.6;
}

.stamp-text-top,
.stamp-text-bot {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
}

.stamp-text-top {
  top: 14px;
}

.stamp-text-bot {
  bottom: 14px;
}

.stamp-center {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
}

.result-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 36px 0 28px;
  color: var(--inkSoft);
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
}

.result-divider::before,
.result-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  opacity: 0.4;
}

.summary-note {
  margin: 0 0 30px;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  color: var(--inkSoft);
  background: rgba(122, 46, 42, 0.04);
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-line;
}

.summary-meta {
  display: block;
  margin-bottom: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--inkSoft);
  opacity: 0.72;
}

.summary-essay {
  display: block;
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink);
}

.loading-block {
  padding: 8px 0 24px;
}

.loading-line {
  height: 22px;
  margin-bottom: 14px;
  background: var(--paperDeep);
  position: relative;
  overflow: hidden;
}

.loading-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 1.6s infinite;
}

.loading-text {
  margin-top: 24px;
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 12px;
}

.group-card {
  margin-bottom: 52px;
  animation: fadeUp 0.7s ease both;
}

.group-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 24px;
  padding-bottom: 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}

.group-head::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  height: 1px;
  background: var(--rule);
  opacity: 0.35;
}

.group-num {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 54px;
  font-style: italic;
  font-weight: 300;
  line-height: 0.9;
}

.group-title-block {
  padding-bottom: 6px;
}

.group-title {
  margin: 0 0 4px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
}

.group-subtitle {
  margin: 0;
  color: var(--inkSoft);
  font-size: 14px;
  font-style: italic;
}

.group-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding-bottom: 8px;
  text-align: right;
}

.side-label {
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
}

.side-letter {
  color: var(--secondary);
  font-family: var(--font-display);
  font-size: 30px;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
}

.dossier-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 18px 16px 18px 4px;
  border-bottom: 1px dotted rgba(58, 42, 34, 0.3);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease, background 0.3s ease, padding-left 0.3s ease;
  position: relative;
}

.dossier-row.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.dossier-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 60%;
  background: var(--accent);
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

.dossier-row:hover {
  padding-left: 16px;
  background: rgba(122, 46, 42, 0.04);
}

.dossier-row:hover::before {
  transform: translateY(-50%) scaleY(1);
}

.song-idx {
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
}

.song-main {
  min-width: 0;
}

.song-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.song-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
}

.song-dash {
  color: var(--inkSoft);
  opacity: 0.5;
}

.song-artist {
  color: var(--inkSoft);
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
}

.song-reason {
  max-width: 680px;
  margin-top: 2px;
  color: var(--inkSoft);
  font-size: 13px;
  line-height: 1.6;
}

.icon-link {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  transition: all 0.2s;
}

.icon-link:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.result-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
}

.foot-quote {
  color: var(--inkSoft);
  font-family: var(--font-display);
  font-size: 14px;
  font-style: italic;
}

.page-footer {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--inkSoft);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.page-footer .dot {
  opacity: 0.5;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stampDrop {
  from {
    opacity: 0;
    transform: rotate(-20deg) scale(1.4);
  }

  to {
    opacity: 0.85;
    transform: rotate(-6deg) scale(1);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(200%);
  }
}

@media (max-width: 880px) {
  .container {
    padding: 32px 28px 64px;
  }

  .hero-title {
    font-size: 52px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .paper-card {
    padding: 32px 28px;
  }

  .result-head {
    grid-template-columns: 1fr;
  }

  .result-stamp {
    justify-self: end;
  }

  .group-num {
    font-size: 42px;
  }

  .group-title {
    font-size: 24px;
  }

  .group-head {
    grid-template-columns: auto 1fr;
  }

  .group-side {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-start;
  }

  .dossier-row {
    grid-template-columns: 36px 1fr;
  }

  .icon-link {
    grid-column: 2;
  }

  .masthead-meta {
    display: none;
  }
}

@media (max-width: 520px) {
  .container {
    padding: 28px 20px 56px;
  }

  .hero-title {
    font-size: 40px;
  }

  .masthead-title {
    font-size: 22px;
  }

  .submit-row,
  .result-foot {
    align-items: flex-start;
    flex-direction: column;
  }

  .submit-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 14px;
  }
}

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