:root {
  --spring: cubic-bezier(.34, 1.28, .5, 1);
  --soft: cubic-bezier(.22, 1, .36, 1);
  --bg: #000;
  --ink: #ededed;
  --dim: #8a8a8a;
  --faint: #3a3a3a;
  --line: #1c1c1c;
  --card: #0b0b0b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  overscroll-behavior: none;
}

#app { height: 100dvh; position: relative; overflow: hidden; }

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(14px) scale(.995);
  pointer-events: none;
  transition: opacity .38s var(--soft), transform .45s var(--spring);
}
.view.active { opacity: 1; transform: none; pointer-events: auto; }

.brand {
  font-weight: 200;
  font-size: 44px;
  letter-spacing: .02em;
  margin: 0;
}
.brand-sm { font-weight: 300; letter-spacing: .03em; }
.tagline { color: var(--dim); margin: 4px 0 28px; font-size: 14px; font-weight: 300; }

.auth-inner {
  margin: auto;
  width: min(400px, 88vw);
  display: flex;
  flex-direction: column;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  position: relative;
}
.auth-tab {
  flex: 1;
  background: none;
  border: 0;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  padding: 9px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color .25s;
  position: relative;
  z-index: 1;
}
.auth-tab.active { color: var(--ink); }
#tab-pill {
  position: absolute;
  top: 4px; bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: #1a1a1a;
  border-radius: 999px;
  transition: transform .45s var(--spring);
}

.auth-form { display: flex; flex-direction: column; gap: 10px; }

.field {
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 13px 16px;
  outline: none;
  transition: border-color .25s, background .25s;
  -webkit-appearance: none;
  appearance: none;
}
.field:focus { border-color: #3f3f3f; background: #0d0d0d; }
.field::placeholder { color: #4a4a4a; }

.btn {
  background: var(--ink);
  color: #000;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 13px 26px;
  cursor: pointer;
  transition: transform .35s var(--spring), opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; }
.btn-sm { padding: 8px 18px; font-size: 13px; }

.ghost {
  background: none;
  border: 0;
  color: var(--dim);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  transition: color .2s;
}
.ghost:hover { color: var(--ink); }

.err { color: #b05c5c; font-size: 13px; min-height: 16px; font-weight: 300; }

#coop-wrap {
  transition: opacity .4s var(--soft), transform .45s var(--spring);
}
#coop-wrap.hidden { opacity: 0; transform: translateY(6px); height: 0; overflow: hidden; pointer-events: none; }
.coop-label { color: var(--dim); font-size: 12px; margin: 2px 0 8px; font-weight: 300; }
#coop-map {
  width: 100%;
  aspect-ratio: 2 / 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #050505;
  cursor: crosshair;
  touch-action: manipulation;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.who { color: var(--dim); font-size: 13px; font-weight: 300; }
.title { font-weight: 300; font-size: 15px; color: var(--dim); }

.mail-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px);
}

.mail-section {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin: 22px 4px 8px;
  font-weight: 400;
}

.mrow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 6px;
  border-bottom: 1px solid #111;
  cursor: pointer;
  animation: rise .5s var(--spring) both;
}
.mrow:active { opacity: .7; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.mrow .glyph { width: 34px; height: 34px; flex: none; }
.mrow .body { flex: 1; min-width: 0; }
.mrow .line1 { font-size: 15px; font-weight: 400; display: flex; align-items: center; gap: 8px; }
.mrow .line2 { font-size: 12px; color: var(--dim); font-weight: 300; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); flex: none; }

.prog-rail {
  height: 2px;
  background: #161616;
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, #3d3d3d, #cfcfcf);
  border-radius: 2px;
  transition: width 1s linear;
}

.empty {
  color: var(--faint);
  text-align: center;
  font-weight: 300;
  font-size: 14px;
  margin-top: 40vh;
}

.sheet {
  flex: 1;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.letter-field {
  resize: none;
  flex: 0 0 auto;
  min-height: 160px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}
.to-info { color: var(--dim); font-size: 12px; min-height: 16px; font-weight: 300; }

.flight-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#flight-map { flex: 1; min-height: 0; width: 100%; }
.flight-stats {
  padding: 14px 20px calc(env(safe-area-inset-bottom) + 16px);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  font-weight: 300;
}
.flight-stats .k { color: var(--faint); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.flight-stats .v { font-size: 15px; margin-top: 4px; }

.letter-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.letter-card {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 26px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  animation: rise .55s var(--spring) both;
}
.letter-meta {
  color: var(--faint);
  font-size: 12px;
  font-weight: 300;
  margin-top: 14px;
  text-align: center;
}

.hidden { display: none; }
