:root {
  --bg: #f3f2ee; --card: #ffffff; --ink: #1d211c; --muted: #66706a; --line: #e0ded6;
  --accent: #8a4f0e; --accent-ink: #ffffff; --bar: #263027; --bar-ink: #f3f2ee;
  --good: #1f7a45; --good-bg: #e1f4e8; --warn: #8a5a00; --warn-bg: #fff1d1;
  --bad: #b3261e; --bad-bg: #fde6e4; --blue: #1f4e8c; --blue-bg: #e3edfb; --grey-bg: #ebeae4;
  --sand: #f6ecd9; --radius: 16px; --shadow: 0 1px 3px rgba(0,0,0,.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111410; --card: #1b201b; --ink: #e8ebe6; --muted: #9aa59c; --line: #2b322b;
    --accent: #e3a55a; --accent-ink: #1a1206; --bar: #0b0e0b; --bar-ink: #e8ebe6;
    --good: #85d6a2; --good-bg: #15301f; --warn: #f2c063; --warn-bg: #3a2c0d;
    --bad: #ff8a80; --bad-bg: #3b1714; --blue: #9cc1f5; --blue-bg: #17263b; --grey-bg: #252b25;
    --sand: #2c2618; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.center { text-align: center; padding: 40px 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
[hidden] { display: none !important; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-ink);
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; display: flex; align-items: center; gap: 4px; }
.bar h1 { font-size: 18px; margin: 0 6px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar button, .bar a { background: transparent; border: 0; color: var(--bar-ink); padding: 6px 10px; font-size: 21px; text-decoration: none;
  border-radius: 10px; min-height: 42px; min-width: 42px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.bar button:active, .bar a:active { background: rgba(255,255,255,.12); }
.offline { background: var(--warn-bg); color: var(--warn); font-size: 13px; text-align: center; padding: 6px 10px; font-weight: 600; }

.wrap { max-width: 680px; margin: 0 auto; padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 6px;
  font-size: 10.5px; color: var(--muted); text-decoration: none; }
.tabs a span { font-size: 21px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--accent); font-weight: 700; }
.tabs a.on span { filter: none; opacity: 1; }

/* login */
.login { max-width: 360px; margin: 10vh auto 0; padding: 0 16px; text-align: center; }
.login .logo { font-size: 54px; }
.login h1 { font-size: 26px; margin: 4px 0; }
.login form { text-align: left; margin-top: 14px; }

/* cards */
.card { display: block; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card h2 .sp { flex: 1; }
.card p { margin: 0 0 8px; }
.card p:last-child { margin-bottom: 0; }
.group { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 4px 8px; font-weight: 600; }
.intro { background: var(--sand); }

/* drone list */
.drone { display: flex; gap: 12px; align-items: center; }
.drone .ic { flex: none; width: 52px; height: 52px; border-radius: 14px; background: var(--sand); display: grid; place-items: center; font-size: 28px; }
.drone .dt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.drone .dt b { font-size: 16px; line-height: 1.25; }
.drone .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.drone .chev { color: var(--muted); font-size: 22px; }
.hero { display: flex; gap: 14px; align-items: flex-start; }
.hero .ic { flex: none; width: 64px; height: 64px; border-radius: 16px; background: var(--sand); display: grid; place-items: center; font-size: 36px; }
.hero h2 { font-size: 19px; margin: 0 0 2px; display: block; }

/* inputs */
label.f { display: block; margin: 0 0 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.f > small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=url], input[type=tel], input[type=email], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 10px 12px; min-height: 44px; font-size: 16px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=date] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 > * { min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--card); border-radius: 12px; padding: 10px 14px; min-height: 46px; cursor: pointer; text-decoration: none; color: inherit; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 6px 12px; border-radius: 10px; font-size: 14px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.mt { margin-top: 10px; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--card); padding: 7px 4px; min-height: 38px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* tags */
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--grey-bg); white-space: nowrap; }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.blue { background: var(--blue-bg); color: var(--blue); }

/* sub-tabs on a drone */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer; text-decoration: none; color: inherit; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chip i { font-style: normal; opacity: .7; font-size: 12px; margin-left: 3px; }

/* specs table */
table.specs { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.specs td { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
table.specs tr:first-child td { border-top: 0; }
table.specs td:first-child { color: var(--muted); width: 36%; padding-right: 10px; }
table.specs .src { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* lists of things */
.li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.li:first-of-type { border-top: 0; }
.li .lt { flex: 1; min-width: 0; }
.li .lt b { display: block; font-weight: 600; }
.li .lt a { text-decoration: none; }
.li .lt a b { color: var(--accent); }
.li .lic { flex: none; font-size: 20px; width: 28px; text-align: center; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 6px 8px; cursor: pointer; border-radius: 8px; flex: none; min-width: 36px; min-height: 36px; }
.x:active { background: var(--grey-bg); }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* photos */
.photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.photos img, .photos .add { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; background: var(--grey-bg); cursor: pointer; }
.photos .add { border: 1px dashed var(--muted); display: grid; place-items: center; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.2; padding: 4px; }
.viewer { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.92); display: flex; flex-direction: column; color: #fff; }
.viewer .vimg { flex: 1; display: grid; place-items: center; overflow: auto; padding: calc(env(safe-area-inset-top) + 50px) 8px 8px; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .vbar { position: absolute; top: calc(env(safe-area-inset-top) + 6px); right: 6px; left: 6px; display: flex; justify-content: space-between; }
.viewer .vbar button, .viewer .vbar a { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 10px; padding: 8px 12px; font-size: 15px; text-decoration: none; }
.viewer .vfoot { padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px); display: flex; gap: 8px; }
.viewer .vfoot input { flex: 1; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); }

/* bottom sheet form */
.sheet-bg { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 14px 14px calc(env(safe-area-inset-bottom) + 18px); }
.sheet .sh { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; position: sticky; top: -14px; background: var(--bg); padding: 4px 0; z-index: 1; }
.sheet .sh h3 { flex: 1; margin: 0; font-size: 18px; }
.sheet .acts { display: flex; gap: 8px; margin-top: 6px; }
.sheet .acts .btn { flex: 1; }
body.noscroll { overflow: hidden; }

/* teaching and CONOPS */
.phase { border-left: 4px solid var(--line); }
.phase.planned { border-left-color: var(--blue); }
.phase.written { border-left-color: var(--warn); }
.phase.taught { border-left-color: var(--good); }
.phase .ph { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.phase .seg { margin: 10px 0; }
.csec .q { font-size: 13px; color: var(--muted); margin: -4px 0 8px; }
.saved { font-size: 12.5px; color: var(--muted); min-height: 1em; }
progress { display: block; width: 100%; height: 7px; margin: 6px 0 2px; border: 0; border-radius: 99px; background: var(--grey-bg); overflow: hidden; -webkit-appearance: none; appearance: none; }
progress::-webkit-progress-bar { background: var(--grey-bg); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--good); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--good); border-radius: 99px; }
[data-plain] { color: inherit; text-decoration: none; }
[data-mb] { margin-bottom: 12px; }
b.big { font-size: 19px; }
.tc { text-align: center; }

/* checklists */
.item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .box { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); background: var(--card); display: grid; place-items: center;
  font-weight: 800; color: #fff; cursor: pointer; margin-top: 1px; }
.item.done .box { background: var(--good); border-color: var(--good); }
.item.done .it { color: var(--muted); }
.item .it { flex: 1; min-width: 0; cursor: pointer; }
.item .ans { display: block; margin-top: 4px; font-size: 14px; background: var(--good-bg); color: var(--ink); border-radius: 8px; padding: 6px 8px; white-space: pre-wrap; }

/* people */
.person { display: flex; gap: 12px; align-items: center; }
.avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--sand); display: grid; place-items: center; font-weight: 700; color: var(--accent); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 84px; height: 84px; font-size: 28px; }
.person .pt { flex: 1; min-width: 0; }
.person .pt b { display: block; }
.contact { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.contact a { flex: 1 1 auto; }

/* reference tables */
table.ref { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ref td { padding: 8px 6px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.refblock b { display: block; margin-top: 10px; }
.refblock p { margin: 2px 0 0; font-size: 14.5px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 90;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: 90vw; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.upl { font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 6px; }

/* print (CONOPS, drill card) */
.print { max-width: 760px; margin: 0 auto; padding: 24px; background: #fff; color: #111; font: 12pt/1.45 Georgia, "Times New Roman", serif; }
.print h1 { font-size: 20pt; margin: 0 0 4px; }
.print h2 { font-size: 13pt; margin: 18px 0 4px; border-bottom: 1px solid #999; padding-bottom: 2px; }
.print .q { font-style: italic; color: #555; font-size: 10pt; margin: 0 0 4px; }
.print .meta { color: #444; font-size: 10pt; }
.print p { white-space: pre-wrap; margin: 0; }
.print .noprint { font-family: -apple-system, Arial, sans-serif; margin-bottom: 16px; display: flex; gap: 8px; }
@media print {
  .noprint { display: none !important; }
  body { background: #fff; }
  .print { padding: 0; }
  @page { size: A4; margin: 18mm; }
}

/* flight calculator */
.unit { position: relative; }
.unit input { padding-right: 64px; }
.unit i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 13px; color: var(--muted); pointer-events: none; }
.res { border: 2px solid var(--accent); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--sand); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile b { font-size: 21px; line-height: 1.15; }
.tile span { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.warns { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.warns .w { border-radius: 10px; padding: 8px 10px; font-size: 13.5px; line-height: 1.35; }
.warns .w.warn { background: var(--warn-bg); color: var(--warn); }
.warns .w.bad { background: var(--bad-bg); color: var(--bad); }
b.good { color: var(--good); } b.bad { color: var(--bad); }
.tw { overflow-x: auto; margin: 0 -4px; }
table.ct { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ct th, table.ct td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.ct th { overflow-wrap: normal; font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: normal; }
table.ct tr.cur td { background: var(--sand); font-weight: 700; }
table.ct tr.over td { color: var(--bad); }
table.ct .x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
details.card summary { cursor: pointer; font-size: 15px; }
.calcmini { position: sticky; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 5; display: flex; gap: 6px; margin: 0 -4px;
  background: var(--bar); color: var(--bar-ink); border-radius: 12px; padding: 8px 10px; font-size: 12px; line-height: 1.25; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.calcmini span { flex: 1; min-width: 0; }
.calcmini b { display: block; font-size: 15px; }
