:root {
  --cream: #f4efe6;
  --cream-2: #ebe4d8;
  --paper: #fffcf7;
  --ink: #17241f;
  --muted: #66736d;
  --line: rgba(23, 36, 31, 0.08);
  --forest: #1b3c32;
  --sage: #d7ead6;
  --sage-2: #eef6ee;
  --ok: #1f6b45;
  --bad: #b42318;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --sans: "Outfit", "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  background:
    radial-gradient(900px 480px at 90% -10%, #dcecdc 0%, transparent 55%),
    radial-gradient(700px 400px at -10% 110%, #ead9c8 0%, transparent 50%),
    var(--cream);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px 8px;
  max-width: 1080px;
  margin: 0 auto;
  background: transparent;
  color: var(--ink);
}
.brand {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.topbar-meta, .topbar a {
  font-size: 0.92rem;
  color: var(--muted);
  text-decoration: none;
}
.topbar a:hover { color: var(--ink); }
.wrap {
  width: min(760px, calc(100% - 40px));
  margin: 28px auto 80px;
}
.wrap.wide { width: min(1120px, calc(100% - 40px)); }
h1, h2, h3 {
  margin: 0 0 10px;
  letter-spacing: -0.03em;
  font-weight: 560;
}
h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.08;
  font-weight: 500;
}
.invite-email {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.email-blur {
  display: inline-block;
  filter: blur(5px);
  user-select: none;
  letter-spacing: 0.06em;
}
h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  margin-bottom: 18px;
  border: 0;
  text-transform: none;
  letter-spacing: -0.03em;
  color: var(--ink);
  padding: 0;
}
.lede, .muted, #invite-meta, .hint { color: var(--muted); }
.lede { font-size: 1.12rem; max-width: 34rem; }
.hint, .kicker {
  margin: 0 0 12px;
  color: var(--forest);
  font-size: 0.92rem;
  font-weight: 500;
}
a { color: var(--forest); }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  margin-top: 22px;
  box-shadow: 0 20px 50px rgba(23, 36, 31, 0.05);
}
#drop {
  border: 1.5px dashed #b7cbb8;
  border-radius: 24px;
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--sage-2);
}
#drop strong { font-size: 1.15rem; }
#drop.hover, #drop:focus, body[data-status="uploading"] #drop {
  border-color: var(--forest);
  background: #f4faf4;
  outline: none;
}
body[data-status="uploading"] #drop { border-style: solid; cursor: default; }
body[data-status="uploading"] #message { font-weight: 600; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
button, .button {
  appearance: none;
  border: 0;
  background: var(--forest);
  color: #f7f4ee;
  border-radius: 999px;
  padding: 12px 18px;
  font: 560 15px/1.1 var(--sans);
  cursor: pointer;
}
button.secondary {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px rgba(23, 36, 31, 0.16);
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
input, select {
  font: 15px/1.4 var(--sans);
  height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid rgba(23, 36, 31, 0.12);
  background: #fff;
  color: var(--ink);
}
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2366736d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 4px rgba(27, 60, 50, 0.12);
}
label {
  display: grid;
  gap: 8px;
  font: 500 13px/1.3 var(--sans);
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}
.duration-fields { display: flex; gap: 8px; align-items: stretch; }
.duration-fields input { min-width: 0; flex: 1; }
.duration-fields select { width: 7.5rem; flex: 0 0 7.5rem; }
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .invite-email { grid-column: 1 / -1; }
}
#invite-form button[type="submit"] {
  justify-self: start;
  align-self: end;
  width: auto;
}
#message { margin: 18px 0 0; }
#message[data-kind="ok"] { color: var(--ok); }
#message[data-kind="error"] { color: var(--bad); }
table { width: 100%; border-collapse: collapse; table-layout: auto; font-size: 0.95rem; }
th, td {
  text-align: left;
  padding: 12px 12px 12px 0;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
th.num, td.num, th.when, td.when, th.actions, td.actions {
  white-space: nowrap;
  width: 1%;
}
td.file { overflow-wrap: break-word; word-break: normal; }
.table-scroll { overflow-x: auto; }
table.invites { min-width: 36rem; }
table.invites td.file { white-space: nowrap; }
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line);
}
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--sage);
  color: var(--forest);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  border: 0;
}
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 18px 0 8px; }
.metric {
  background: var(--paper);
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: 0 12px 30px rgba(23, 36, 31, 0.04);
}
.metric strong { display: block; font-family: var(--serif); font-size: 1.6rem; font-weight: 500; }
.metric.due strong { color: var(--ok); }
.hidden { display: none !important; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: var(--sage-2);
  padding: 0.1em 0.4em;
  border-radius: 8px;
}
body[data-status="idle"] #controls,
body[data-status="completed"] #controls { display: none; }
body[data-status="ready"]:not(.has-stage) #controls { display: none; }
body[data-status="ready"] #pause,
body[data-status="ready"] #resume,
body[data-status="ready"] #retry,
body[data-status="ready"] #cancel { display: none; }
body:not([data-status="ready"]) #start { display: none; }
.file-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.file-remove {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  padding: 6px 8px;
  font-size: 0.85rem;
  font-weight: 500;
}
#stage-panel,
.uploaded-card {
  margin-top: 22px;
  padding-top: 6px;
}
.uploaded-card {
  padding-top: 22px;
}
.file-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.file-panel-head h2 { margin: 0; }
.file-panel-head .muted { margin: 0; }
.uploaded-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.uploaded-list li {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.uploaded-list li:first-child { padding-top: 8px; }
.uploaded-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.file-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.uploaded-list strong {
  display: block;
  word-break: break-word;
}
.uploaded-list .muted {
  margin: 4px 0 0;
  font-size: 0.9rem;
}
.file-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--sage);
}
.file-bar-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--forest);
  border-radius: 999px;
  transition: transform 0.16s linear;
}
.uploaded-list li[data-status="complete"] .file-bar-fill { transform: scaleX(1); }
.uploaded-list li.empty {
  display: block;
  color: var(--muted);
  border: 0;
  padding: 10px 0 0;
}
.pill.waiting { background: var(--cream-2); color: var(--muted); }
.pill.sending { background: #d9e8d4; color: var(--forest); }
.pill.failed { background: #f8e0dc; color: var(--bad); }
.upload-user { margin-top: 28px; }
.upload-user:first-child { margin-top: 0; }
.upload-user-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.upload-user-head h3 {
  font-family: var(--serif);
  font-size: 1.45rem;
  margin: 0;
}
.upload-user-head .muted { margin: 0; }
.upload-session { margin: 0; padding: 0; }
.upload-session + .upload-session {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.upload-session-meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}
table.uploads { table-layout: auto; }
table.uploads th.actions,
table.uploads td.actions {
  width: 1%;
  text-align: right;
  padding-right: 0;
  vertical-align: middle;
}
table.uploads td.actions .row {
  flex-wrap: nowrap;
  justify-content: flex-end;
  white-space: nowrap;
}
.hero { max-width: 40rem; }
.gate { margin-top: 8px; }
#controls { margin-top: 18px; }
.device-login { text-align: center; }
.device-confirm {
  position: relative;
  min-height: 7.5rem;
  margin: 8px 0 18px;
  overflow: visible;
}
#device-pending { transition: opacity 0.32s ease; }
#device-pending.faded { opacity: 0; pointer-events: none; }
.device-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
@keyframes login-check-stroke {
  100% { stroke-dashoffset: 0; }
}
@keyframes login-check-scale {
  0%, 100% { transform: none; }
  50% { transform: scale3d(1.1, 1.1, 1); }
}
.login-check {
  width: 72px;
  height: 72px;
  padding: 8px;
  box-sizing: content-box;
  display: block;
  overflow: visible;
  stroke-width: 3.5;
  stroke: #7ac142;
  stroke-miterlimit: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: login-check-scale 0.3s ease-in-out 0.8s both;
}
.login-check-circle {
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  stroke-width: 3.5;
  stroke: #7ac142;
  fill: none;
  animation: login-check-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.login-check-mark {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: #7ac142;
  fill: none;
  animation: login-check-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.55s forwards;
}
@media (prefers-reduced-motion: reduce) {
  .login-check, .login-check-circle, .login-check-mark { animation: none; }
}
.match-number {
  margin: 8px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(3.4rem, 12vw, 5rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1;
  min-height: 1.1em;
}
.match-number.waiting::after {
  content: "···";
  color: var(--muted);
  animation: match-wait 1s ease-in-out infinite;
}
@keyframes match-wait {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
#device-countdown { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
#otp-code {
  letter-spacing: 0.35em;
  font-size: 1.4rem;
  text-align: center;
}
.otp-field { display: grid; gap: 10px; }
.otp-label {
  font: 500 13px/1.3 var(--sans);
  color: var(--muted);
}
.otp-slots {
  display: flex;
  justify-content: flex-start;
  gap: 6px;
}
.otp-slot {
  width: 3rem;
  height: 3.4rem;
  padding: 0;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.45rem;
  font-weight: 600;
  border-radius: 16px;
  caret-color: var(--forest);
}
.otp-slot:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 4px rgba(27, 60, 50, 0.12);
}
@media (max-width: 420px) {
  .otp-slot {
    width: 2.55rem;
    height: 3rem;
    font-size: 1.25rem;
  }
}
button.linkish {
  background: none;
  color: var(--muted);
  box-shadow: none;
  padding: 0;
  font-size: 0.92rem;
  font-weight: 500;
}
button.linkish:hover { color: var(--ink); }
#login-error { color: var(--bad); min-height: 1.2em; }
