:root {
  --background: #ffffff;
  --text: #000000;
  --secondary: #8e8e93;
  --fill: #e9e9eb;
  --bar: rgba(249, 249, 249, 0.92);
  --separator: rgba(60, 60, 67, 0.29);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --grouped: #f2f2f7;
  --cell: #ffffff;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #000000;
    --text: #ffffff;
    --secondary: #8e8e93;
    --fill: #262629;
    --bar: rgba(28, 28, 30, 0.92);
    --separator: rgba(84, 84, 88, 0.6);
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --grouped: #000000;
    --cell: #1c1c1e;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

/* Home */

body.home { background: var(--grouped); }

.home main {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18vh) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px);
}

.field { display: flex; gap: 8px; }

.field input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--cell);
  color: var(--text);
  font: inherit;
  text-transform: uppercase;
  outline: none;
}

.field input::placeholder { text-transform: none; color: var(--secondary); }

.field input:focus-visible { box-shadow: 0 0 0 2px var(--blue); }

.field button {
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 600;
}

.error { margin: 8px 4px 0; color: var(--red); font-size: 15px; }

.recent {
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
  border-radius: 12px;
  background: var(--cell);
  overflow: hidden;
}

.recent a {
  display: flex;
  justify-content: space-between;
  margin-left: 16px;
  padding: 12px 16px 12px 0;
  color: var(--text);
  text-decoration: none;
}

.recent li + li a { border-top: 0.5px solid var(--separator); }

.recent li:has(a:active) { background: var(--fill); }

.recent time { color: var(--secondary); }

/* Flight */

header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: env(safe-area-inset-top) calc(env(safe-area-inset-right) + 8px) 0 calc(env(safe-area-inset-left) + 8px);
  min-height: calc(env(safe-area-inset-top) + 56px);
  background: var(--bar);
  border-bottom: 0.5px solid var(--separator);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.back, .bell {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
}

.back svg { width: 12px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.bell svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }

.bell[aria-pressed="true"] svg { fill: currentColor; }

.bell[hidden] { display: none; }

.title {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  min-width: 0;
}

h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill.following::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

#thread {
  display: flex;
  flex-direction: column;
  padding: 8px calc(env(safe-area-inset-right) + 12px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 12px);
}

.divider {
  align-self: center;
  margin: 16px 0 8px;
  color: var(--secondary);
  font-size: 12px;
}

.divider b { font-weight: 600; }

.facility {
  margin: 10px 0 2px 14px;
  color: var(--secondary);
  font-size: 12px;
}

.msg {
  max-width: 78%;
  margin-top: 10px;
  padding: 8px 13px;
  border: 0;
  border-radius: 19px;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: filter 0.2s;
}

.msg.atc { align-self: flex-start; background: var(--fill); color: var(--text); }

.msg.pilot { align-self: flex-end; background: var(--blue); color: #ffffff; }

.facility + .msg, .divider + .msg { margin-top: 0; }

.msg.atc + .msg.atc, .msg.pilot + .msg.pilot { margin-top: 2px; }

.msg:active { filter: brightness(0.9); }

.msg.playing { animation: playing 1.2s ease-in-out infinite; }

@keyframes playing {
  50% { filter: brightness(0.82); }
}

@media (prefers-reduced-motion: reduce) {
  .msg.playing { animation: none; filter: brightness(0.82); }
}

.empty {
  margin: 30vh 24px 0;
  color: var(--secondary);
  font-size: 15px;
  text-align: center;
}
