/* CPDLC Ai design system: shared by the landing page, the app and the admin dashboard.
   Follows the system light/dark setting. */
:root {
  color-scheme: light dark;
  --bg: #F5F5F7; --bg-elev: #FBFBFD; --surface: #FFFFFF; --surface2: #EDEDF0; --surface3: #E3E3E8;
  --line: rgba(0, 0, 0, .08); --line-strong: rgba(0, 0, 0, .14);
  --fg: #1D1D1F; --muted: #6E6E73; --faint: #86868B;
  --accent: #0071E3; --accent-2: #5E5CE6; --accent-soft: rgba(0, 113, 227, .10); --on-accent: #FFFFFF;
  --green: #34C759; --green-soft: rgba(52, 199, 89, .14); --amber: #FF9F0A; --amber-soft: rgba(255, 159, 10, .14);
  --red: #FF3B30; --red-soft: rgba(255, 59, 48, .12); --purple: #AF52DE;
  --glass: rgba(251, 251, 253, .72); --scrim: rgba(0, 0, 0, .32);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .06), 0 12px 32px rgba(0, 0, 0, .08);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, .08), 0 30px 80px rgba(0, 0, 0, .12);
  --hl-emergency: #D70015; --hl-instruction: #0066CC; --hl-procedure: #248A3D; --hl-callsign: #8944AB;
  --hl-value: #C93400; --hl-place: #0E7C86; --hl-weather: #3634A3; --hl-phonetic: #946200;
  --mic: #1D1D1F; --on-mic: #FFFFFF;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --display: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  /* Apple-like motion */
  --ease: cubic-bezier(.25, .1, .25, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.32, .72, 0, 1);
  --r-sm: 10px; --r: 14px; --r-lg: 22px; --r-xl: 28px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --bg-elev: #0A0A0B; --surface: #1C1C1E; --surface2: #2C2C2E; --surface3: #3A3A3C;
    --line: rgba(255, 255, 255, .10); --line-strong: rgba(255, 255, 255, .18);
    --fg: #F5F5F7; --muted: #A1A1A6; --faint: #86868B;
    --accent: #2997FF; --accent-2: #7D7AFF; --accent-soft: rgba(41, 151, 255, .16);
    --green: #30D158; --green-soft: rgba(48, 209, 88, .16); --amber: #FFD60A; --amber-soft: rgba(255, 214, 10, .14);
    --red: #FF453A; --red-soft: rgba(255, 69, 58, .16); --purple: #BF5AF2;
    --glass: rgba(18, 18, 20, .72); --scrim: rgba(0, 0, 0, .55);
    --shadow: none; --shadow-lift: 0 12px 40px rgba(0, 0, 0, .6); --shadow-float: 0 30px 90px rgba(0, 0, 0, .7);
    --hl-emergency: #FF6961; --hl-instruction: #64B5FF; --hl-procedure: #30D158; --hl-callsign: #DA8FFF;
    --hl-value: #FFB340; --hl-place: #5AD8E6; --hl-weather: #A5A3FF; --hl-phonetic: #E6C34D;
    --mic: #F5F5F7; --on-mic: #000000;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.47 var(--font); letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
svg:not(.chart):not([width]) { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i, .i svg, button svg, .btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.link { color: var(--accent); text-decoration: none; background: none; border: 0; padding: 0; }
.link:hover { text-decoration: underline; }
.grad-text {
  background: linear-gradient(100deg, var(--accent) 0%, var(--accent-2) 55%, var(--purple) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 980px; padding: 11px 20px; font-weight: 500; font-size: 15px; line-height: 1.2;
  background: var(--surface2); color: var(--fg); text-decoration: none; white-space: nowrap;
  transition: background .25s var(--ease), color .25s, box-shadow .25s, opacity .2s, transform .35s var(--spring), filter .2s;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.97); transition-duration: .1s; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.dark { background: var(--fg); color: var(--bg); }
.btn.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.outline:hover { background: var(--surface2); filter: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); filter: none; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-soft { background: var(--red-soft); color: var(--red); }
.btn.plain { background: transparent; color: var(--accent); }
.btn.sm { padding: 7px 14px; font-size: 13.5px; }
.btn.lg { padding: 15px 28px; font-size: 17px; }
.btn.block { width: 100%; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-accent) var(--on-accent) transparent transparent; animation: spin .7s linear infinite;
}
.btn:not(.primary):not(.danger).busy::after { border-color: var(--fg) var(--fg) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--fg); text-decoration: none;
  transition: background .2s var(--ease), color .2s, transform .3s var(--spring);
}
.icon-btn:hover { background: var(--surface2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- fields */
.field, .form input, .form select, .form textarea {
  width: 100%; border: 1px solid transparent; border-radius: 12px; padding: 12px 14px;
  background: var(--surface2); color: var(--fg); font-size: 16px; outline: none;
  transition: border-color .2s, box-shadow .25s var(--ease), background .2s;
}
.field:focus, .form input:focus, .form select:focus, .form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .lbl { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
span.lbl { display: block; margin-bottom: 2px; }
.form-error { margin: 0; color: var(--red); font-size: 13.5px; }
.form-error:empty { display: none; }
.form-ok { margin: 0; color: var(--green); font-size: 13.5px; }
.form-ok:empty { display: none; }
select.field { appearance: auto; }

/* segmented control with a sliding thumb */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface2); border-radius: 11px; padding: 2px; }
.seg button { position: relative; z-index: 1; border: 0; background: transparent; border-radius: 9px; padding: 7px 12px; font-size: 14px; font-weight: 500; color: var(--muted); transition: color .25s; }
.seg button.on { color: var(--fg); }
.seg .thumb {
  position: absolute; top: 2px; bottom: 2px; left: 2px; border-radius: 9px; background: var(--surface);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); transition: transform .4s var(--spring), width .4s var(--spring);
}
@media (prefers-color-scheme: dark) { .seg .thumb { background: #636366; } }

/* iOS switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; cursor: pointer; }
.switch, .switch-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; margin: 0; border-radius: 16px;
  background: color-mix(in srgb, var(--fg) 12%, transparent); border: 0; position: relative; cursor: pointer;
  transition: background .3s var(--ease);
}
.switch::after, .switch-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
  transition: transform .35s var(--spring);
}
.switch:checked, .switch-row input[type="checkbox"]:checked { background: var(--green); }
.switch:checked::after, .switch-row input[type="checkbox"]:checked::after { transform: translateX(20px); }

/* ---------------------------------------------------------------- badges + chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 980px;
  font-size: 12px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; background: var(--surface2); color: var(--muted);
}
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 80%, var(--fg)); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.purple { background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 13px; border-radius: 980px;
  background: var(--accent-soft); color: var(--accent); font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  animation: pop .35s var(--spring);
}
.chip .icon-btn { color: var(--accent); width: 26px; height: 26px; }
.chip .icon-btn svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border-radius: var(--r); padding: 4px 16px; }
.card.pad { padding: 16px; }
.card p { margin: 0; line-height: 1.45; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.row-title { font-size: 16px; display: block; letter-spacing: -.015em; }
.row-hint { font-size: 13px; color: var(--muted); display: block; margin: 2px 12px 8px 0; }
.switch-row .row-hint { margin-bottom: 0; }
.nav-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border: 0; background: none; text-align: left;
  font-size: 16px; color: var(--fg);
}
.nav-row + .nav-row { border-top: 1px solid var(--line); }
.nav-row .grow { flex: 1; min-width: 0; }
.nav-row .chev { color: var(--faint); width: 16px; height: 16px; }
.nav-row .val { color: var(--muted); font-size: 15px; }
.nav-row.danger { color: var(--red); }

/* ---------------------------------------------------------------- sheets + modals */
.sheet {
  position: fixed; inset: 0; z-index: 30; background: var(--scrim); display: flex; justify-content: center; align-items: flex-end;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: fade .3s var(--ease);
}
.sheet.closing { animation: fade-out .28s var(--ease) forwards; }
.sheet-page {
  width: 100%; max-width: 640px; height: calc(100% - 12px); background: var(--bg); display: flex; flex-direction: column;
  border-radius: 14px 14px 0 0; overflow: hidden; padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  animation: sheet-up .55s var(--spring); box-shadow: var(--shadow-float);
}
.sheet.closing .sheet-page { animation: sheet-down .32s var(--ease) forwards; }
.sheet-head { display: flex; align-items: center; gap: 6px; padding: 14px 16px 8px 10px; }
.sheet-head h1 { flex: 1; margin: 0; font: 700 26px/1.15 var(--display); letter-spacing: -.028em; }
.sheet-head h1.center { text-align: center; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 20px calc(36px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.group-title { margin: 26px 0 8px 16px; font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.group-foot { margin: 8px 16px 0; font-size: 12.5px; color: var(--faint); line-height: 1.4; }
@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-page { height: auto; max-height: calc(100% - 64px); border-radius: 26px; animation: pop-in .5s var(--spring); }
  .sheet.closing .sheet-page { animation: pop-out .25s var(--ease) forwards; }
  .sheet-page.tall { height: calc(100% - 64px); }
}

.modal {
  position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: grid; place-items: center; padding: 16px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: fade .25s var(--ease);
}
.modal.closing { animation: fade-out .2s var(--ease) forwards; }
.modal-card {
  width: 100%; max-width: 380px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 24px;
  padding: 26px 22px 20px; box-shadow: var(--shadow-float); animation: pop-in .45s var(--spring); text-align: center;
}
.modal.closing .modal-card { animation: pop-out .2s var(--ease) forwards; }
.modal-card.wide { max-width: 520px; text-align: left; }
.modal-card h2 { margin: 0 0 6px; font-size: 19px; font-weight: 600; letter-spacing: -.02em; }
.modal-card > p { margin: 0 0 20px; color: var(--muted); line-height: 1.45; font-size: 14.5px; }
.modal-card > p:empty { display: none; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.modal-actions .btn { width: 100%; }
.modal-card .form { text-align: left; }

/* toast */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 460px; padding: 12px 18px; border-radius: 16px;
  background: color-mix(in srgb, var(--fg) 92%, transparent); color: var(--bg); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-float); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  animation: toast-in .5s var(--spring);
}
.toast.out { animation: toast-out .3s var(--ease) forwards; }
.toast.error { background: var(--red); color: #fff; }

/* ---------------------------------------------------------------- motion */
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
@keyframes pop-in { from { transform: scale(.94) translateY(8px); opacity: 0; } }
@keyframes pop-out { to { transform: scale(.96); opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
@keyframes toast-in { from { transform: translateY(24px) scale(.96); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(10px) scale(.98); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake { animation: shake .4s var(--ease); }

/* children with class "rise" animate in one after another (set --i on each) */
.rise { animation: rise .7s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 60ms); }

/* skeleton shimmer while loading */
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--surface2) 0%, var(--surface3) 50%, var(--surface2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* view transitions (Chrome / Safari 18) */
::view-transition-old(root) { animation: .28s var(--ease) both vt-out; }
::view-transition-new(root) { animation: .5s var(--ease-out) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: scale(.985); } }
@keyframes vt-in { from { opacity: 0; transform: scale(1.01); } }

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