:root {
  color-scheme: only light;
  font-family: "Courier New", Courier, monospace;
  background: #000;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

button,
a {
  font: inherit;
}

button,
a[href] {
  touch-action: manipulation;
}

.desktop-banner {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #000;
  font-size: 12px;
}

.site-shell {
  width: 100%;
  height: 100dvh;
  padding-top: 48px;
  display: grid;
  place-items: center;
  background: #000;
}

.feed-frame {
  position: relative;
  width: min(430px, 100vw);
  height: calc(100dvh - 48px);
  overflow: hidden;
  color: #000;
  background: #fff;
  border: 1px solid #fff;
}

.feed {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.feed::-webkit-scrollbar {
  display: none;
}

.feed-page {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 76px 68px calc(24px + env(safe-area-inset-bottom)) 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  color: #000;
  background: #fff;
}

.feed-page[data-intro="true"] {
  justify-content: center;
}

.feed-page[data-kind="sobriety"] {
  padding-inline: 46px;
}

.sobriety-grid {
  width: 100%;
  height: 100%;
  max-height: 440px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  font-variant-numeric: tabular-nums;
}

.sobriety-cell {
  min-width: 0;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.sobriety-cell:nth-child(odd) {
  border-right: 1px solid #000;
}

.sobriety-cell:nth-child(-n + 2) {
  border-bottom: 1px solid #000;
}

.sobriety-label,
.sobriety-total,
.sobriety-since {
  margin: 0;
  font-weight: 400;
}

.sobriety-label {
  font-size: 11px;
}

.sobriety-total {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sobriety-days {
  font-size: clamp(26px, 8vw, 38px);
  line-height: 1;
}

.sobriety-unit {
  font-size: 11px;
}

.sobriety-since {
  font-size: 9px;
  white-space: nowrap;
}

.page-ascii {
  min-height: 1px;
  margin: 0;
  overflow: visible;
  color: #000;
  background: transparent;
  font: 400 12px/1.45 "Courier New", Courier, monospace;
  white-space: pre;
}

.page-ascii:empty {
  display: none;
}

.page-copy {
  margin: 0;
}

.page-charm {
  display: block;
  width: 112px;
  max-width: 100%;
  height: auto;
  margin: 0 0 24px;
}

.page-title {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.page-title:empty {
  display: none;
}

.page-writing {
  max-width: 290px;
  margin: 0;
  overflow: visible;
  color: #000;
  background: transparent;
  font: 400 15px/1.45 "Courier New", Courier, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.page-writing a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.page-writing a:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
}

@media (max-height: 620px) {
  .page-title {
    margin-bottom: 14px;
    font-size: 13px;
  }

  .page-writing {
    font-size: 14px;
    line-height: 1.4;
  }
}

.feed-top {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  padding: env(safe-area-inset-top) 14px 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  border-bottom: 1px solid #000;
  background: #fff;
  font-size: 11px;
}

.feed-top h1 {
  grid-column: 1;
  margin: 0;
  font: inherit;
  text-align: left;
}

.feed-top span:nth-child(2) {
  grid-column: 2;
  text-align: center;
}

.feed-actions {
  position: absolute;
  z-index: 6;
  right: 8px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  gap: 8px;
  font-size: 12px;
}

.feed-actions > span,
.feed-actions > button,
.feed-actions > a {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.feed-actions > button,
.feed-actions > a {
  margin: 0;
  padding: 0;
  color: #000;
  border: 0;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

#next-page {
  margin-top: 6px;
  border-top: 1px solid #000;
}

#like-page[aria-pressed="true"] {
  font-weight: 700;
}

.share-dialog button:disabled,
.subscribe-dialog button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.share-dialog,
.subscribe-dialog {
  width: min(340px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  padding: 20px;
  overflow-y: auto;
  color: #000;
  background: #fff;
  border: 1px solid #000;
  font: 400 12px/1.45 "Courier New", Courier, monospace;
}

.share-dialog::backdrop,
.subscribe-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.share-dialog h2,
.subscribe-dialog h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
}

#share-preview {
  display: block;
  max-width: 100%;
  max-height: min(180px, 20dvh);
  width: auto;
  height: auto;
  margin: 16px auto;
  border: 1px solid #000;
}

#share-preview[hidden],
.share-options button[hidden],
.share-options a[hidden] {
  display: none;
}

#share-link,
#subscribe-email {
  width: 100%;
  min-height: 44px;
  margin: 6px 0 14px;
  padding: 8px;
  border: 1px solid #000;
  border-radius: 0;
  color: #000;
  background: #fff;
  font: inherit;
}

.share-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-dialog button,
.subscribe-dialog button,
.share-options a {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #000;
  color: #000;
  background: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

#share-status {
  min-height: 18px;
  margin: 12px 0;
}

#share-status:empty {
  display: none;
}

#subscribe-description {
  margin: 12px 0 20px;
}

#subscribe-email {
  font-size: 16px;
}

#subscribe-status {
  min-height: 18px;
  margin: 14px 0;
}

.subscribe-dialog button:disabled {
  cursor: not-allowed;
}

.subscribe-terms {
  margin: 0 0 18px;
  font-size: 10px;
  line-height: 1.5;
}

.subscribe-terms a {
  color: inherit;
  text-underline-offset: 2px;
}

.tutorial {
  position: absolute;
  z-index: 30;
  inset: 54px 0 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.72);
}

.tutorial[hidden] {
  display: none;
}

.tutorial-box {
  width: min(280px, 100%);
  padding: 24px;
  color: #000;
  border: 1px solid #000;
  background: #fff;
  text-align: center;
}

.tutorial-box p {
  margin: 0 0 8px;
  font-size: 14px;
}

.tutorial-box pre {
  margin: 22px auto;
  overflow: visible;
  color: #000;
  background: transparent;
  font: 400 15px/1.2 "Courier New", Courier, monospace;
  animation: tutorial-nudge 1.1s steps(2, end) infinite;
}

.tutorial-box button {
  min-width: 100px;
  min-height: 44px;
  padding: 0 12px;
  color: #000;
  border: 1px solid #000;
  background: #fff;
  pointer-events: auto;
}

.noscript {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 12px;
  color: #fff;
  background: #000;
  text-align: center;
  font-size: 12px;
}

@keyframes tutorial-nudge {
  50% {
    transform: translateY(-8px);
  }
}

@media (max-width: 699px) {
  .desktop-banner {
    display: none;
  }

  .site-shell {
    padding-top: 0;
    place-items: stretch;
    background: #fff;
  }

  .feed-frame {
    width: 100%;
    height: 100dvh;
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .feed {
    scroll-behavior: auto;
  }

  .tutorial-box pre {
    animation: none;
  }
}
