:root {
  color-scheme: light;
  --ink: #16181d;
  --muted: #6b7280;
  --paper: #ffffff;
  --panel: #fafafa;
  --line: #e3e5e9;
  --blue: #3558e8;
  --blue-dark: #2743bd;
  --blue-soft: #eef1fd;
  --green: #1f9d63;
  --green-text: #146c46;
  --red: #c8394f;
  --radius: 8px;
  --radius-sm: 5px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
textarea,
select {
  font: inherit;
}

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

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

button {
  color: inherit;
}

.page-shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
}

.site-header nav {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 550;
}

.site-header nav a {
  color: var(--muted);
  text-underline-offset: 4px;
  text-decoration-color: transparent;
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

.site-header nav a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: clamp(36px, 6vw, 72px);
  align-items: start;
  padding: 56px 0 64px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: flex;
  align-items: center;
  margin: 0 0 14px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero h1 {
  max-width: 560px;
  margin-bottom: 18px;
  font-size: clamp(2.1rem, 4vw, 2.9rem);
  line-height: 1.15;
}

.hero h1 em {
  color: var(--blue);
  font-style: normal;
}

.hero-lede {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.stack span {
  padding: 5px 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 600;
}

.stats-card {
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stats-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.stats-header .eyebrow {
  margin-bottom: 6px;
}

.stats-header h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.pulse-badge {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 4px 8px;
  color: var(--green-text);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.pulse-badge span {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0;
}

.stats-grid > div {
  padding: 18px 10px 18px 0;
  border-bottom: 1px solid var(--line);
}

.stats-grid > div:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.stats-grid > div:nth-child(even) {
  padding-left: 18px;
}

.stats-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.stats-grid dd {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.stats-grid small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 400;
  font-family: Inter, ui-sans-serif, sans-serif;
}

.runtime-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  color: var(--muted);
  font-size: 0.74rem;
}

.runtime-line strong {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.stats-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.5;
}

.stats-note code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.guestbook-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  overflow: hidden;
  margin: 56px 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.composer-panel,
.stream-panel {
  padding: clamp(24px, 3vw, 40px);
}

.composer-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  color: var(--ink);
}

.section-heading h2,
.stream-heading h2 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 2vw, 1.6rem);
}

.section-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.composer {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .grow {
  flex: 1;
}

.mood-field {
  width: 140px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span:first-child {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input,
.field select {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 120px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #9ca3af;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.field [aria-invalid="true"] {
  border-color: var(--red);
}

.field-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.field-meta small,
.field-error {
  font-size: 0.66rem;
}

.field-error {
  color: var(--red);
}

.honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.primary-button {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  color: white;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.primary-button:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.submit-status {
  font-size: 0.7rem;
  font-weight: 600;
}

.how-it-works {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.7rem;
  line-height: 1.55;
}

.how-it-works p {
  margin: 0;
}

.stream-panel {
  min-width: 0;
}

.stream-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stream-heading .eyebrow {
  margin-bottom: 6px;
}

.stream-heading h2 {
  margin-bottom: 0;
}

.small-spinner {
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 650;
}

.filters {
  display: flex;
  gap: 10px;
  margin: 24px 0 8px;
}

.filters label {
  display: block;
}

.search-field {
  position: relative;
  flex: 1;
}

.search-field > span[aria-hidden="true"] {
  position: absolute;
  top: 50%;
  left: 13px;
  color: var(--muted);
  font-size: 1.1rem;
  transform: translateY(-54%);
}

.filters input,
.filters select {
  height: 42px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
}

.filters input {
  width: 100%;
  padding: 0 12px 0 38px;
}

.filters select {
  padding: 0 30px 0 12px;
}

.filters input:focus,
.filters select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.message-list {
  display: grid;
}

.note {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.note:last-child {
  border-bottom: 0;
}

.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
}

.note-content {
  min-width: 0;
}

.note-content header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.note-content header > div {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.note-content strong {
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mood-label {
  padding: 2px 7px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.6rem;
  font-weight: 600;
}

.note time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6rem;
}

.note-content > p {
  margin: 8px 0 12px;
  color: #3d4451;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.cheer-form {
  display: inline-block;
}

.cheer-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 9px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.64rem;
  font-weight: 650;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.cheer-button:hover {
  color: var(--red);
  border-color: var(--red);
}

.cheer-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.cheer-copy {
  color: var(--muted);
  font-weight: 600;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 14px;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.empty-state h3 {
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 1rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.8rem;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 24px 0 40px;
  color: var(--muted);
  font-size: 0.7rem;
  border-top: 1px solid var(--line);
}

footer p {
  margin: 0;
}

footer a {
  color: var(--muted);
  text-underline-offset: 3px;
}

.not-found {
  display: grid;
  min-height: calc(100vh - 190px);
  place-items: center;
  align-content: center;
  text-align: center;
}

.not-found h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3rem);
}

.not-found > p:not(.eyebrow) {
  margin: 0 0 24px;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.htmx-indicator {
  visibility: hidden;
  opacity: 0;
  transition: opacity 150ms ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  visibility: visible;
  opacity: 1;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (max-width: 940px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 44px 0 48px;
  }

  .stats-card {
    width: min(100%, 520px);
  }

  .guestbook-grid {
    grid-template-columns: 1fr;
  }

  .composer-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 24px, 1080px);
  }

  .site-header {
    min-height: 68px;
  }

  .site-header nav {
    display: none;
  }

  .stats-card {
    padding: 20px;
  }

  .guestbook-grid {
    margin: 40px -4px;
    border-radius: 6px;
  }

  .composer-panel,
  .stream-panel {
    padding: 26px 20px;
  }

  .field-row,
  .filters {
    flex-direction: column;
  }

  .mood-field,
  .filters select {
    width: 100%;
  }

  .note {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
  }

  .avatar {
    width: 34px;
    height: 34px;
  }

  .mood-label,
  .cheer-copy {
    display: none;
  }

  footer {
    display: grid;
    gap: 8px;
  }
}

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