:root {
  --ink: #090909;
  --paper: #ffffff;
  --muted: #6b6b6b;
  --soft: #f3f3f3;
  --line: #d9d9d9;
  --app-height: 100svh;
  --app-top: 0px;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea { font: inherit; }

button {
  cursor: pointer;
  touch-action: manipulation;
}

.shell {
  position: fixed;
  top: var(--app-top);
  left: 50%;
  width: min(100%, 640px);
  height: var(--app-height);
  padding: max(18px, env(safe-area-inset-top)) 22px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-50%);
}

.topbar {
  flex: 0 0 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.topbar p { margin: 0; }

.screen {
  display: none;
  flex: 1;
  min-height: 0;
}

.screen.active { display: flex; }

.intro {
  flex-direction: column;
  justify-content: center;
  padding: clamp(38px, 8vh, 88px) 0 26px;
  overflow-y: auto;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: -.06em;
}

h1 {
  max-width: 560px;
  font-size: clamp(64px, 18vw, 104px);
  line-height: .9;
}

.dek {
  width: min(100%, 450px);
  margin: clamp(30px, 6vh, 54px) 0 38px;
  font-size: 17px;
  line-height: 1.5;
}

#join-form label {
  display: block;
  margin-bottom: 9px;
  font-size: 12px;
  font-weight: 600;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.join-row input,
.composer input {
  min-width: 0;
  border: 1px solid var(--ink);
  outline: 0;
  background: var(--paper);
  color: var(--ink);
}

.join-row input {
  height: 52px;
  padding: 0 16px;
  border-radius: 12px;
}

input::placeholder { color: #9a9a9a; }

.join-row button,
.composer button,
.save {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.join-row button {
  min-width: 104px;
  height: 52px;
  padding: 0 20px;
  border-radius: 12px;
}

.form-error,
.chat-error {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 12px;
}

.chat-error:empty { display: none; }

.privacy {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.matching {
  flex-direction: column;
  justify-content: center;
}

.matching p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.matching h2 {
  max-width: 440px;
  font-size: clamp(48px, 12vw, 76px);
  line-height: .95;
}

.chat-screen {
  flex-direction: column;
  min-height: 0;
}

.chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 24px 0 16px;
}

.identity small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.identity strong {
  display: block;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.03em;
}

.clock {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -.03em;
}

.progress {
  flex: 0 0 auto;
  height: 1px;
  background: var(--line);
}

.progress i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink);
  transform-origin: left;
}

.messages {
  flex: 1;
  min-height: 0;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.bubble { max-width: 82%; }
.bubble.me { align-self: flex-end; }

.bubble p {
  margin: 0;
  padding: 13px 16px;
  border-radius: 14px;
  background: var(--soft);
  font-size: 15px;
  line-height: 1.45;
}

.bubble.me p {
  background: var(--ink);
  color: var(--paper);
}

.bubble span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
}

.bubble.me span { text-align: right; }

.typing p {
  display: flex;
  gap: 4px;
  padding: 18px;
}

.typing i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #777;
  animation: dot 1s infinite;
}

.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

@keyframes dot { 50% { transform: translateY(-3px); } }

.composer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 50px;
  gap: 8px;
}

.composer input {
  height: 50px;
  padding: 0 18px;
  border-color: var(--line);
  border-radius: 999px;
  font-size: 16px;
}

.composer input:focus { border-color: var(--ink); }

.composer button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 20px;
}

.ended {
  flex-direction: column;
  justify-content: center;
  padding: 28px 0;
  overflow-y: auto;
  text-align: left;
}

.ended h2 {
  font-size: clamp(54px, 14vw, 82px);
  line-height: .95;
}

.ended > p:nth-of-type(2) {
  margin: 20px 0 0;
  font-size: 17px;
}

.decision {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 34px;
}

.decision button {
  position: relative;
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  transition: background .15s, color .15s;
}

.decision button:hover,
.decision button.selected {
  background: var(--ink);
  color: var(--paper);
}

.decision.voted button { cursor: default; }
.decision.voted button:not(.selected) { opacity: .35; }

.decision span {
  position: absolute;
  top: 16px;
  right: 16px;
  color: inherit;
  font-size: 10px;
  opacity: .55;
}

.decision strong {
  display: block;
  margin-top: 43px;
  font-size: 27px;
  letter-spacing: -.04em;
}

.chosen {
  min-height: 18px;
  margin-top: 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.vote-results {
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--ink);
  text-align: left;
}

.results-head,
.result-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results-head { margin-bottom: 18px; }
.results-head strong { font-size: 17px; }
.results-head span,
.look-up {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.result + .result { margin-top: 14px; }
.result-label { margin-bottom: 7px; }
.result-label span { font-size: 12px; font-weight: 600; }
.result-label strong { font-size: 12px; }

.vote-track {
  height: 7px;
  overflow: hidden;
  background: var(--soft);
}

.vote-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ink);
  transition: width .55s ease;
}

.look-up { margin-top: 16px !important; }

.admin {
  width: min(100%, 960px);
  height: 100%;
  margin: auto;
  padding: 64px 28px 90px;
  overflow-y: auto;
}

.admin header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 40px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--ink);
}

.admin h1 {
  font-size: clamp(48px, 8vw, 82px);
  line-height: .9;
}

.admin header > p {
  max-width: 340px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

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

.panel h2 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.field label { font-size: 12px; font-weight: 600; }

.field input,
.field textarea,
.person input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: var(--paper);
  padding: 13px 14px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus,
.person input:focus { border-color: var(--ink); }

.people {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.person {
  display: grid;
  grid-template-columns: 1fr 3fr auto;
  gap: 8px;
}

.person button,
.add {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  padding: 0 14px;
}

.add {
  min-height: 44px;
  margin-top: 12px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 30px;
}

.save {
  min-height: 48px;
  padding: 0 22px;
  border-radius: 10px;
}

#status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.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;
}

.keyboard-open .shell {
  padding-top: 6px;
  padding-bottom: 6px;
}

.keyboard-open .topbar { display: none; }
.keyboard-open .chat-head { padding: 8px 0 10px; }
.keyboard-open .messages { padding: 10px 0; gap: 12px; }

@media (max-width: 520px) {
  .shell { padding-inline: 18px; }
  .topbar { flex-basis: 48px; }
  .intro { justify-content: center; }
  .join-row { grid-template-columns: 1fr; }
  .join-row button { width: 100%; }
  .decision button { min-height: 106px; }
  .admin { padding: 42px 20px 70px; }
  .admin header { display: block; }
  .admin header > p { margin-top: 22px; }
  .person { grid-template-columns: 1fr auto; }
  .person input:nth-child(2) { grid-row: 2; grid-column: 1 / 3; }
}

@media (max-height: 700px) {
  .intro,
  .ended { justify-content: flex-start; }
  .intro h1 { font-size: 62px; }
  .dek { margin: 26px 0 24px; }
  .ended h2 { font-size: 54px; }
  .decision { margin-top: 22px; }
}

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