:root {
  color-scheme: light;
  --ink: #1f1147;
  --muted: #6b6688;
  --paper: #f5f3ff;
  --panel: #ffffff;
  --line: #e6e0f7;
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
  --good: #0891b2;
  --bad: #e11d48;
  --warn: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(236, 72, 153, 0.13), transparent 38rem),
    var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

main {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 5rem 0;
}

.hero {
  margin-bottom: 2.5rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 1rem;
  font-family: ui-serif, Georgia, serif;
  font-size: clamp(2.2rem, 8.5vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.065em;
  line-height: 0.95;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  letter-spacing: -0.045em;
}

.eyebrow {
  margin-bottom: 0.65rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.intro {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.2rem;
}

.about {
  max-width: 44rem;
  margin-bottom: 0;
  color: var(--muted);
}

.about a {
  font-weight: 650;
}

form,
.result,
.reader-preview,
.example {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--panel);
  box-shadow: 0 1.5rem 4rem rgba(31, 17, 71, 0.1);
}

form {
  padding: clamp(1.25rem, 5vw, 2rem);
}

.field + .field {
  margin-top: 1.4rem;
}

label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 750;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.field-heading label {
  margin-bottom: 0;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c7bce8;
  border-radius: 0.65rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0.75rem 0.85rem;
}

textarea {
  min-height: 11rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(124, 58, 237, 0.25);
}

small {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

button {
  margin-top: 1.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 0.85rem 1.25rem;
}

button:hover {
  background: var(--accent-dark);
}

.clear-textarea {
  display: grid;
  width: 1.8rem;
  height: 1.8rem;
  margin: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1;
  padding: 0 0 0.12rem;
}

.clear-textarea:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.spinner {
  margin-left: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

#validation-output,
#results {
  margin-top: 1.25rem;
}

.example {
  overflow-x: auto;
  padding: 1.35rem;
}

.example code {
  white-space: nowrap;
}

.result {
  overflow: visible;
}

.result-header {
  border-bottom: 1px solid var(--line);
  border-radius: 1.25rem 1.25rem 0 0;
  padding: clamp(1.25rem, 5vw, 2rem);
}

.supported .result-header {
  background: rgba(8, 145, 178, 0.1);
}

.validating .result-header {
  background: rgba(124, 58, 237, 0.08);
}

.unsupported .result-header {
  background: rgba(225, 29, 72, 0.08);
}

.result-header p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.reader-preview {
  position: relative;
  z-index: 2;
  padding: clamp(1.25rem, 5vw, 2rem);
}

.reader-preview-header {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.reader-preview-header h3 {
  margin-bottom: 0;
  font-size: 1.5rem;
  letter-spacing: -0.035em;
}

.reader-preview-header small {
  max-width: 22rem;
  margin-top: 0;
  text-align: right;
}

.reader-preview-content {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--panel);
  font-family: ui-serif, Georgia, serif;
  font-size: 1.08rem;
  padding: 1.25rem;
}

.reader-preview-content > :last-child {
  margin-bottom: 0;
}

.reader-preview-content a:not(.universal-mention-link) {
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.13em;
}

.reader-mention {
  position: relative;
  display: inline-block;
}

.universal-mention-link {
  border-radius: 0.3em;
  background: rgba(124, 58, 237, 0.13);
  color: var(--accent-dark);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 800;
  padding: 0.08em 0.22em;
  text-decoration-color: rgba(124, 58, 237, 0.5);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.12em;
}

.universal-mention-link:hover,
.universal-mention-link:focus-visible,
.reader-mention.is-open > .universal-mention-link {
  background: var(--accent);
  color: #fff;
  outline: none;
}

.reader-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.55rem);
  left: 50%;
  display: none;
  width: min(24rem, calc(100vw - 3rem));
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 0.9rem;
  background: #fff;
  box-shadow: 0 1.25rem 3rem rgba(31, 17, 71, 0.22);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  transform: translateX(-50%);
}

.reader-popover::before {
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: 0.65rem;
  content: "";
}

.reader-mention:hover > .reader-popover,
.reader-mention:focus-within > .reader-popover,
.reader-mention.is-open > .reader-popover {
  display: block;
}

.reader-popover-main {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 1rem;
}

.reader-popover img,
.reader-avatar-placeholder {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--paper);
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 800;
  object-fit: cover;
}

.reader-popover-details {
  min-width: 0;
}

.reader-popover-details .eyebrow {
  margin-bottom: 0.2rem;
}

.reader-popover-details strong {
  display: block;
  overflow: hidden;
  font-size: 1.05rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-popover-details a {
  font-size: 0.78rem;
}

.reader-popover .subscribe-demo {
  margin: 0;
}

.reader-feed-note {
  margin: 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.65rem 1rem;
}

.reader-popover .subscribe-explanation {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.profile-preview {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: clamp(1.25rem, 5vw, 2rem);
}

.profile-preview img {
  width: 8rem;
  height: 8rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
  object-fit: cover;
}

.profile-preview h3 {
  margin-bottom: 0.25rem;
  font-size: 1.75rem;
  letter-spacing: -0.04em;
}

.profile-preview p:not(.eyebrow) {
  margin-bottom: 0.35rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.mention-result {
  margin: clamp(1rem, 4vw, 1.5rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: #fff;
}

.mention-result.mention-supported {
  border-color: rgba(8, 145, 178, 0.45);
}

.mention-header {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 1.1rem 1.25rem;
}

.mention-header h3 {
  margin-bottom: 0.2rem;
  font-size: 1.5rem;
  letter-spacing: -0.035em;
}

.mention-header p:last-child {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.mention-status {
  border-radius: 999px;
  background: rgba(8, 145, 178, 0.12);
  color: var(--good);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.6rem;
  text-transform: uppercase;
}

.subscribe-demo {
  align-self: start;
  margin: 0;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
}

.subscribe-explanation {
  border-bottom: 1px solid var(--line);
  background: rgba(124, 58, 237, 0.07);
  padding: 1rem 1.25rem;
}

.subscribe-explanation[hidden] {
  display: none;
}

.subscribe-explanation strong {
  display: block;
  margin-bottom: 0.35rem;
}

.subscribe-explanation p:not(.eyebrow) {
  margin-bottom: 0.3rem;
  overflow-wrap: anywhere;
}

.waiting {
  color: var(--muted);
  padding: 1rem 1.25rem;
}

.waiting .mark {
  margin-right: 0.75rem;
}

.checks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.check {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 0.9rem;
  border-bottom: 1px solid var(--line);
  padding: 1rem clamp(1.25rem, 5vw, 2rem);
}

.check p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.mark {
  padding-top: 0.12rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.check.checking {
  background: rgba(124, 58, 237, 0.05);
}

.check.checking .mark {
  color: var(--accent);
  animation: checking-pulse 1.1s ease-in-out infinite;
}

.check.pass .mark {
  color: var(--good);
}

.check.fail .mark {
  color: var(--bad);
}

.check.warn .mark {
  color: var(--warn);
}

@keyframes checking-pulse {
  0%,
  100% {
    opacity: 0.35;
  }

  50% {
    opacity: 1;
  }
}

.feeds {
  padding: clamp(1.25rem, 5vw, 2rem);
}

.feed {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-left: 0.3rem solid var(--good);
  border-radius: 0.65rem;
  padding: 0.9rem;
}

.feed.invalid {
  border-left-color: var(--bad);
}

.feed header {
  display: flex;
  justify-content: space-between;
}

.feed p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
}

.site-footer {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.25rem 0 2.5rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 560px) {
  main {
    padding: 2.5rem 0;
  }

  .check {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .profile-preview {
    grid-template-columns: 5rem minmax(0, 1fr);
  }

  .profile-preview img {
    width: 5rem;
    height: 5rem;
  }

  .profile-preview .subscribe-demo {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .reader-preview-header {
    display: block;
  }

  .reader-preview-header small {
    margin-top: 0.35rem;
    text-align: left;
  }

  .reader-popover-main {
    grid-template-columns: 3rem minmax(0, 1fr) auto;
  }

  .reader-popover img,
  .reader-avatar-placeholder {
    width: 3rem;
    height: 3rem;
  }

  .mention-header {
    flex-direction: column;
  }

  /* On narrow screens, anchor the popover to the rendered-post box (full content
     width, just below it) instead of centering it on the inline mention — which
     would push it off-screen when the mention sits near a viewport edge. */
  .reader-mention {
    position: static;
  }

  .reader-popover {
    top: calc(100% + 0.55rem);
    right: 0;
    left: 0;
    width: auto;
    transform: none;
  }

  .reader-popover::before {
    display: none;
  }
}
