/* =====================================================================
   MLE Field Tools - stylesheet
   Design constraints driven by the actual use case:
     - read in direct sunlight on a dock  -> very high contrast, no grey-on-grey
     - operated with one hand, possibly gloved -> 48px minimum touch targets
     - iOS Safari must not zoom on focus  -> all inputs >= 16px
     - nav within thumb reach -> bottom tab bar, safe-area aware
   ===================================================================== */

:root {
  --navy:      #0b2545;
  --navy-2:    #13355f;
  --accent:    #0069c0;
  --accent-lo: #e7f1fb;
  --ok:        #1b6e3c;
  --ok-bg:     #e6f4ea;
  --warn:      #8a4b00;
  --warn-bg:   #fff4e0;
  --bad:       #a01b1b;
  --bad-bg:    #fdeaea;
  --ink:       #12181f;
  --ink-2:     #4a5563;
  --line:      #c9d2dc;
  --line-2:    #e4e9ef;
  --bg:        #ffffff;
  --bg-2:      #f4f7fa;
  --radius:    10px;
  --tap:       48px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #06121f; --navy-2: #0d2137;
    --accent: #4da3ff; --accent-lo: #12283d;
    --ok: #6ee7a0; --ok-bg: #12301f;
    --warn: #ffc266; --warn-bg: #35270f;
    --bad: #ff8f8f; --bad-bg: #3a1414;
    --ink: #eef3f8; --ink-2: #a8b6c6;
    --line: #2b3947; --line-2: #1d2937;
    --bg: #0b1219; --bg-2: #121b25;
  }
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--font);
  font-size: 17px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

/* ---------- app frame ---------- */

header.appbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--navy); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
header.appbar .mark {
  font-weight: 800; letter-spacing: .06em; font-size: 15px;
  background: #fff; color: var(--navy);
  padding: 3px 7px; border-radius: 5px; flex: none;
}
header.appbar h1 { font-size: 16px; margin: 0; font-weight: 600; flex: 1; }
header.appbar .ver { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }
header.appbar .netdot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #4ade80; flex: none;
}
header.appbar .netdot.off { background: #fbbf24; }

main {
  padding: 14px 14px calc(var(--tap) + env(safe-area-inset-bottom, 0px) + 34px);
  max-width: 760px; margin: 0 auto;
}

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
nav.tabs button {
  flex: 1; min-height: var(--tap);
  border: 0; background: none; color: var(--ink-2);
  font: inherit; font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 2px; cursor: pointer;
  border-top: 3px solid transparent;
}
nav.tabs button .ic { font-size: 19px; line-height: 1; }
nav.tabs button[aria-selected="true"] {
  color: var(--accent); border-top-color: var(--accent);
  background: var(--accent-lo);
}

section.panel { display: none; }
section.panel.active { display: block; }

/* ---------- cards, fields ---------- */

.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 0 0 14px;
}
.card > h2 {
  margin: -2px 0 12px; font-size: 15px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2);
}
.card > h2 .sub { text-transform: none; letter-spacing: 0; font-weight: 400; }

details.card > summary {
  cursor: pointer; font-size: 15px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2);
  min-height: 30px; display: flex; align-items: center;
}
details.card[open] > summary { margin-bottom: 12px; }

.grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.grid.one { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 420px) { .grid.three { grid-template-columns: 1fr 1fr; } }

label.f { display: block; }
label.f > span {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 4px;
}
label.f > span .u { font-weight: 400; opacity: .8; }

input[type="number"], input[type="text"], select {
  width: 100%; min-height: var(--tap);
  font: inherit; font-size: 17px;
  padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-lo);
}
select { -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
                    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 34px;
}

.seg { display: flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1; min-height: var(--tap); border: 0; background: var(--bg);
  color: var(--ink-2); font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

button.btn {
  min-height: var(--tap); padding: 0 16px;
  border: 1.5px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff;
  font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
}
button.btn.ghost { background: var(--bg); color: var(--accent); }
button.btn.mini { min-height: 38px; font-size: 14px; padding: 0 10px; }

/* ---------- results ---------- */

.out { background: var(--bg-2); border-radius: 8px; padding: 4px 0; margin-top: 12px; }
.row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-2);
}
.row:last-child { border-bottom: 0; }
.row .k { font-size: 14px; color: var(--ink-2); }
.row .v { font-family: var(--mono); font-size: 16.5px; font-weight: 600;
          font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row.hero { background: var(--accent-lo); border-radius: 6px; margin: 4px 6px; border: 0; }
.row.hero .k { color: var(--ink); font-weight: 700; font-size: 14.5px; }
.row.hero .v { font-size: 21px; color: var(--accent); }

.note {
  margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  font-size: 13.5px; line-height: 1.4;
  background: var(--warn-bg); color: var(--warn);
  border-left: 4px solid currentColor;
}
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.ok  { background: var(--ok-bg);  color: var(--ok); }
.note.info{ background: var(--accent-lo); color: var(--accent); }
.note + .note { margin-top: 6px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
table.tbl th, table.tbl td {
  padding: 7px 6px; text-align: right; border-bottom: 1px solid var(--line-2);
  font-variant-numeric: tabular-nums;
}
table.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
               color: var(--ink-2); text-align: right; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl tr.pick { background: var(--ok-bg); }
table.tbl tr.pick td { font-weight: 700; color: var(--ok); }
table.tbl td.no { color: var(--ink-2); opacity: .55; }

/* dynamic fitting rows */
.frow { display: grid; grid-template-columns: 1fr 68px 44px; gap: 6px;
        align-items: center; margin-bottom: 6px; }
.frow select, .frow input { min-height: 42px; font-size: 15px; }
.frow button {
  min-height: 42px; border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--bad); font: inherit; font-size: 20px;
  line-height: 1; cursor: pointer;
}

/* psych chart */
.chartwrap { margin-top: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
svg.chart { display: block; width: 100%; min-width: 320px; height: auto; }
svg.chart .sat   { fill: none; stroke: var(--ink); stroke-width: 2.2; }
svg.chart .rh    { fill: none; stroke: var(--line); stroke-width: 1; }
svg.chart .rhlab { fill: var(--ink-2); font-size: 9px; font-family: var(--font); }
svg.chart .gridl { stroke: var(--line-2); stroke-width: 1; }
svg.chart .axis  { stroke: var(--ink-2); stroke-width: 1.2; }
svg.chart .axlab { fill: var(--ink-2); font-size: 10px; font-family: var(--font); }
svg.chart .proc  { stroke: var(--accent); stroke-width: 2.5; fill: none;
                   stroke-linecap: round; }
svg.chart .pt1   { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
svg.chart .pt2   { fill: var(--bad); stroke: var(--bg); stroke-width: 2; }
svg.chart .ptlab { fill: var(--ink); font-size: 10px; font-weight: 700;
                   font-family: var(--font); }

.basis h3 { font-size: 14px; margin: 16px 0 6px; }
.basis p, .basis li { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.basis ul { padding-left: 20px; margin: 6px 0; }
.basis code { font-family: var(--mono); font-size: 13px; background: var(--bg-2);
              padding: 1px 4px; border-radius: 3px; }
.stamp {
  border: 2px solid var(--bad); color: var(--bad); border-radius: 8px;
  padding: 10px 12px; font-size: 13.5px; font-weight: 600; line-height: 1.45;
}
.hint { font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.stackbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
