@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/geist-latin-variable.woff2") format("woff2");
}

@font-face {
  font-family: "Lora";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/lora-latin-variable.woff2") format("woff2");
}

:root {
  color-scheme: light dark;
  --background: #f4efe6;
  --card: #fbf9f3;
  --foreground: #2d2e29;
  --focus-ring: var(--foreground);
  --card-foreground: #292a23;
  --muted: #e9e3d9;
  --muted-foreground: #64675f;
  --secondary: #e8e0d4;
  --accent: #c7b27f;
  --accent-foreground: #2d3025;
  --border: rgba(54, 59, 48, 0.14);
  --control-border: #8a8b82;
  --primary: #506a59;
  --primary-foreground: #ffffff;
  --primary-hover: #35483d;
  --good-bg: #dfe6de;
  --good-fg: #47604c;
  --warn-bg: #e9dfc9;
  --warn-fg: #705d35;
  --bad-bg: #eadbd6;
  --bad-fg: #7d5049;
  --tint: #faf7f0;
}

body[data-accent="lime"] {
  --primary: #c7b27f;
  --primary-foreground: #2d3025;
  --primary-hover: #b09b68;
}

body[data-accent="clay"] {
  --primary: #9d7462;
  --primary-foreground: #fff;
  --primary-hover: #8a6455;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --background: #171814;
    --card: #1f211b;
    --foreground: #e6e4d9;
    --focus-ring: var(--foreground);
    --card-foreground: #e6e4d9;
    --muted: #2b2d25;
    --muted-foreground: #a4a698;
    --secondary: #2b2d25;
    --accent: #b6a474;
    --accent-foreground: #171812;
    --border: rgba(230, 228, 213, 0.13);
    --control-border: #565a4e;
    --primary: #9dbcaa;
    --primary-foreground: #121713;
    --primary-hover: #bcd6c5;
    --good-bg: #2e3a2f;
    --good-fg: #a9c6b2;
    --warn-bg: #3b3422;
    --warn-fg: #d3ba7e;
    --bad-bg: #3a2a25;
    --bad-fg: #dc9c91;
    --tint: #23251f;
  }

  :root:not([data-theme]) body[data-accent="lime"] {
    --primary: #b6a474;
    --primary-foreground: #171812;
    --primary-hover: #c9b98b;
  }

  :root:not([data-theme]) body[data-accent="clay"] {
    --primary: #b08572;
    --primary-foreground: #171814;
    --primary-hover: #c29a88;
  }
}

/* Manual override set by the toggle. The inline <head> script resolves the
   initial value from localStorage or the system preference (no flash). An
   explicit choice wins over prefers-color-scheme via the :not([data-theme])
   scoping above. Light needs only color-scheme; the :root vars are light. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #171814;
  --card: #1f211b;
  --foreground: #e6e4d9;
  --focus-ring: var(--foreground);
  --card-foreground: #e6e4d9;
  --muted: #2b2d25;
  --muted-foreground: #a4a698;
  --secondary: #2b2d25;
  --accent: #b6a474;
  --accent-foreground: #171812;
  --border: rgba(230, 228, 213, 0.13);
  --control-border: #565a4e;
  --primary: #9dbcaa;
  --primary-foreground: #121713;
  --primary-hover: #bcd6c5;
  --good-bg: #2e3a2f;
  --good-fg: #a9c6b2;
  --warn-bg: #3b3422;
  --warn-fg: #d3ba7e;
  --bad-bg: #3a2a25;
  --bad-fg: #dc9c91;
  --tint: #23251f;
}

:root[data-theme="dark"] body[data-accent="lime"] {
  --primary: #b6a474;
  --primary-foreground: #171812;
  --primary-hover: #c9b98b;
}

:root[data-theme="dark"] body[data-accent="clay"] {
  --primary: #b08572;
  --primary-foreground: #171814;
  --primary-hover: #c29a88;
}

.theme-toggle {
  display: none; /* revealed only when JS has set a theme (below) */
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 20;
  align-items: center;
  justify-content: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

:root[data-theme] .theme-toggle {
  display: inline-flex;
}

.theme-toggle:hover {
  background: var(--muted);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-toggle svg {
  inline-size: 1.15rem;
  block-size: 1.15rem;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 20rem;
  background: var(--background);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Geist", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1 {
  color: var(--foreground);
  font-family: "Lora", Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
  line-height: 1.08;
}

h2,
h3 {
  color: var(--card-foreground);
  line-height: 1.2;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

a {
  color: inherit;
}

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

button {
  appearance: none;
}

.eyebrow,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
}

.eyebrow {
  color: var(--muted-foreground);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

main.public {
  display: grid;
  max-width: 40rem;
  margin: 0 auto;
  padding: 4rem max(1.25rem, env(safe-area-inset-right)) calc(3rem + env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  gap: 1.5rem;
}

main.desk {
  display: grid;
  max-width: 72rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem;
  gap: 1.25rem;
}

.brand-mark {
  /* 3D ASCII monogram (ascii-logo.js) on a squircle backdrop echoing the app icon */
  display: grid;
  place-content: center; /* center the ASCII within the square box */
  box-sizing: border-box;
  width: max-content;
  aspect-ratio: 1 / 1; /* keep the surrounding box symmetrical (square squircle) */
  margin: 0;
  padding: 1rem;
  background: #45524a; /* the logo's dark-green squircle, theme-independent */
  color: #eeece0; /* the logo's cream mark */
  border-radius: 22%;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(4.5px, 1.4vw, 7.5px);
  line-height: 1;
  letter-spacing: 0;
  white-space: pre;
  overflow: hidden;
  font-variant-ligatures: none;
  -webkit-font-smoothing: none;
  user-select: none;
}

.brand-mark:empty {
  display: none; /* no-JS: hide the empty card, the <noscript> img stands in */
}

.brand-mark-fallback {
  display: block;
  width: 6rem;
  height: 6rem;
  border-radius: 22%;
}

.site-header {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 0.75rem;
}

.site-header > p:not(.eyebrow) {
  max-width: 38rem;
  text-wrap: pretty;
  color: var(--muted-foreground);
  font-size: 1.05rem;
}

.desk-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
}

.desk-header > div {
  display: grid;
  gap: 0.4rem;
}

.card {
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: none;
}

.card > :first-child {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

.card > h2 + form,
.card > h2 + .table-wrap,
.card > h2 + p,
.card > p + form {
  margin-top: 1.25rem;
}

.referral-panel > .referral-link,
.referral-panel > .referral-count,
.settings-card > .settings-form,
.signups-card > #signup-table,
.signups-card > .actions {
  margin-top: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--border);
}

.stat {
  min-width: 0;
  padding: 1rem 1.25rem;
  text-align: center;
  background: var(--tint);
}

.stat-value {
  color: var(--foreground);
  font-size: 1.9rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.1;
}

.stat .mono {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted-foreground);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Soft flame glow wrapping the stats box (behind it; the box itself clips its
   own overflow, so the flame lives on this wrapper). */
@property --flame-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.flame-wrap {
  position: relative;
  isolation: isolate;
  border-radius: 0.85rem;
}

.flame-wrap::before {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: inherit;
  background: conic-gradient(
    from var(--flame-angle),
    #6fc78f,
    #a8e6c0,
    #e0f8ea,
    #8fd9ac,
    #6fc78f,
    #c2f0d4,
    #6fc78f
  );
  filter: blur(10px);
  opacity: 0.72;
  animation:
    flame-spin 5s linear infinite,
    flame-flicker 2.6s ease-in-out infinite;
}

@keyframes flame-spin {
  to {
    --flame-angle: 360deg;
  }
}

@keyframes flame-flicker {
  0%,
  100% {
    opacity: 0.58;
    transform: scale(1);
  }
  30% {
    opacity: 0.85;
    transform: scale(1.015);
  }
  55% {
    opacity: 0.68;
    transform: scale(0.995);
  }
  80% {
    opacity: 0.92;
    transform: scale(1.02);
  }
}

@media (prefers-reduced-motion: reduce) {
  .flame-wrap::before {
    animation: none;
    opacity: 0.55;
  }
}

.notice {
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  background: var(--good-bg);
  color: var(--good-fg);
  font-size: 0.875rem;
  text-align: center;
}

.notice-error {
  background: var(--bad-bg);
  color: var(--bad-fg);
}

.notice:empty {
  display: none;
}

form {
  margin: 0;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field + .field,
.field + .actions,
.settings-grid + .actions,
.radio-pills + .actions {
  margin-top: 1rem;
}

.form-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.form-stack > .field + .field,
.settings-grid > .field + .field {
  margin-top: 0;
}

.field label,
.field > span {
  color: var(--card-foreground);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}

input:where(:not([type="radio"], [type="checkbox"])),
select,
textarea {
  width: 100%;
  min-height: 2.625rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--control-border);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--foreground);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}

input[readonly] {
  background: var(--tint);
}

input:disabled,
select:disabled,
textarea:disabled {
  border-color: var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  cursor: not-allowed;
  opacity: 1;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.muted-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.field-extra {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.referral-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.referral-link input {
  min-width: 0;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.625rem;
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: var(--secondary);
  color: var(--foreground);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

.btn:hover {
  background: var(--muted);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.join-form.htmx-request .btn-primary {
  opacity: 0.65;
  pointer-events: none;
}

.btn-ghost {
  border-color: var(--control-border);
  background: transparent;
  color: var(--foreground);
}

.btn-ghost:hover {
  background: var(--muted);
}

.btn-danger {
  border-color: var(--bad-fg);
  background: transparent;
  color: var(--bad-fg);
}

.btn-danger:hover {
  background: var(--bad-bg);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  border-color: var(--border);
  background: var(--muted);
  color: var(--muted-foreground);
  cursor: not-allowed;
  opacity: 1;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.settings-grid > .field:has(textarea),
.settings-grid > .retention-field,
.settings-grid > .radio-pills {
  grid-column: 1 / -1;
}

.radio-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  border: 0;
}

.radio-pills legend {
  width: 100%;
  margin-bottom: 0.25rem;
  color: var(--card-foreground);
  font-size: 0.875rem;
  font-weight: 600;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--control-border);
  border-radius: 9999px;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  font-size: 0.875rem;
}

.radio-pill:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.radio-pill:has(input:checked) input {
  accent-color: var(--primary-foreground);
}

.radio-pill input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary);
}

.radio-pill:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  padding-block: 3px;
}

.table {
  width: 100%;
  min-width: 62rem;
  border-collapse: collapse;
  border-spacing: 0;
}

.table th {
  padding: 0.5rem 0.625rem;
  color: var(--muted-foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 0.625rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: middle;
}

.table td:first-child,
.table td .mono {
  font-variant-numeric: tabular-nums;
}

.table td:first-child,
.table td:nth-child(2) {
  white-space: nowrap;
}

.compact-input,
.compact-select {
  min-height: 2.25rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
}

.compact-input {
  min-width: 8rem;
}

.compact-select {
  min-width: 6.5rem;
}

.table td:nth-child(8) .chip {
  display: flex;
  width: fit-content;
  margin-bottom: 0.375rem;
}

.table td:nth-child(8) .compact-select {
  display: block;
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.row-actions .btn {
  min-height: 2.25rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.chip-waiting {
  background: var(--muted);
  color: var(--muted-foreground);
}

.chip-invited {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.chip-joined {
  background: var(--good-bg);
  color: var(--good-fg);
}

.privacy {
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  line-height: 1.55;
  text-align: center;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

.muted-link {
  color: var(--muted-foreground);
  text-decoration-color: var(--border);
  text-underline-offset: 0.2em;
}

.muted-link:hover {
  color: var(--foreground);
  text-decoration-color: currentColor;
}

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 10; /* only z-index on the public page: glint overlay above content, pointer-transparent */
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fx-source {
  display: none;
}

@media (max-width: 44rem) {
  main.public {
    padding-top: 2.5rem;
  }

  main.desk {
    padding-top: 1.5rem;
  }

  .desk-header {
    align-items: stretch;
    flex-direction: column;
  }

  .card {
    padding: 1.25rem;
  }

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

  .settings-grid > .field,
  .settings-grid > .radio-pills {
    grid-column: 1;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 479.98px) {

  .stat {
    padding: 0.75rem 0.875rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .stat .mono {
    margin-top: 0.2rem;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
  }

  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
  }

  .referral-link {
    grid-template-columns: 1fr;
  }

  .referral-link .btn {
    width: 100%;
  }

  .radio-pills {
    align-items: stretch;
    flex-direction: column;
  }

  .radio-pill {
    width: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
  }
  main.public > * { animation: rise-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
  #live-stats { animation: none; } /* htmx re-polls it every 30s; re-animating each swap is noise */
  #notice { animation-delay: 90ms; }
  #join-panel { animation-delay: 150ms; }
  main.public > .privacy { animation-delay: 220ms; }
  main.public > .footer { animation-delay: 280ms; }
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}
