:root {
  --maroon: #6f1d2c;
  --ink: #24151a;
  --gold: #f0b429;
  --paper: #fff8ea;
  --page: #fbf6ee;
  --field: #f6eee0;
  --line: #e6d3b2;
  --muted: #8a7a72;
  --note-1: #fff1b8;
  --note-2: #ffd6c9;
  --note-3: #d8efe8;
  --note-4: #e4d7ff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: Outfit, sans-serif;
  background: var(--page);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Cover the initial font/layout adjustment and the footer's first canvas frame. */
.entry-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #000;
  opacity: 1;
  transition: opacity 280ms ease;
  animation: entry-loader-fallback 1ms linear 8s forwards;
}

.entry-loader.is-ready {
  opacity: 0;
  pointer-events: none;
}

.entry-loader__track {
  width: min(60vw, 240px);
  height: 4px;
  background: #123420;
}

.entry-loader__bar {
  width: 100%;
  height: 100%;
  background: #4cff88;
  box-shadow: 0 0 9px #4cff88, 0 0 20px #3cc86e80;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

@keyframes entry-loader-fallback {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  .entry-loader { transition: none; }
  .entry-loader__bar { transform: none; }
}

.first-screen,
main,
.paper-grain {
  transition: filter 0.28s ease;
}

body.modal-open .first-screen,
body.modal-open main,
body.modal-open .paper-grain,
body.modal-open .topbar,
body.modal-open .stage {
  filter: blur(7px);
}

.paper-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}

.first-screen {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding-bottom: 20px;
}

.stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--page);
}

body[data-view="wall"] .stage {
  background: var(--maroon);
}

.intro,
main,
.view-tabs {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100% - 40px));
  margin-left: auto;
  margin-right: auto;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 14px 20px 12px;
  background: var(--page);
  border-bottom: 3px solid var(--maroon);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  width: min(1280px, 100%);
  margin: 0 auto;
}

.crest {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--maroon);
  color: var(--gold);
  font-family: Fraunces, serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
}

.kicker {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a5a48;
}

h1,
h2,
h3 {
  font-family: Fraunces, serif;
  margin: 0;
}

h1 {
  font-size: 1.28rem;
  color: var(--maroon);
}

.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 8px;
  flex-shrink: 0;
  max-width: 420px;
}

button.view-tab {
  display: grid;
  place-items: center;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  border: 2px solid var(--maroon);
  border-radius: 999px;
  padding: 12px 18px;
  background: transparent;
  color: var(--maroon);
  cursor: pointer;
  text-align: center;
  filter: none;
}

button.view-tab.is-active {
  background: var(--maroon);
  color: #fff8ea;
  border-color: var(--maroon);
}

button.view-tab:hover {
  filter: none;
  background: rgba(111, 29, 44, 0.08);
}

button.view-tab.is-active:hover {
  background: var(--maroon);
}

body[data-view="wall"] button.view-tab {
  border-color: rgba(255, 248, 234, 0.85);
  color: #fff8ea;
  background: transparent;
}

body[data-view="wall"] button.view-tab:hover {
  background: rgba(255, 248, 234, 0.08);
}

body[data-view="wall"] button.view-tab.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

body[data-view="wall"] button.view-tab.is-active:hover {
  background: var(--gold);
}

body[data-view="wall"] #message-view {
  display: none;
}

body[data-view="message"] #wall-view {
  display: none;
}

#wall-view {
  flex: 1 1 auto;
}

.intro {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  gap: 20px;
  align-items: center;
  padding: 18px 0 16px;
}

.hero {
  padding: 0;
}

h2 {
  font-size: clamp(1.7rem, 3.2vw, 2.55rem);
  line-height: 1.12;
  color: var(--maroon);
}

.lede {
  max-width: 34rem;
  margin: 12px 0 0;
  font-size: 0.98rem;
  line-height: 1.5;
  color: #5b3f3a;
}

.composer-wrap {
  padding: 8px 0 12px;
  min-width: 0;
}

.notes article,
.empty {
  background: var(--paper);
  border: 1.5px solid #d7b57a;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 14px 32px rgba(80, 40, 20, 0.12);
}

.composer {
  width: 100%;
  padding: 26px 24px 22px;
  border-radius: 28px;
  background: #fff;
  border: 0;
  box-shadow: 0 22px 48px rgba(80, 40, 20, 0.14);
}

.composer-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 18px;
}

.composer-head h3,
.composer-head p {
  display: block;
  width: 100%;
  margin: 0;
}

.composer-head h3 {
  color: var(--maroon);
  font-size: 1.7rem;
}

.composer-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

#char-count {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
}

.composer-head p {
  color: var(--muted);
}

.wall {
  padding: 20px 0 80px;
}

.wall-head {
  margin-bottom: 20px;
}

.wall-head h3 {
  color: #fff8ea;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
}

.wall-head p {
  margin: 6px 0 0;
  color: var(--gold);
  font-weight: 600;
}

.composer label {
  display: grid;
  gap: 8px;
  margin: 0;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--maroon);
}

input,
textarea {
  font: inherit;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: inherit;
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--field);
}

input::placeholder,
textarea::placeholder {
  color: #b0a49a;
}

input:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(111, 29, 44, 0.16);
}

textarea {
  resize: vertical;
  min-height: 8.5rem;
  height: clamp(8.5rem, 18vh, 12rem);
}

.composer-foot {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.composer-foot button {
  width: 100%;
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  background: var(--gold);
  color: var(--ink);
  cursor: pointer;
}

.composer-foot button:hover {
  filter: brightness(1.04);
}

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--maroon);
  color: #fff8ea;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  filter: none;
}

.status {
  min-height: 1.15em;
  margin: 8px 0 0;
}

.status.ok {
  color: #1f6b4a;
}

.status.err {
  color: #9c1f2d;
}

.notes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  max-width: 520px;
}

@media (min-width: 900px) {
  .notes {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    max-width: none;
  }
}

.notes article {
  position: relative;
  padding: 28px 18px 16px;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 12px 24px rgba(20, 8, 10, 0.22);
}

.notes article::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e0a21a;
  transform: translateX(-50%);
  box-shadow: 0 3px 0 #8d5a12;
}

.notes article:nth-child(4n + 1) {
  background: var(--note-1);
}
.notes article:nth-child(4n + 2) {
  background: var(--note-2);
}
.notes article:nth-child(4n + 3) {
  background: var(--note-3);
}
.notes article:nth-child(4n) {
  background: var(--note-4);
}

.notes p {
  margin: 0;
  white-space: pre-wrap;
  font-family: Caveat, cursive;
  font-size: 1.55rem;
  line-height: 1.35;
  color: #3a241c;
}

.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 0.82rem;
  color: #704c3d;
}

button.heart {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1.5px solid rgba(111, 29, 44, 0.28);
  background: rgba(255, 255, 255, 0.45);
  color: var(--maroon);
  font-size: 1.05rem;
  line-height: 1;
  filter: none;
}

button.heart[aria-pressed="true"] {
  background: #fff;
  color: #c43b4f;
}

.empty {
  grid-column: 1 / -1;
  padding: 28px;
  border-style: dashed;
  border-radius: 18px;
  color: #f3e2c8;
  background: transparent;
  box-shadow: none;
}

@media (min-width: 900px) {
  .intro {
    grid-template-columns: minmax(240px, 0.85fr) minmax(360px, 1.15fr);
    gap: 24px 40px;
  }

  .hero {
    padding-right: 8px;
  }
}

@media (max-width: 899px) {
  .topbar {
    padding: 12px 20px 10px;
  }

  .intro {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
    align-items: stretch;
    padding: 8px 0 12px;
  }

  .hero {
    display: none;
  }

  .composer-wrap,
  .composer {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .composer {
    padding: 22px 20px 18px;
  }

  textarea {
    min-height: 8rem;
    height: auto;
    max-height: none;
  }
}

@media (max-height: 720px) {
  .intro {
    gap: 10px;
    padding: 10px 0 12px;
  }

  .lede {
    margin-top: 6px;
  }

  textarea {
    min-height: 6.5rem;
  }
}

.sent-dialog {
  border: 0;
  padding: 16px;
  margin: 0;
  background: transparent;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
}

.sent-dialog[open] {
  display: grid;
  place-items: center;
}

.sent-dialog::backdrop {
  background: rgba(36, 21, 26, 0.28);
  backdrop-filter: blur(8px);
}

.sent-card {
  width: min(320px, calc(100vw - 40px));
  padding: 22px 20px;
  border-radius: 22px;
  background: #fff;
  border: 0;
  box-shadow: 0 16px 36px rgba(80, 40, 20, 0.18);
  text-align: center;
}

.sent-card h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  color: var(--maroon);
}

.sent-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

/* ===== Doomsday theme =====
   Idea: a dark riveted iron wall in Doom green-black. Notes are real paper scraps
   taped up by hand. Green is the "ink" for actions only; nothing glows except the logo. */
:root {
  --maroon: #3fd46b;   /* accent var kept so base rules follow: Doom green */
  --ink: #e8e4d8;      /* bone, not pure white */
  --gold: #b8913f;
  --page: #0a0d0b;
  --paper: #e9e4d4;
  --field: #121714;
  --line: #2a332d;
  --muted: #7f8a83;
}

body {
  font-family: Rajdhani, sans-serif;
  font-weight: 500;
  font-size: 1.05rem;
  background: var(--page);
}

/* iron plate seams instead of noise */
.paper-grain {
  opacity: 1;
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 180px 100%,
    linear-gradient(rgba(0,0,0,.5) 2px, transparent 2px) 0 0 / 100% 240px;
}

.stage,
body[data-view="wall"] .stage { background: transparent; }

.topbar {
  background: #060807;
  border-bottom: 2px solid var(--maroon);
}

img.crest {
  width: 150px;
  height: 64px;
  border-radius: 4px;
  object-fit: cover; /* wide box crops the square art to its title band */
}

.kicker { color: var(--gold); letter-spacing: 0.16em; }

h1, h2, h3 { font-family: Cinzel, serif; font-weight: 800; color: var(--ink); }
h1 { text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); }
h2 { color: var(--ink); }
.lede { color: #a7ab9f; }

/* tabs (superseded by the segmented control further down) */
.view-tabs { gap: 0; border-bottom: 1px solid var(--line); }
button.view-tab,
body[data-view="wall"] button.view-tab {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  box-shadow: none;
  padding: 14px 8px;
}
button.view-tab:hover,
body[data-view="wall"] button.view-tab:hover { background: transparent; color: var(--ink); }
button.view-tab.is-active,
button.view-tab.is-active:hover,
body[data-view="wall"] button.view-tab.is-active,
body[data-view="wall"] button.view-tab.is-active:hover {
  background: transparent;
  color: var(--ink);
}

/* composer: an iron plate with rivets, no glow */
.composer {
  position: relative;
  background: #141a16;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset;
}
.composer::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  background:
    radial-gradient(circle, #3a443d 2.5px, transparent 3px) left top / 12px 12px no-repeat,
    radial-gradient(circle, #3a443d 2.5px, transparent 3px) right top / 12px 12px no-repeat,
    radial-gradient(circle, #3a443d 2.5px, transparent 3px) left bottom / 12px 12px no-repeat,
    radial-gradient(circle, #3a443d 2.5px, transparent 3px) right bottom / 12px 12px no-repeat;
}
.composer-head h3 { color: var(--ink); }
.composer label { color: var(--gold); }

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
}
input::placeholder,
textarea::placeholder { color: #59625c; }
input:focus,
textarea:focus { border-color: var(--maroon); box-shadow: none; }

button,
.composer-foot button {
  background: var(--maroon);
  color: #06110a;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.status.err { color: #ff7a6b; }
.status.ok { color: var(--maroon); }

.sent-card {
  background: var(--paper);
  border-radius: 2px;
  transform: rotate(-1.5deg);
}
.sent-card h2 { color: #1a1d1b; }
.sent-card p { color: #4d4a40; }
.sent-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }

/* ---- the wall ----
   Principles: capped card size (long notes can't dominate), 8px spacing rhythm,
   44px tap targets, message text is the loudest thing, meta is quietest. */
:root {
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px;
  --note-lines: 5;
  --note-size: 1.6rem;
  --note-lh: 1.3;
}

.wall-head { margin-bottom: var(--s4); }
.wall-head h3 { color: var(--ink); }
.wall-head p { color: var(--muted); font-weight: 500; }

.notes {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s4) var(--s3);   /* extra row gap leaves room for the tape */
  max-width: none;
  align-items: start;   /* cards keep their own height in a row */
}
@media (min-width: 640px) { .notes { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .notes { grid-template-columns: repeat(3, 1fr); } }

.notes article,
.notes article:nth-child(n) {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--s4) var(--s3) var(--s1);
  background: var(--paper);
  color: #1d1f1c;
  border: 0;
  border-radius: 1px;
  box-shadow: 0 2px 1px rgba(0,0,0,.35), 0 10px 18px -8px rgba(0,0,0,.6);
  transform: rotate(var(--tilt, -0.8deg));
  --more: #1f6b3a;
}

/* each scrap a little different: angle, paper stock, tape */
.notes article:nth-child(4n + 2) { --tilt: 1.1deg; background: #dfe6d3; }
.notes article:nth-child(4n + 3) { --tilt: -1.4deg; background: #efe9dc; }
.notes article:nth-child(4n)     { --tilt: 0.6deg; background: #1d3a26; color: #e6e9df; --more: #9fe3b4; }
.notes article:nth-child(5n)     { --tilt: -0.3deg; }

.notes article::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 92px;
  height: 24px;
  border-radius: 0;
  background: rgba(214, 205, 170, 0.72);
  box-shadow: none;
  transform: translateX(-50%) rotate(-3deg);
}
.notes article:nth-child(3n)::before { left: 22%; transform: translateX(-50%) rotate(4deg); width: 70px; }

/* max-height body: short notes stay short, long notes clamp at --note-lines */
.notes .note-body {
  margin: 0;
  font-family: Caveat, cursive;
  font-size: var(--note-size);
  line-height: var(--note-lh);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: inherit;
  max-height: calc(var(--note-size) * var(--note-lh) * var(--note-lines));
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--note-lines);
  line-clamp: var(--note-lines);
  overflow: hidden;
}

/* "See more": reads as a darker ink line, behaves as a real button */
button.see-more {
  align-self: flex-start;
  min-height: 44px;
  margin: 0 0 calc(-1 * var(--s2));  /* its own 44px tap height already spaces it from the foot */
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--more);
  font: 700 0.95rem/1 Rajdhani, sans-serif;
  letter-spacing: 0.02em;
  text-transform: none;
  display: none;
}
.is-clamped button.see-more { display: inline-block; }
button.see-more:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.note-foot {
  margin-top: var(--s2);
  padding-top: var(--s1);
  border-top: 1px dashed currentColor;
  color: inherit;
  font-size: 0.85rem;
}
.note-foot span { opacity: 0.7; }

button.heart,
button.heart[aria-pressed="true"] {
  min-width: 44px;
  min-height: 44px;
  width: auto;
  height: auto;
  margin-right: -10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  opacity: 0.7;
  font-size: 1.3rem;
  letter-spacing: 0;
}
button.heart[aria-pressed="true"] { color: #c2312f; opacity: 1; }

.heart .like-count {
  margin-left: 0.3em;
  font: 600 0.75rem/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
.heart:disabled { opacity: 0.45; cursor: wait; }
.wall-load-marker {
  display: block;
  min-height: 44px;
  margin: 24px auto 36px;
  padding: 10px 18px;
  border: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.wall-load-marker[hidden] { display: none; }
.wall-load-marker:focus-visible,
.heart:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 2px;
}

/* ---- full-note modal: the same paper, larger, straight for reading ---- */
.note-dialog {
  border: 0;
  margin: 0;
  padding: var(--s2);
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  background: transparent;
}
.note-dialog[open] { display: grid; place-items: center; }
.note-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }

.note-full {
  position: relative;
  width: min(560px, 100%);
  max-height: min(78dvh, 720px);
  display: flex;
  flex-direction: column;
  padding: var(--s4) var(--s3) var(--s2);
  background: var(--paper);
  color: #1d1f1c;
  box-shadow: 0 20px 40px rgba(0,0,0,.6);
}
.note-full[data-stock="1"] { background: #dfe6d3; }
.note-full[data-stock="2"] { background: #efe9dc; }
.note-full[data-stock="3"] { background: #1d3a26; color: #e6e9df; }
.note-full::before {
  content: "";
  position: absolute;
  top: -11px; left: 50%;
  width: 110px; height: 24px;
  background: rgba(214, 205, 170, 0.8);
  transform: translateX(-50%) rotate(-2deg);
}
.note-full-body {
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Caveat, cursive;
  font-size: 1.75rem;
  line-height: 1.3;
}
.note-full-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-top: var(--s2);
  padding-top: var(--s1);
  border-top: 1px dashed currentColor;
  font-size: 0.85rem;
}
.note-full-meta { opacity: 0.7; }
button.note-close {
  min-height: 44px;
  padding: 0 var(--s2);
  background: #1d1f1c;
  color: var(--paper);
}
.note-full[data-stock="3"] button.note-close { background: var(--paper); color: #1d3a26; }

@media (prefers-reduced-motion: no-preference) {
  .note-dialog[open] .note-full { animation: note-in 0.18s ease-out; }
  @keyframes note-in { from { opacity: 0; transform: translateY(12px) rotate(-1deg); } }
}

body:has(.note-dialog[open]) .stage,
body:has(.note-dialog[open]) .topbar { filter: blur(3px); }

/* mobile: logo is the header, duplicate text hidden visually (alt text covers it) */
@media (max-width: 899px) {
  .brand { justify-content: center; }
  img.crest { width: min(260px, 70vw); height: 84px; }
  .brand > div {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
  .composer { padding: 22px 18px 18px; }
  .composer-head h3 { font-size: 1.4rem; }
}

/* ---- Doomsday details: gold rune strips (pixel art from tools/pixel_art.py) ---- */
.topbar {
  border-bottom: 0;
  box-shadow: none;
  padding-bottom: 12px;
  position: relative;
}
.topbar::after,
.composer-head::before {
  content: "";
  display: block;
  height: 12px;
  background: url("/rune-band.png") repeat-x 0 0 / 64px 12px;
  image-rendering: pixelated;
}
.topbar::after { position: absolute; left: 0; right: 0; bottom: -12px; }
.stage { padding-top: 12px; }

.composer { border-color: #3a3424; }  /* dim gold edge like the posters' trim */
.composer-head::before { margin: -8px -4px 10px; }

/* pixel footer scene on the message page: fills the leftover space, full bleed */
.first-screen { padding-bottom: 0; }
.doom-stage {
  flex: 1 0 auto;            /* fill leftover space, never get squashed */
  display: flex;
  align-items: flex-end;     /* floor sits on the bottom edge */
  width: 100%;
  overflow: hidden;
  line-height: 0;
}
#doom-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
/* intro takes its natural height so the pixel scene gets the leftover space */
.intro { flex: 0 0 auto; }

/* ---- short screens: tighten the form so form + duel fit with no scrolling ---- */
@media (max-height: 860px) {
  .intro { padding: 6px 0 8px; }
  .composer-wrap { padding: 4px 0 8px; }
  .composer { padding: 16px 18px 14px; }
  .composer-head { margin-bottom: 10px; gap: 4px; }
  .composer-head::before { margin: -4px -4px 8px; }
  .composer-fields { gap: 10px; }
  textarea { height: 6rem; min-height: 4.5rem; }
  .composer-foot { margin-top: 8px; gap: 8px; }
  .composer-foot button { padding: 12px 18px; }
  .view-tabs { margin-top: 8px; margin-bottom: 4px; }
  .status { min-height: 0; margin: 0; }
}
@media (max-height: 700px) {
  img.crest { height: 60px; }
  .topbar { padding-top: 8px; padding-bottom: 8px; }
  .composer-head p { display: none; }
  .composer-head h3 { font-size: 1.2rem; }
  button.view-tab { padding: 10px 8px; }
  textarea { height: 4.5rem; min-height: 4rem; }
  input, textarea { padding: 10px 12px; }
  .composer label { gap: 4px; }
  .composer-foot button { padding: 10px 18px; }
}
@media (max-height: 600px) {
  img.crest { height: 48px; }
  .composer { padding: 12px 14px 10px; }
  .composer-fields { gap: 6px; }
  textarea { height: 3.4rem; min-height: 3.4rem; }
  #char-count { display: none; }
}

/* =====================================================================
   The window and the hall.
   From the poster research: the recurring image is a tall arched
   stained-glass window in a dark, symmetric throne hall, lit from above.
   The message card is smoked glass in a stone frame (the arched window was
   removed at the user's request); the page is the hall.
   (Originally: arched fanlight, stone frame, stone
   transom, smoked glass); the page is the hall. Flat colour, no glow.
   ===================================================================== */
:root {
  --stone: #27302a;             /* window frame + transom */
  --came: #050806;              /* lead between panes and around the stone */
  --smoked: rgba(9, 16, 12, 0.34);   /* smoked glass: the hall smoke shows through */
  --hall: #0a0f0c;
}

/* the hall: near-black, one wash of window light from above */
body,
.stage,
body[data-view="wall"] .stage { background: transparent; }
.paper-grain {
  opacity: 1;
  background:
    radial-gradient(ellipse 55% 38% at 50% 0%, rgba(46, 140, 80, 0.16), transparent 72%),
    var(--hall);
}
/* two stone pillars frame the page when there is room: throne-room symmetry */
@media (min-width: 760px) {
  .paper-grain {
    background:
      linear-gradient(90deg,
        #0f1612 0 56px, #1d2621 56px 58px, transparent 58px,
        transparent calc(100% - 58px), #1d2621 calc(100% - 58px) calc(100% - 56px), #0f1612 calc(100% - 56px)),
      radial-gradient(ellipse 55% 38% at 50% 0%, rgba(46, 140, 80, 0.16), transparent 72%),
      var(--hall);
  }
}

/* the card: see-through smoked glass in a stone frame */
.composer {
  position: relative;
  padding: 22px 22px 20px;
  border: 6px solid var(--stone);
  border-radius: 4px;
  background: var(--smoked);
  box-shadow: inset 0 0 0 2px var(--came), 0 24px 48px -24px rgba(0, 0, 0, 0.8);
}
.composer::before { content: none; }
.composer-head::before { display: none; }       /* no stained-glass strip on the card */
.composer-head h3 { color: var(--ink); }

input,
textarea {
  background: #070c09;
  border: 1px solid #1f2a23;
  border-radius: 2px;
}
input:focus,
textarea:focus { border-color: var(--maroon); box-shadow: none; }

/* poster caption lettering */
.kicker,
.composer label,
.wall-head p { letter-spacing: 0.22em; }

/* short screens: tighter form keeps form + footer on one screen */
@media (max-height: 960px) { .composer { padding: 18px 18px 14px; } textarea { height: 5.5rem; min-height: 4.5rem; } }
@media (max-height: 860px) { textarea { height: 5rem; } }
@media (max-height: 760px) { .composer { padding: 14px 16px 12px; } textarea { height: 4rem; min-height: 3.5rem; } }
@media (max-height: 640px) { .composer { padding: 12px 14px 10px; } }
@media (max-height: 600px) { textarea { height: 3.2rem; min-height: 3.2rem; } }

/* ---- Send: a forged iron plate with chamfered corners; the label uses the same
   Cinzel + brushed-steel lettering as the headings (.metal-text) ---- */
.composer-foot button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px;
  border: 0;
  border-radius: 0;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px),
                     calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  background: linear-gradient(180deg, #2b3431, #151b19);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px #3a4541;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.composer-foot button .metal-text {
  font: 800 1.1rem/1 Cinzel, serif;
  letter-spacing: 0.3em;
  margin-right: -0.3em;                       /* balance the trailing letter-space */
  text-transform: uppercase;
}
.composer-foot button:hover,
.composer-foot button:focus-visible {
  filter: none;
  outline: none;
  background: linear-gradient(180deg, #36413d, #1c2421);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 0 0 1px #5a6a64;
}
.composer-foot button:focus-visible { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 0 0 2px var(--maroon); }
.composer-foot button:active { transform: translateY(1px); }
.composer-foot button:disabled { opacity: 0.55; }

/* ---- background smoke: two slow layers drifting opposite ways, thickest low in the hall ---- */
.paper-grain::before,
.paper-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to top, #000 0%, rgba(0, 0, 0, 0.75) 55%, rgba(0, 0, 0, 0.25) 100%);
  mask-image: linear-gradient(to top, #000 0%, rgba(0, 0, 0, 0.75) 55%, rgba(0, 0, 0, 0.25) 100%);
}
.paper-grain::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='600'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0045 .009' numOctaves='4' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 1 0 0 0 0 .34 1.9 0 0 0 -.78'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E") 0 0 / 900px 600px repeat;
  opacity: 0.46;
}
.paper-grain::after {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1300' height='800'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.003 .007' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .06 0 0 0 0 .78 0 0 0 0 .26 2 0 0 0 -.88'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E") 0 0 / 1300px 800px repeat;
  opacity: 0.36;
}
/* Performance: the layers slide with transform (composited on the GPU) instead of
   animating background-position (a full-screen repaint every frame). Each layer is one
   texture tile wider than the screen and slides exactly one tile, so the loop is seamless. */
.paper-grain { overflow: hidden; contain: strict; }
.paper-grain::before { inset: 0 auto 0 -900px; width: calc(100% + 900px); }    /* drifts right */
.paper-grain::after { inset: 0 auto 0 0; width: calc(100% + 1300px); }        /* drifts left */
@media (prefers-reduced-motion: no-preference) {
  .paper-grain::before { will-change: transform; animation: smoke-a 95s linear infinite; }
  .paper-grain::after { will-change: transform; animation: smoke-b 150s linear infinite; }
  @keyframes smoke-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(900px, 0, 0); } }
  @keyframes smoke-b { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-1300px, 0, 0); } }
}

/* ---- brushed-steel lettering for display headings: bright top edge, light band,
   dark band through the middle, medium lower half, fine horizontal brushing and
   diagonal scratches. Headings only; body text stays plain for readability. ---- */
h1,
h2,
.composer-head h3,
.wall-head h3,
.metal-text {
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, #ffffff 0%, #e4e8e2 18%, #c9cfc8 40%, #7f8a84 50%, #9aa49e 58%, #c2c9c3 78%, #8b958f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0.5px rgba(10, 20, 14, 0.6);   /* crisp edge like stamped metal */
  filter: none;
}

/* ---- tabs: segmented control. A dark track; a forged plate slides under the
   active tab (driven by body[data-view], which app.js already sets). ---- */
.view-tabs {
  position: relative;
  gap: 0;
  padding: 4px;
  border: 1px solid #26302b;
  border-radius: 8px;
  background: rgba(4, 8, 6, 0.6);
}
.view-tabs::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 5px;
  background: linear-gradient(180deg, #2b3431, #151b19);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px #3a4541;
  transition: transform 0.25s ease;
}
body[data-view="wall"] .view-tabs::before { transform: translateX(100%); }
button.view-tab,
button.view-tab:hover,
button.view-tab.is-active,
button.view-tab.is-active:hover,
body[data-view="wall"] button.view-tab,
body[data-view="wall"] button.view-tab:hover,
body[data-view="wall"] button.view-tab.is-active,
body[data-view="wall"] button.view-tab.is-active:hover {
  position: relative;
  z-index: 1;
  border: 0;
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
  clip-path: none;
  padding: 10px 8px;
  letter-spacing: 0.2em;
  color: var(--muted);
}
button.view-tab:hover,
body[data-view="wall"] button.view-tab:hover { color: var(--ink); }
button.view-tab.is-active,
button.view-tab.is-active:hover,
body[data-view="wall"] button.view-tab.is-active,
body[data-view="wall"] button.view-tab.is-active:hover { color: var(--ink); }
button.view-tab:focus-visible { outline: 2px solid var(--maroon); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { .view-tabs::before { transition: none; } }
@media (max-height: 600px) { .composer-foot button { padding: 10px 14px; } }

/* ---- header: title on the left in heavy slanted steel capitals with a green rim
   (same feel as the logo's own lettering); small logo on the right ---- */
.brand,
.brand:has(> div) { justify-content: flex-start; align-items: center; gap: 14px; }
.brand > div {                               /* always visible now, on every width */
  position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; max-width: none;
}
.topbar h1 {
  font-family: "Exo 2", sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  -webkit-text-stroke: 0;
  filter: none;
  padding-right: 0.08em;                     /* italic overhang */
}
.topbar .kicker { margin-bottom: 4px; }
img.crest,
.brand img.crest {
  width: 92px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 0 0 1px #26302b;
}
@media (max-width: 899px) {
  .brand { justify-content: flex-start; gap: 12px; }
  img.crest, .brand img.crest { width: 72px; height: 32px; }
  .topbar .kicker { font-size: 0.56rem; letter-spacing: 0.14em; }
}
@media (max-height: 700px), (max-height: 600px) { img.crest, .brand img.crest { width: 72px; height: 32px; } }
button.see-more:hover { filter: none; color: var(--ink); }
@media (max-height: 600px) { .topbar h1 { font-size: 1.4rem; } .topbar .kicker { display: none; } }

/* ---- tabs (user spec): brushed-steel labels, no box/borders, a "|" divider in the
   middle, and a plain white underline that slides to the active tab ---- */
.view-tabs {
  position: relative;
  gap: 0;
  padding: 0 0 8px;
  border: 0;
  border-radius: 0;
  background: none;
}
.view-tabs::before {                        /* the sliding underline */
  content: "";
  position: absolute;
  top: auto;
  bottom: 0;
  left: 12%;
  width: 26%;
  height: 2px;
  border-radius: 0;
  background: #f4f1e8;
  box-shadow: none;
  transform: none;
  transition: left 0.3s ease;
}
body[data-view="wall"] .view-tabs::before { left: 62%; transform: none; }
.view-tabs::after {                         /* the "|" between the two tabs */
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 1.1em;
  background: rgba(244, 241, 232, 0.55);
  transform: translate(-50%, calc(-50% - 4px));
}
button.view-tab,
button.view-tab:hover,
button.view-tab.is-active,
button.view-tab.is-active:hover,
body[data-view="wall"] button.view-tab,
body[data-view="wall"] button.view-tab:hover,
body[data-view="wall"] button.view-tab.is-active,
body[data-view="wall"] button.view-tab.is-active:hover {
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, #ffffff 0%, #e4e8e2 18%, #c9cfc8 40%, #7f8a84 50%, #9aa49e 58%, #c2c9c3 78%, #8b958f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  border: 0;
  box-shadow: none;
  font: 800 0.95rem/1 Cinzel, serif;
  letter-spacing: 0.22em;
  padding: 12px 8px;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}
button.view-tab:hover,
body[data-view="wall"] button.view-tab:hover { opacity: 0.8; }
button.view-tab.is-active,
button.view-tab.is-active:hover,
body[data-view="wall"] button.view-tab.is-active,
body[data-view="wall"] button.view-tab.is-active:hover { opacity: 1; }
button.view-tab:focus-visible { outline: 1px solid #f4f1e8; outline-offset: -1px; }
@media (prefers-reduced-motion: reduce) { .view-tabs::before { transition: none; } }

/* ---- the message box stretches to fill the space down to the footer ---- */
.first-screen { min-height: 0; }
.intro { flex: 1 1 auto; min-height: 0; align-items: stretch; }
.hero { align-self: center; }
.composer-wrap { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.composer { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.composer-fields { display: flex; flex-direction: column; align-items: stretch; flex: 1 1 auto; min-height: 0; }
.composer .message-field { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.composer .message-field textarea { flex: 1 1 0; height: auto; min-height: 4.5rem; max-height: none; resize: none; }
.doom-stage { flex: 0 0 auto; }

/* ---- desktop message view ---- */
.status:empty { display: none; }                       /* no empty strip under Send */
@media (min-width: 900px) {
  /* one content column, always inside the stone pillars (58px each side + gutter) */
  .brand,
  .intro,
  .view-tabs,
  main {
    width: min(1120px, calc(100% - 180px));
    margin-left: auto;
    margin-right: auto;
  }
  .view-tabs { max-width: 420px; margin-left: calc((100% - min(1120px, calc(100% - 180px))) / 2); }
  .intro {
    grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
    gap: 32px 64px;
    align-items: center;                               /* both columns centred vertically */
    align-content: center;
  }
  .hero { max-width: 30rem; }
  .hero h2 { line-height: 1.15; }
  .lede { margin-top: 18px; font-size: 1rem; line-height: 1.6; }
  .composer-wrap { flex: 0 1 auto; }
  .composer .message-field textarea { min-height: 8rem; max-height: 18rem; }   /* sensible on big screens */
}
@media (min-width: 900px) {
  .intro { grid-template-columns: minmax(0, 1fr) minmax(420px, 1fr); }
  .hero { max-width: 34rem; }
  .hero h2 { font-size: clamp(1.9rem, 2.6vw, 2.5rem); text-wrap: balance; }
  /* the card sits in a grid row with no fixed height, so size the message box from
     the screen height directly: short laptops stay scroll-free, big screens get room */
  .composer .message-field textarea { flex: none; height: clamp(6rem, calc(100vh - 610px), 20rem); min-height: 6rem; max-height: none; }
}
@media (min-width: 900px) {
  /* the card's column fills the space between the tabs and the footer; the message
     box takes that column's height minus the rest of the card (~330px), capped */
  .intro { align-items: stretch; align-content: stretch; }
  .hero { align-self: center; }
  .composer-wrap { container-type: size; display: flex; flex-direction: column; justify-content: center; padding: 12px 0; }
  .composer { flex: 0 0 auto; }
  .composer .message-field textarea { height: clamp(5rem, calc(100cqh - 330px), 20rem); }
}

/* ===== Ad slots (public/ads.js) — placeholders now, real AdSense later ===== */
/* in-feed: a full-width labelled card between notes */
.ad-slot {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 14px;
  border: 1px solid #2c3a30;
  border-radius: 10px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #12201a, #0c140f);
}
.ad-label {
  font: 700 0.64rem/1 Rajdhani, sans-serif;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #6f7d73;
}
.ad-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  min-height: 48px;
}
.ad-brand { font: 800 1.15rem/1.1 Cinzel, serif; color: #e7efe9; }
.ad-line { flex: 1 1 180px; font: 500 0.95rem/1.35 Rajdhani, sans-serif; color: #aeb8b1; }
.ad-cta {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 6px;
  background: linear-gradient(180deg, #4dff86, #1f9e48);
  color: #03110a;
  font: 700 0.82rem/1 Rajdhani, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ad-unit { min-height: 90px; width: 100%; }

@media (max-width: 899px) {
  .ad-body { gap: 4px 10px; }
  .ad-brand { font-size: 1.02rem; }
}

/* iPhone Safari zooms into any text field under 16px and never zooms back out. */
@media (pointer: coarse) { input, textarea { font-size: 16px; } }
