:root {
  --field: #12343c;
  --field-deep: #0c242b;
  --ink: #f4f7f8;
  --scribe: #06d6a0;
  --line: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--field-deep);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  font-family: Figtree, "Avenir Next", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(880px 420px at 50% -120px, rgba(17, 138, 178, 0.42), transparent 68%),
    radial-gradient(640px 360px at 110% 110%, rgba(6, 214, 160, 0.1), transparent 62%),
    var(--field-deep);
}

button, a { -webkit-tap-highlight-color: transparent; }

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: calc(60px + env(safe-area-inset-top));
  padding:
    env(safe-area-inset-top)
    max(16px, env(safe-area-inset-right))
    0
    max(16px, env(safe-area-inset-left));
  background: rgba(12, 36, 43, 0.82);
  backdrop-filter: saturate(150%) blur(18px);
  -webkit-backdrop-filter: saturate(150%) blur(18px);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.appbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.appbar-brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.appbar-brand span {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.appbar-get,
.dock-button,
.view-app,
.join-button,
.follow,
.read-series,
.continue,
.sheet-go,
.sheet-later,
.metric,
.thread,
.more-lock {
  font-family: inherit;
  cursor: pointer;
}

.appbar-get {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--field-deep);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
}

.appbar-get:hover,
.dock-button:hover,
.view-app:hover,
.join-button:hover,
.follow:hover,
.read-series:hover,
.continue:hover,
.sheet-go:hover { filter: brightness(1.06); }

.appbar-get:active,
.dock-button:active,
.view-app:active,
.join-button:active,
.follow:active,
.read-series:active { transform: translateY(1px); }

.page {
  display: flex;
  justify-content: center;
  padding:
    18px
    max(16px, env(safe-area-inset-right))
    calc(112px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.stack {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  order: 2;
}

.sidebar { display: contents; }

.stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top-snipfics { order: 1; }

.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 2px 0;
}

.preview-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(244, 247, 248, 0.55);
}

.preview-head p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(244, 247, 248, 0.78);
}

.stage, .cta, .top-snipfics, .join, .note, .card, .thread, .more-lock { width: 100%; }

.sharer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px var(--line);
}

.sharer[hidden] { display: none; }

.sharer-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
}

.sharer-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sharer-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 247, 248, 0.55);
}

.sharer-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sharer-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #fff;
  color: var(--field-deep);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.card {
  border-radius: 18px;
  background: #fff;
  color: #1c1c1c;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 44px rgba(0, 0, 0, 0.28);
}

.card.loading {
  min-height: 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(244, 247, 248, 0.88);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 16px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.5; } }

.story-card {
  padding: 16px 16px 12px;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}

.story-linked {
  position: relative;
  cursor: pointer;
}

a.story-hit {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  white-space: nowrap;
  text-indent: 100%;
  color: transparent;
}

a.story-hit:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -4px;
}

.story-linked a.byline,
.story-linked .metric {
  position: relative;
  z-index: 1;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 22px 20px;
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
}

.avatar {
  position: relative;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
}

.story-card .avatar,
.sharer .avatar {
  width: 40px;
  height: 40px;
}

.profile-card .avatar {
  width: 96px;
  height: 96px;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 14%, transparent);
}

.profile-card .avatar.scribe { box-shadow: 0 0 0 4px var(--scribe); }

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.avatar-fallback svg { width: 46%; height: 46%; }
.profile-card .avatar-fallback svg { width: 38%; height: 38%; }

.byline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

a.byline { cursor: pointer; }
a.byline:hover .byline-name { text-decoration: underline; text-underline-offset: 2px; }

.byline > div,
.byline-name { min-width: 0; }

.byline-name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: color-mix(in srgb, currentColor 72%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.byline-date {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  opacity: 0.55;
}

.prompt-kicker,
.kind-kicker {
  margin: 14px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.55;
}

.card-title {
  margin: 12px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  overflow-wrap: anywhere;
}

.card-title.after-kicker { margin-top: 4px; }

.story {
  margin: 10px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.story.solo { margin-top: 14px; }
.story strong { font-weight: 700; }
.story em { font-style: italic; }

.metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  padding-top: 10px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, currentColor 16%, transparent);
}

.metric {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  background: color-mix(in srgb, currentColor 10%, transparent);
  color: color-mix(in srgb, currentColor 78%, transparent);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.metric svg { width: 18px; height: 18px; flex: none; }

button.metric:hover { background: color-mix(in srgb, currentColor 16%, transparent); }

.name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-top: 14px;
}

.kind-kicker + .name-row { margin-top: 4px; }

.profile-card .username {
  margin: 0;
  min-width: 0;
  font-size: clamp(26px, 6vw, 32px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.pencil {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--scribe);
}

.pencil svg { width: 14px; height: 14px; }

.stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  width: 100%;
  margin-top: 16px;
}

.stat { margin: 0; }

.stat strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
}

.meta {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0.7;
}

.bio {
  margin: 14px 0 0;
  max-width: 34em;
  font-size: 16px;
  line-height: 1.5;
  opacity: 0.88;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.profile-link {
  display: inline-block;
  max-width: 100%;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: inherit;
  opacity: 0.8;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.profile-link:hover { opacity: 1; }

.follow,
.read-series {
  appearance: none;
  width: 100%;
  margin-top: 18px;
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--ink, currentColor);
  color: var(--paper, #fff);
  font-size: 15px;
  font-weight: 800;
}

.top-snipfics {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top-snipfics[hidden] { display: none; }

.top-heading {
  margin: 8px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 247, 248, 0.55);
}

.thread,
.more-lock {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  padding: 14px 16px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  box-shadow: inset 0 0 0 1px var(--line);
}

.thread-title,
.more-lock strong {
  font-size: 15px;
  font-weight: 700;
}

.thread-sub,
.more-lock span {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(244, 247, 248, 0.68);
}

.thread:hover,
.more-lock:hover { background: rgba(255, 255, 255, 0.1); }

.note {
  padding: 22px 20px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
}

.kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 247, 248, 0.55);
}

.note p {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: rgba(244, 247, 248, 0.92);
}

.prompt-intro .kicker { margin: 0; }

.prompt-intro h1 {
  margin: 8px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(28px, 6vw, 36px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.prompt-intro p:not(.kicker) {
  margin: 10px 0 0;
  max-width: 34em;
  font-size: 16px;
  line-height: 1.45;
  color: rgba(244, 247, 248, 0.78);
}

.prompt-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.prompt-card .prompt-kicker { margin: 0; }

.prompt-card .story { margin-top: 6px; }

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

.view-app,
.continue,
.join-button,
.dock-button,
.sheet-go {
  appearance: none;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.view-app,
.continue,
.dock-button {
  background: #fff;
  color: var(--field-deep);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.continue { margin-top: 16px; }

.view-app { padding: 14px 18px; line-height: 1.3; text-wrap: balance; }

.cta-note { display: none; }

.layout-profile .cta,
.layout-series .cta,
.stack:has(.follow) .cta,
.stack:has(.read-series) .cta { display: none; }

html.ios-safari .appbar { display: none; }

.join {
  margin-top: 6px;
  padding: 22px 18px 18px;
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 0 0 1px var(--line);
}

.join img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.stars {
  margin: 12px 0 0;
  color: #ffd166;
  font-size: 13px;
  letter-spacing: 0.14em;
}

.stars span:last-child {
  margin-left: 6px;
  letter-spacing: 0;
  color: rgba(244, 247, 248, 0.82);
  font-weight: 700;
}

.join h2 {
  margin: 10px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(26px, 5vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.join p:not(.stars) {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(244, 247, 248, 0.78);
}

.join-button {
  margin-top: 16px;
  background: var(--scribe);
  color: #06281f;
}

.dock {
  position: fixed;
  z-index: 25;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 22px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(12, 36, 43, 0), rgba(12, 36, 43, 0.92) 40%, var(--field-deep));
  pointer-events: none;
}

.dock-button {
  width: min(440px, 100%);
  pointer-events: auto;
}

.sheet {
  width: min(380px, calc(100% - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.sheet::backdrop {
  background: rgba(5, 14, 18, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sheet-card {
  margin: 0;
  padding: 26px 22px 16px;
  border-radius: 24px;
  background: #f7f4ee;
  color: #1c1c1c;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.sheet-card img {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}

.sheet-card h2 {
  margin: 14px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.sheet-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: #3f3c37;
}

.sheet-card p:empty { display: none; }

.sheet-go {
  margin-top: 18px;
  background: var(--field);
  color: #fff;
}

.sheet-later {
  appearance: none;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: #5e5a54;
  font-size: 15px;
  font-weight: 650;
}

.gated template { display: none; }

.appbar-get:focus-visible,
.appbar-brand:focus-visible,
.dock-button:focus-visible,
.view-app:focus-visible,
.join-button:focus-visible,
.follow:focus-visible,
.read-series:focus-visible,
.continue:focus-visible,
.metric:focus-visible,
.thread:focus-visible,
.more-lock:focus-visible,
.sharer-person:focus-visible,
.sharer-button:focus-visible,
.profile-link:focus-visible,
.sheet-go:focus-visible,
.sheet-later:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.sheet-go:focus-visible,
.sheet-later:focus-visible,
.follow:focus-visible,
.read-series:focus-visible { outline-color: var(--field); }

@media (min-width: 960px) {
  .dock { display: none; }

  .page {
    align-items: flex-start;
    padding: 28px 32px 72px;
  }

  .appbar {
    padding-left: max(32px, env(safe-area-inset-left));
    padding-right: max(32px, env(safe-area-inset-right));
  }

  .story-card { padding: 20px 24px 14px; }

  .story {
    font-size: 17.5px;
    line-height: 1.55;
  }

  .card-title { font-size: 20px; }

  .join h2 { font-size: 26px; }

  .layout-snipfic .stack {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    column-gap: 64px;
    row-gap: 16px;
    align-items: start;
  }

  .layout-snipfic .sharer { grid-column: 1; grid-row: 1; }
  .layout-snipfic .stage { grid-column: 1; grid-row: 2; min-width: 0; }
  .layout-snipfic .rail { display: contents; }

  .layout-snipfic .cta { grid-column: 1; grid-row: 3; }

  .layout-snipfic .join {
    grid-column: 2;
    grid-row: 2 / span 2;
    margin-top: 0;
    position: sticky;
    top: 84px;
    align-self: start;
  }

  .layout-snipfic .stack:not(:has(.sharer:not([hidden]))) .stage { grid-row: 1; }
  .layout-snipfic .stack:not(:has(.sharer:not([hidden]))) .cta { grid-row: 2; }
  .layout-snipfic .stack:not(:has(.sharer:not([hidden]))) .join { grid-row: 1 / span 2; }

  html.ios-safari .layout-snipfic .join { top: 16px; }

  .stack:has(.sidebar) {
    width: min(1140px, 100%);
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    column-gap: 72px;
    row-gap: 16px;
    align-items: start;
  }

  .stack:has(.sidebar) .sharer {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: start;
    width: auto;
    max-width: 100%;
  }

  .stack:has(.sidebar) .sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    min-width: 0;
  }

  .stack:has(.sidebar):not(:has(.sharer:not([hidden]))) .sidebar,
  .stack:has(.sidebar):not(:has(.sharer:not([hidden]))) .top-snipfics { grid-row: 1; }

  .stack:has(.sidebar) .top-snipfics {
    grid-column: 2;
    grid-row: 2;
    order: 0;
    min-width: 0;
  }

  .stack:has(.sidebar) .join { margin-top: 0; border-radius: 18px; }

  .stack:has(.sidebar):has(.top-snipfics[hidden]) {
    width: min(440px, 100%);
    grid-template-columns: minmax(0, 1fr);
  }

  .stack:has(.top-heading) .top-heading {
    margin: 2px 0 0;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card.loading { animation: none; }
}
