/* GeoNote — geological field notebook with GPS.
   Colour themes are chosen in Settings → ธีมสี. "geonote" (the default) follows the app icon:
   paper white with slate-navy ink and earth tones. "dark" (Night) stays true black so OLED pixels
   switch off. The other themes (v1.7) are at the end of this file. Map symbols always use
   field-book yellow (--map-ink). */

:root {
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --r-lg: 14px;
  --r-md: 11px;
  --map-ink: #f5c933;
}

/* Extras a theme may set (defaults here): the header background and the line or band under it,
   the fill of primary buttons (a colour or a gradient), a pattern behind the screens, and a filter
   over the map. Declared on every [data-theme] element, so the previews in Settings show them too. */
:root, [data-theme] {
  --bar: var(--bg);
  --bar-edge: 1px solid var(--rule);
  --bar-band: none;
  --bar-band-h: 0px;
  --accent-fill: var(--accent);
  --paper-img: none;
  --paper-size: auto;
  --paper-attach: local;
  --paper-pos: 0 0;
  --map-filter: none;
  /* v1.7: text on the top and tab bars (for bars darker or brighter than the page), the tab bar's
     own fill and top line, a heading typeface, a shade inside the screen, a glow on big numbers */
  --bar-text: var(--text);
  --bar-text-2: var(--text-2);
  --bar-text-3: var(--text-3);
  --bar-press: var(--raise-2);
  --tab-text: var(--bar-text);
  --tab-text-2: var(--bar-text-2);
  --tab-text-3: var(--bar-text-3);
  --tab-press: var(--bar-press);
  --tab-bg: var(--bar);
  --tab-edge: 1px solid var(--rule);
  --display: var(--font);
  --display-w: 600;
  --view-shade: none;
  --num-glow: none;
  --fill-ink: var(--accent-ink);
  --cta-bg: linear-gradient(to bottom, transparent, var(--bg) 40%);
}

/* GeoNote: the app icon's colours: cream page, slate, sand and river blue */
:root, [data-theme='geonote'] {
  --bg: #f7f5ef;
  --raise: #eeebe3;
  --raise-2: #e4dfd4;
  --rule: #ddd6c8;
  --rule-strong: #8b8880;
  --text: #1f3440;
  --text-2: #3e5460;
  --text-3: #627279;
  --accent: #34505e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(196, 168, 140, 0.3);
  --sym: #93653b;
  --good: #3f7a4f;
  --fair: #a0661c;
  --bad: #b3432c;
  --info: #4f7b8b;
  --chip: rgba(247, 245, 239, 0.94);
  --focus: #34505e;
  --tab-on: #34505e;
  --btn-edge: #cfc6b6;
  color-scheme: light;
}

/* Night: true black for OLED battery saving, field-book yellow. Only in the header button (with Sunlight) */
[data-theme='dark'] {
  --bg: #000000;
  --raise: #101213;
  --raise-2: #1a1d1e;
  --rule: #2a2e2f;
  --rule-strong: #4c5254;
  --text: #ecebe3;
  --text-2: #a8aaa3;
  --text-3: #868981;
  --accent: #f5c933;
  --accent-ink: #1a1500;
  --accent-soft: rgba(245, 201, 51, 0.14);
  --sym: #f5c933;
  --good: #3dd68c;
  --fair: #f5a524;
  --bad: #ff6b57;
  --info: #5ab8f2;
  --chip: rgba(0, 0, 0, 0.74);
  --focus: #f5c933;
  --tab-on: #f5c933;
  --btn-edge: transparent;
  color-scheme: dark;
}

/* Sunlight: black on white for glare. Only in the header button (with Night), not in Settings */
[data-theme='sun'] {
  --bg: #ffffff;
  --raise: #f2f2ee;
  --raise-2: #e6e6e0;
  --rule: #cfcfc6;
  --rule-strong: #1b1b1b;
  --text: #000000;
  --text-2: #2c2c29;
  --text-3: #5b5b55;
  --accent: #f5c933;
  --accent-ink: #000000;
  --accent-soft: rgba(245, 201, 51, 0.3);
  --sym: #7a5c00;
  --good: #087a4b;
  --fair: #9a5800;
  --bad: #c22a16;
  --info: #0a68ad;
  --chip: rgba(255, 255, 255, 0.92);
  --focus: #000000;
  --tab-on: #000000;
  --btn-edge: #000000;
  color-scheme: light;
}



/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i.inline { width: 16px; height: 16px; vertical-align: -3px; }
.hidden { display: none !important; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nw { white-space: nowrap; }
.muted { color: var(--text-3); }
.q-good { color: var(--good); }
.q-fair { color: var(--fair); }
.q-bad { color: var(--bad); }

/* ---------- shell ---------- */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.topbar {
  flex: none;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  min-height: 54px;
  padding: calc(var(--safe-t) + 2px) 6px 2px;
  background: var(--bar);
  border-bottom: var(--bar-edge);
  position: relative;
  z-index: 20;
}
.topbar::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: var(--bar-band-h); background: var(--bar-band); pointer-events: none; }
.topbar, .tp .tp-bar { --text: var(--bar-text); --text-2: var(--bar-text-2); --text-3: var(--bar-text-3); --raise-2: var(--bar-press); color: var(--text); }
.tabbar, .tp .tp-tab { --text: var(--tab-text); --text-2: var(--tab-text-2); --text-3: var(--tab-text-3); --raise-2: var(--tab-press); color: var(--text); }
.tb-side { display: flex; align-items: center; min-width: 0; }
.tb-side.right { justify-content: flex-end; }
.tb-title { text-align: center; min-width: 0; }

.brand { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; }
.brand b { font-family: var(--display); font-weight: var(--display-w); font-size: 19px; letter-spacing: 0.01em; }
.brand small { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-3); max-width: 62vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.brand { color: inherit; border-radius: 10px; padding: 2px 10px; }
a.brand:active { background: var(--raise-2); }
.brand .chev { width: 14px; height: 14px; stroke-width: 2.2; }

.hdr-st { display: inline-flex; align-items: baseline; gap: 8px; }
.hdr-st span { font-size: 15px; color: var(--text-2); }
.hdr-st b { font-family: var(--mono); font-weight: 500; font-size: 22px; letter-spacing: 0.04em; }

.save-state { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--text-3); white-space: nowrap; padding-right: 8px; }
.save-state .i { width: 15px; height: 15px; color: var(--good); }
.save-state.saving { color: var(--text-2); }
.save-state.error { color: var(--bad); }

main#view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; position: relative;
  background-color: var(--bg); background-image: var(--paper-img); background-size: var(--paper-size); background-attachment: var(--paper-attach);
  background-position: var(--paper-pos); box-shadow: var(--view-shade); }
main#view:focus { outline: none; }

.tabbar {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--tab-bg);
  border-top: var(--tab-edge);
  /* sit low, like v0.4 in the browser: only part of the home-indicator area is kept free */
  padding-bottom: max(2px, calc(var(--safe-b) - 18px));
  z-index: 20;
}
.tabbar.hide { display: none; }
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}
.tab.active { color: var(--tab-on); }
.tab.active::before { content: ''; position: absolute; top: -1px; left: 32%; right: 32%; height: 2px; border-radius: 0 0 2px 2px; background: var(--tab-on); }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--text-2);
}
.icon-btn:active { background: var(--raise-2); }

.screen { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 14px; max-width: 620px; margin: 0 auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--rule-strong);
  background: transparent;
  font-size: 15px; font-weight: 500;
}
.btn .i { width: 20px; height: 20px; }
.btn:active { background: var(--raise-2); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.btn.add {
  width: 100%; justify-content: flex-start;
  border-style: dashed; color: var(--text-2);
  margin-top: 10px;
}
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 20px;
  border: 2px solid var(--btn-edge);
  border-radius: var(--r-lg);
  background: var(--accent-fill); color: var(--fill-ink);
  font-size: 16px; font-weight: 600; letter-spacing: 0.06em;
}
.btn-primary .i { stroke-width: 2.1; }
.btn-primary.xl { width: 100%; min-height: 60px; font-size: 17px; }
.btn-primary.block { width: 100%; }
.btn-primary:active { transform: translateY(1px); filter: brightness(0.94); }
.btn-primary[disabled] { opacity: 0.55; }

.btn-text {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  align-self: center; margin-top: 8px; padding: 10px 14px;
  border: 0; background: transparent; font-size: 15px;
}
.btn-text.danger { color: var(--bad); }

.cta {
  position: sticky; bottom: 0; z-index: 10;
  max-width: 620px; margin: 0 auto;
  padding: 18px 16px 14px;
  background: var(--cta-bg);
}
.view-station .cta, .view-stationEdit .cta, .view-summary .cta, .view-projects .cta { padding-bottom: calc(14px + var(--safe-b)); }

/* ---------- GPS screen ---------- */
.gps-screen { gap: 12px; padding-bottom: 8px; }

.minimap {
  position: relative;
  height: 23vh; min-height: 150px; max-height: 260px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--rule);
  cursor: pointer;
}

.gps-chip {
  position: absolute; left: 10px; top: 10px; z-index: 1000;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--chip);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  font-size: 13px; font-weight: 500;
  pointer-events: none;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.q-good { background: var(--good); }
.dot.q-fair { background: var(--fair); }
.dot.q-bad { background: var(--bad); }
.dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.help { padding: 12px 14px; border-radius: var(--r-md); border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); font-size: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.readout { margin: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.ro-row {
  display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px;
  padding: 6px 2px; min-height: 48px;
  border-top: 1px solid var(--rule);
  cursor: default;
}
.ro-row:first-child { border-top: 0; }
.ro-row[data-copy] { cursor: copy; }
.ro-row dt { font-size: 15px; font-weight: 500; color: var(--text-2); line-height: 1.25; }
.ro-row dd {
  margin: 0; text-align: right;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 26px; font-weight: 400; line-height: 1.2; letter-spacing: -0.01em;
  white-space: nowrap;
}
.ro-row dd small { font-size: 14px; color: var(--text-3); margin-left: 6px; letter-spacing: 0; }
.ro-row dd .u, .loc-rows dd .u { font-family: var(--font); font-size: 16px; margin-left: 5px; letter-spacing: 0; }
.ro-row dd .u { color: var(--text-2); }
.ro-row dd .q-good .u, .ro-row dd .q-fair .u, .ro-row dd .q-bad .u { color: inherit; }
.ro-row.zone dd { color: var(--sym); }
.ro-row .na { font-family: var(--font); font-size: 14px; color: var(--text-3); }
.readout.no-fix dd { color: var(--text-3); }

.coord-head { display: flex; align-items: center; gap: 8px; margin-bottom: -4px; }
.coord-head .copy { margin-left: auto; }
.pill, .pill-select { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--rule-strong); font-size: 15px; font-weight: 500; }
.pill { color: var(--text-2); }
.pill-select { position: relative; padding: 0; }
.pill-select select { min-height: 34px; border: 0; padding: 0 34px 0 12px; font-size: 15px; font-weight: 600; background: transparent; }
.pill-select select:focus { box-shadow: none; }
.pill-select .i { position: absolute; right: 8px; width: 18px; height: 18px; pointer-events: none; color: var(--text-2); }
.fix-line { min-height: 22px; font-size: 13px; color: var(--text-3); margin-top: -6px; }
.fix-line .progress { margin: 0 0 6px; }

.qbar { display: inline-flex; gap: 3px; margin-left: 12px; vertical-align: 2px; }
.qbar i { width: 5px; height: 15px; border-radius: 1.5px; background: var(--rule); }
.qbar.q-good i.on { background: var(--good); }
.qbar.q-fair i.on { background: var(--fair); }
.qbar.q-bad i.on { background: var(--bad); }

.compass { display: flex; align-items: center; gap: 16px; padding: 2px 2px 4px; }
.dial { width: 78px; height: 78px; flex: none; }
.dial .ring { fill: var(--raise); stroke: var(--rule); stroke-width: 1; }
.dial .tick { stroke: var(--text-3); stroke-width: 1; }
.dial .tick.major { stroke: var(--text-2); stroke-width: 1.8; }
.dial text { font-family: var(--mono); font-size: 11px; font-weight: 500; fill: var(--text-2); text-anchor: middle; dominant-baseline: central; }
.dial text.n { fill: var(--bad); }
.dial .lubber { fill: var(--sym); }
.dial .hub { fill: var(--text-2); }
.compass.off .dial { opacity: 0.45; }
.cmp-read { flex: 1; min-width: 0; }
.cmp-label { font-size: 13px; font-weight: 600; color: var(--text-3); }
.cmp-val { display: flex; align-items: baseline; gap: 10px; font-family: var(--mono); font-size: 32px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.cmp-card { font-size: 18px; color: var(--text-2); }
.cmp-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.banner {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 12px 6px 12px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  font-size: 14px; line-height: 1.5;
}
.banner p { flex: 1; }
.banner-actions { display: flex; align-items: center; gap: 2px; margin-top: -6px; }

/* ---------- notebook pages (station, settings) ---------- */
.page { gap: 0; }
.sec { border-top: 1px solid var(--rule); padding: 18px 0 20px; }
.page > .sec:first-child { border-top: 0; padding-top: 6px; }
.sec-h { margin: 0 0 4px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.sec-h .btn { align-self: center; }
.sec-note { font-size: 13px; font-weight: 400; color: var(--text-3); }
.sec-empty { font-size: 14px; color: var(--text-3); padding: 6px 0 2px; }

.field { display: block; margin-top: 14px; }
.lbl { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 2px; }
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 13px; color: var(--text-3); margin-top: 10px; line-height: 1.55; }

input[type='text'], select {
  width: 100%; min-height: 46px;
  padding: 9px 2px;
  border: 0; border-bottom: 1.5px solid var(--rule-strong); border-radius: 0;
  background: transparent;
  font-size: 17px;
  outline: none;
  -webkit-appearance: none; appearance: none;
}
input[type='text']:focus, select:focus { border-bottom-color: var(--accent); box-shadow: 0 1.5px 0 0 var(--accent); }
input.invalid, input.invalid:focus { border-bottom-color: var(--bad); box-shadow: 0 1.5px 0 0 var(--bad); color: var(--bad); }
::placeholder { color: var(--text-3); opacity: 1; }
select option, select optgroup { background: var(--raise); color: var(--text); }

.select { position: relative; display: block; }
.select select { padding-right: 30px; text-overflow: ellipsis; }
.select::after {
  content: ''; position: absolute; right: 8px; top: 50%;
  width: 8px; height: 8px;
  border-right: 1.8px solid var(--text-2); border-bottom: 1.8px solid var(--text-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Notes: ruled like a field book page */
textarea {
  display: block; width: 100%;
  min-height: 168px; margin-top: 8px; padding: 0 2px;
  border: 0; outline: none; resize: vertical;
  font-size: 17px; line-height: 28px;
  background: transparent repeating-linear-gradient(to bottom, transparent 0, transparent 27px, var(--rule) 27px, var(--rule) 28px);
  background-attachment: local;
}
textarea:focus { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 27px, color-mix(in srgb, var(--accent) 50%, var(--rule)) 27px, color-mix(in srgb, var(--accent) 50%, var(--rule)) 28px); }

/* Location panel — the coordinate every observation hangs on */
.loc-panel { background: var(--raise); border-radius: var(--r-lg); padding: 14px 14px 16px; margin-bottom: 18px; }
.fix-tag { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor; }
.loc-sys { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.loc-rows { margin: 8px 0 0; }
.loc-rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-top: 1px solid var(--rule); }
.loc-rows > div:first-child { border-top: 0; }
.loc-rows dt { font-size: 14px; color: var(--text-2); }
.loc-rows dd { margin: 0; font-family: var(--mono); font-size: 20px; font-variant-numeric: tabular-nums; }
.loc-rows dd .u { color: var(--text-2); }
.loc-rows dd .q-good .u, .loc-rows dd .q-fair .u, .loc-rows dd .q-bad .u { color: inherit; }
.loc-note { font-size: 13px; color: var(--text-3); margin-top: 10px; }
.loc-wait { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text-2); margin-top: 8px; }
.progress { height: 4px; border-radius: 2px; background: var(--raise-2); overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s linear; }

/* Strike/dip measurements */
.meas { background: var(--raise); border-radius: var(--r-md); padding: 8px 10px 12px; margin-top: 12px; }
.meas-top { display: flex; align-items: center; gap: 8px; }
.meas-top .select { flex: 1; min-width: 0; }
.meas-top select { min-height: 42px; font-size: 16px; border-bottom-color: var(--rule); }
.sdsym { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--sym); stroke-width: 2.2; stroke-linecap: round; transition: transform 0.15s ease-out; }
.sdsym.live { width: 30px; height: 30px; stroke-width: 2; margin: 0 2px; }
.sdsym.idle { stroke: var(--rule-strong); }
.meas-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 6px; }
.meas-grid label { display: block; padding: 0 8px; border-left: 1px solid var(--rule); }
.meas-grid label:first-child { border-left: 0; padding-left: 0; }
.meas-grid label:last-child { padding-right: 0; }
.meas-grid span { display: block; text-align: center; font-size: 12px; font-weight: 500; color: var(--text-3); }
.meas-grid input { text-align: center; font-family: var(--mono); font-size: 26px; padding: 4px 0; min-height: 48px; font-variant-numeric: tabular-nums; }

/* Samples */
.sample { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) 40px; gap: 12px; align-items: end; margin-top: 8px; }
.sample .icon-btn { width: 40px; height: 44px; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-grid:empty { display: none; }
.ph { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--raise-2); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph span { position: absolute; left: 6px; bottom: 6px; font-family: var(--mono); font-size: 12px; color: #fff; background: rgba(0, 0, 0, 0.62); padding: 1px 6px; border-radius: 6px; }
.ph.busy { display: grid; place-items: center; }

/* ---------- stations list ---------- */
.list-screen { gap: 6px; }
.proj { padding: 4px 0 10px; }
.proj h1 { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.proj-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.proj-top .btn { flex: none; margin-top: 2px; }
.proj-stats { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; color: var(--text-2); font-size: 14px; }
.proj-stats b { font-family: var(--mono); font-weight: 500; font-size: 19px; color: var(--text); margin-right: 4px; }

.st-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.st-list li { border-bottom: 1px solid var(--rule); }
.st-row { display: grid; grid-template-columns: 48px 50px 1fr auto; gap: 12px; align-items: center; padding: 11px 2px; }
.st-row:active { background: var(--raise); }
.st-num { font-family: var(--mono); font-size: 22px; font-weight: 400; color: var(--text); }
.st-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.st-lith { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-lith i { font-style: normal; font-weight: 400; color: var(--text-3); font-size: 14px; margin-left: 8px; }
.st-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 14px; color: var(--text-2); }
.st-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.st-meta .i { width: 16px; height: 16px; color: var(--text-3); }
.st-plane { font-family: var(--mono); color: var(--text); }
.st-meta .warn { color: var(--fair); }
.st-side { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-family: var(--mono); font-size: 14px; color: var(--text-2); }
.st-side small { font-family: var(--font); font-size: 12px; color: var(--text-3); }
.draft { font-style: normal; font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--accent-ink); background: var(--accent); padding: 0 7px; border-radius: 5px; margin-top: 3px; }

.empty { padding: 48px 20px; text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 18px; line-height: 1.7; }
.loading { display: grid; place-items: center; padding: 60px 0; }

/* ---------- map ---------- */
.view-map { overflow: hidden; }
.map-screen { position: absolute; inset: 0; }
.bigmap { position: absolute; inset: 0; }
.map-chip { left: 12px; top: 12px; }
.map-fabs { position: absolute; right: 12px; bottom: 26px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.fab { width: 50px; height: 50px; display: grid; place-items: center; border-radius: var(--r-lg); border: 1px solid var(--rule-strong); background: var(--bg); color: var(--text); box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.7); }
.fab:active { background: var(--raise-2); }
.fab.busy { border-color: var(--accent); color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }

.leaflet-container {
  font-family: var(--font);
  background-color: var(--raise);
  background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 40px 40px;
}
[data-mode='dark'] .leaflet-tile-pane { filter: brightness(0.74) saturate(0.85) contrast(1.05); }
.leaflet-container .leaflet-control-attribution { background: var(--chip); color: var(--text-3); font-size: 10px; padding: 1px 6px; border-top-left-radius: 6px; }
.leaflet-container .leaflet-control-attribution a { color: var(--text-2); }
.leaflet-container .leaflet-control-scale-line { background: var(--chip); border-color: var(--text-2); color: var(--text); font-family: var(--mono); font-size: 11px; text-shadow: none; }
.leaflet-control-scale { margin-left: 12px !important; margin-bottom: 14px !important; }
.me-dot { fill: var(--info); fill-opacity: 1; stroke: #ffffff; stroke-width: 2.5; }
.me-acc { fill: var(--info); fill-opacity: 0.14; stroke: var(--info); stroke-opacity: 0.55; stroke-width: 1; }

/* .st-icon must stay position:absolute (Leaflet's own rule) or markers stack in normal flow */
.st-icon .pt { position: absolute; left: 9px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--map-ink); border: 2px solid #000; }
.st-icon .sd { position: absolute; inset: 0; width: 30px; height: 30px; fill: none; stroke: var(--map-ink); stroke-width: 3; stroke-linecap: round; filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.95)); }
.st-icon .sd-dip { position: absolute; transform: translate(-50%, -50%); font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--map-ink); text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000; }
.st-icon .st-lbl { position: absolute; left: 31px; top: 6px; white-space: nowrap; font-family: var(--mono); font-size: 11px; color: #fff; background: rgba(0, 0, 0, 0.6); padding: 0 5px; border-radius: 5px; }
.geo-popup .leaflet-popup-content-wrapper { background: var(--bg); color: var(--text); border: 1px solid var(--rule-strong); border-radius: 12px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8); }
.geo-popup .leaflet-popup-tip { background: var(--bg); border: 1px solid var(--rule-strong); }
.geo-popup .leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.5; }
.pp { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.pp b { font-family: var(--mono); font-weight: 500; font-size: 16px; }
.pp .btn { margin-top: 8px; }

/* ---------- overlays ---------- */
#overlay { position: fixed; inset: 0; z-index: 2000; display: none; }
#overlay.open { display: block; }
.scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 90vh; overflow-y: auto;
  max-width: 620px; margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--rule-strong); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(16px + var(--safe-b));
  animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.5; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--rule-strong); margin: 0 auto 14px; }
.sheet h3 { margin: 0; font-size: 20px; font-weight: 600; }
.sheet-sub { color: var(--text-3); font-size: 14px; margin-top: 2px; }
.x-list { display: flex; flex-direction: column; margin: 14px 0; border-top: 1px solid var(--rule); }
.x-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 13px 4px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; }
.x-item b { font-size: 16px; font-weight: 600; }
.x-item span { font-size: 14px; color: var(--text-2); }
.x-item.main b::after { content: 'แนะนำ'; margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--accent-ink); background: var(--accent); padding: 1px 7px; border-radius: 5px; vertical-align: 2px; }
.x-item:active { background: var(--raise); }
.x-item[disabled] { opacity: 0.5; }
.x-item b { display: inline-flex; align-items: center; gap: 10px; }
.x-item.danger b { color: var(--bad); }
.x-ready { margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.x-busy { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.x-file { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-md); background: var(--raise); }
.x-file .i { color: var(--sym); width: 28px; height: 28px; }
.x-file b { display: block; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.x-file span { font-family: var(--mono); font-size: 13px; color: var(--text-3); }
.x-error { color: var(--bad); }

.full .lightbox { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column; padding-top: var(--safe-t); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--rule-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; z-index: 3000;
  top: calc(var(--safe-t) + 62px);
  transform: translate(-50%, -12px);
  max-width: calc(100vw - 32px); width: max-content;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 500; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- settings ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin-top: 6px; border: 1px solid var(--rule-strong); border-radius: var(--r-md); }
.seg button { min-height: 42px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-size: 15px; font-weight: 500; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.kv span { color: var(--text-2); }
.kv b { font-weight: 500; }
#storage .btn { margin-top: 12px; }
.about p + p { margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) {
  .minimap { max-height: 340px; }
}

/* ---------- v0.2: two GPS actions, lithology quick picks, projects ---------- */
.cta-2 { display: grid; grid-template-columns: 1fr 1.45fr; gap: 10px; }
.cta-2 .btn-primary { min-height: 60px; font-size: 16px; padding: 0 12px; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 60px; padding: 0 12px;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--rule-strong);
  background: var(--bg);
  font-size: 16px; font-weight: 600;
}
.btn-secondary:active { background: var(--raise-2); }
.btn-secondary.active { border-color: var(--accent); color: var(--accent); }
.btn-secondary[disabled] { opacity: 0.5; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips-label { width: 100%; font-size: 13px; color: var(--text-3); }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  min-height: 40px; padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  font-size: 15px; font-weight: 500;
}
.chip i { font-style: normal; font-weight: 400; font-size: 13px; color: var(--text-3); }
.chip[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed='true'] i { color: inherit; opacity: 0.75; }

.lead { font-size: 14px; color: var(--text-2); }
.pj-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.pj { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--rule); }
.pj-open { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 4px; border: 0; background: transparent; text-align: left; }
.pj-open:active { background: var(--raise); }
.pj-name { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.pj.current .pj-name { color: var(--text); }
.badge-cur { font-style: normal; font-size: 12px; font-weight: 500; color: var(--accent-ink); background: var(--accent); padding: 0 7px; border-radius: 5px; }
.pj-stats { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 14px; color: var(--text-2); }
.pj-stats b { font-family: var(--mono); font-weight: 500; color: var(--text); margin-right: 3px; }
.pj-meta { font-size: 13px; color: var(--text-3); }

.warn-text { font-size: 13px; color: var(--fair); margin-top: 8px; }
.sheet .btn-row .btn-primary { min-height: 46px; font-size: 15px; letter-spacing: 0.02em; }
.body { font-size: 15px; line-height: 1.6; margin-top: 8px; }
.steps { margin: 8px 0 0; padding-left: 22px; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.steps li + li { margin-top: 6px; }

/* ---------- v0.3: read-only station, swipe actions, export choices, summary image ---------- */
.hdr-btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 10px; margin-right: 2px; border-radius: 10px; color: var(--accent); font-size: 15px; font-weight: 600; }
.hdr-btn .i { width: 18px; height: 18px; }
[data-mode='light'] .hdr-btn { color: var(--text); }
.hdr-btn:active { background: var(--raise-2); }

.dt-hero { padding: 4px 0 16px; }
.dt-code { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 15px; color: var(--text-3); }
.dt-lith { margin: 4px 0 0; font-size: 26px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.dt-lith i { font-style: normal; font-weight: 400; font-size: 18px; color: var(--text-3); margin-left: 10px; }
.dt-time { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.dt-meas { list-style: none; margin: 8px 0 0; padding: 0; }
.dt-meas li { display: grid; grid-template-columns: 38px 1fr auto auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--rule); }
.dt-meas li:first-child { border-top: 0; }
.dt-mtype { font-size: 16px; font-weight: 500; }
.dt-mtype i { font-style: normal; font-weight: 400; font-size: 13px; color: var(--text-3); margin-left: 6px; }
.dt-plane { font-size: 22px; }
.dt-dd { font-size: 15px; color: var(--text-2); min-width: 64px; text-align: right; }
.dt-samples { list-style: none; margin: 8px 0 0; padding: 0; }
.dt-samples li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 9px 0; border-top: 1px solid var(--rule); }
.dt-samples li:first-child { border-top: 0; }
.dt-samples b { font-weight: 500; font-size: 17px; }
.dt-samples span { color: var(--text-2); font-size: 15px; }
.dt-notes { white-space: pre-wrap; font-size: 16px; line-height: 1.65; margin-top: 8px; }
.dt-edited { text-align: center; margin: 8px 0 0; }
.dt-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dt-nav .btn-secondary { min-height: 52px; font-family: var(--mono); font-weight: 500; font-size: 15px; }
.dt-nav .btn-secondary.next { justify-content: center; }
.dt-nav .btn-secondary.next .i { transform: rotate(180deg); }


.sw-item { position: relative; overflow: hidden; }
.sw-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.sw-actions button { width: 84px; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; }
.sw-edit { background: var(--raise-2); color: var(--text); }
.sw-del { background: var(--bad); color: #fff; }
.sw-front { position: relative; z-index: 1; background: var(--bg); transition: transform 0.22s ease; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.sw-item.dragging .sw-front { transition: none; }
.swipe-hint { text-align: center; margin-top: 12px; }
.summary-btn { width: 100%; margin-top: 14px; }

.x-h { display: flex; align-items: baseline; justify-content: space-between; margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.link-btn { border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; padding: 4px 0; }
[data-theme='sun'] .link-btn { color: var(--text); text-decoration: underline; }
.x-projects { display: flex; flex-direction: column; margin-top: 6px; border-top: 1px solid var(--rule); }
.x-proj { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.x-proj input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.x-check { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 7px; border: 1.5px solid var(--rule-strong); color: transparent; }
.x-check .i { width: 18px; height: 18px; stroke-width: 2.6; }
.x-proj input:checked + .x-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.x-proj input:focus-visible + .x-check { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.x-pname { display: flex; flex-direction: column; min-width: 0; }
.x-pname b { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.x-pname small { font-size: 13px; color: var(--text-3); }
.x-list { margin-top: 6px; }

.summary-screen { gap: 12px; }
.sum-preview { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--rule); background: var(--raise); min-height: 200px; display: grid; place-items: center; }
.sum-preview img { display: block; width: 100%; height: auto; }
.sum-preview.busy img { opacity: 0.45; }
.sum-preview.busy::after { content: ''; position: absolute; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--rule-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.sum-facts { font-size: 14px; color: var(--text-2); }
.summary-screen .field { margin-top: 4px; }

.route-halo { fill: none; stroke: #000; stroke-opacity: 0.75; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.route-line { fill: none; stroke: var(--map-ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- v0.4: sensor strike/dip, zero calibration, Smart Photo ---------- */
.meas-add { margin-top: 14px; }
.btn.sensor { border-color: var(--accent); color: var(--accent); }
[data-theme='sun'] .btn.sensor { border-color: var(--rule-strong); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.meas-top .icon-btn { width: 40px; flex: none; }
.meas-top .icon-btn[data-act='clino-row'] { color: var(--sym); }
.m-src { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.m-src .i { width: 15px; height: 15px; color: var(--sym); flex: none; }
.src-tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; font-style: normal; font-size: 11px; font-weight: 500; color: var(--sym); }
.src-tag .i { width: 13px; height: 13px; }

.full .clino {
  position: absolute; inset: 0; background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 6px) 16px calc(14px + var(--safe-b));
  overflow-y: auto;
}
.cl-head { display: flex; align-items: center; gap: 8px; margin-left: -8px; }
.cl-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cl-head b { font-size: 17px; font-weight: 600; }
.cl-head small { font-size: 12px; color: var(--text-3); }
.cl-count { font-family: var(--mono); font-size: 13px; color: var(--sym); }
.cl-types { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.cl-types::-webkit-scrollbar { display: none; }
.cl-types .chip { flex: none; }
.cl-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 0; padding: 8px 0; }
.cl-dial { width: min(70vw, 290px, 38vh); height: auto; flex: none; }
.cl-dial .ring { fill: var(--raise); stroke: var(--rule); stroke-width: 1; }
.cl-dial .tick { stroke: var(--text-3); stroke-width: 1; }
.cl-dial .tick.major { stroke: var(--text-2); stroke-width: 1.8; }
.cl-dial text { font-family: var(--mono); font-size: 12px; font-weight: 500; fill: var(--text-2); text-anchor: middle; dominant-baseline: central; }
.cl-dial text.n { fill: var(--sym); }
.cl-dial .north { fill: var(--sym); }
.cl-dial .sym line { stroke: var(--sym); stroke-width: 6; stroke-linecap: round; transition: stroke 0.2s; }
.cl-dial .sym.idle line { stroke: var(--rule-strong); }
.cl-dial .hub { fill: var(--text-2); }
.cl-dial .diplbl { font-size: 15px; font-weight: 600; fill: var(--text); }
.cl-read { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 420px; text-align: center; }
.cl-read div + div { border-left: 1px solid var(--rule); }
.cl-read span { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.cl-read b { display: block; font-family: var(--mono); font-size: 34px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; }
.clino.locked .cl-read b { color: var(--sym); }
.cl-note { font-size: 15px; color: var(--text-2); min-height: 1.4em; text-align: center; }
.cl-steady { width: 100%; max-width: 420px; }
.cl-steady .progress { margin-top: 0; height: 6px; border-radius: 3px; }
.clino.locked .cl-steady .progress i { background: var(--good); }
.cl-steady p { text-align: center; font-size: 15px; font-weight: 500; color: var(--text-2); margin-top: 8px; }
.clino.locked .cl-steady p { color: var(--good); }
.cl-warn { width: 100%; max-width: 420px; font-size: 13px; line-height: 1.5; color: var(--fair); text-align: center; }
.cl-actions { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.cl-actions:empty { display: none; }
.cl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cl-row:has(> :only-child) { grid-template-columns: 1fr; }
.cl-actions .btn-secondary { min-height: 54px; font-size: 15px; }
@media (max-height: 640px) {
  .cl-read b { font-size: 28px; }
  .cl-dial { width: min(60vw, 230px, 34vh); }
}

.cal-sheet .progress { margin-top: 16px; }
.cal-steps { margin: 14px 0 0; padding-left: 22px; font-size: 15px; line-height: 1.55; color: var(--text-3); }
.cal-steps li + li { margin-top: 8px; }
.cal-steps li.on { color: var(--text); font-weight: 500; }
.cal-steps li.done { color: var(--good); }
.cal-msg { margin-top: 10px; font-size: 15px; color: var(--text-2); min-height: 3em; }
.cal-msg b { color: var(--text); }
.cal-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin-top: 14px; }
.cal-actions .btn-primary { min-height: 48px; }

.btn-primary.sm { min-height: 38px; padding: 0 14px; font-size: 14px; letter-spacing: 0.02em; border-radius: 10px; gap: 6px; }
.btn-primary.sm .i { width: 18px; height: 18px; }

/* 6-figure grid reference first; easting/northing smaller underneath */
.ro-row.gr { min-height: 62px; }
.ro-row.gr dt small, .loc-rows .gr dt small { display: block; font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--sym); margin-top: 2px; letter-spacing: 0.02em; }
.ro-row.gr dd { font-size: 40px; font-weight: 500; letter-spacing: 0.03em; }
.ro-row.sub { min-height: 30px; padding: 0 2px 8px; border-top: 0; }
.ro-row.sub dt { font-size: 13px; color: var(--text-3); }
.ro-row.sub dd { font-size: 17px; color: var(--text-2); letter-spacing: 0; }
.loc-rows .gr dd { font-size: 30px; font-weight: 500; letter-spacing: 0.03em; }
.loc-rows > div.sub { border-top: 0; padding-top: 0; }
.loc-rows .sub dt { font-size: 12px; color: var(--text-3); }
.loc-rows .sub dd { font-size: 15px; color: var(--text-2); }
/* Lat/Long in full under UTM (GPS and Station screens) */
.ro-row.ll { grid-template-columns: auto 1fr; margin-top: -3px; }
.ro-row.ll dd { font-size: 15px; letter-spacing: 0; }
.loc-rows > div.ll { margin-top: -3px; }
.loc-rows .ll dd { font-size: 14px; }

/* ---------- v0.5: the GPS screen fits the screen and does not scroll ---------- */
main#view.view-gps { overflow: hidden; display: flex; flex-direction: column; }
.view-gps > .view-root { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-gps .gps-screen { flex: 1; min-height: 0; width: 100%; overflow: hidden; padding-top: 10px; padding-bottom: 4px; gap: 10px; }
.view-gps .minimap { flex: 1 1 0; height: auto; min-height: 72px; max-height: 340px; }
.view-gps .gps-screen > :not(.minimap) { flex: none; }
.view-gps .cta { position: static; flex: none; width: 100%; padding-top: 6px; background: var(--bg); }
.view-gps .banner { padding-top: 8px; padding-bottom: 8px; font-size: 13px; }
@media (max-height: 760px) {
  .view-gps .ro-row { min-height: 40px; padding-top: 3px; padding-bottom: 3px; }
  .view-gps .ro-row.gr { min-height: 52px; }
  .view-gps .ro-row.gr dd { font-size: 34px; }
  .view-gps .ro-row.sub { min-height: 24px; padding-bottom: 5px; }
  .view-gps .ro-row dd { font-size: 23px; }
  .view-gps .dial { width: 60px; height: 60px; }
  .view-gps .cmp-val { font-size: 26px; }
  .view-gps .cta-2 .btn-primary, .view-gps .cta-2 .btn-secondary { min-height: 52px; }
  .view-gps .fix-line { min-height: 18px; }
}
@media (max-height: 640px) {
  .view-gps .compass { display: none; }
}
@media (max-height: 700px) {
  .view-gps .gps-screen { gap: 8px; padding-top: 8px; }
  .view-gps .minimap { min-height: 56px; }
  .view-gps .banner { font-size: 12px; line-height: 1.4; padding-top: 6px; padding-bottom: 6px; }
  .view-gps .coord-head .pill, .view-gps .coord-head .pill-select { min-height: 32px; }
}
.view-gps .ro-row.sub dd { font-size: 16px; }
.view-gps .ro-row.gr dt small { font-size: 13px; }

/* ---------- v0.5: in-app camera with the Smart Photo details live ---------- */
.full .cam { position: absolute; inset: 0; background: #000; color: #fff; overflow: hidden; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: cam-flash 0.35s ease-out; }
@keyframes cam-flash { from { opacity: 0.85; } to { opacity: 0; } }
.cam-msg { position: absolute; left: 24px; right: 24px; top: 42%; text-align: center; font-size: 15px; line-height: 1.6; color: #ddd; }

.cam-top {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-t) + 8px) 12px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.35) 70%, transparent);
}
.cam-x { position: absolute; left: 8px; top: calc(var(--safe-t) + 6px); width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.45); color: #fff; display: grid; place-items: center; }
.cam-tape { position: relative; width: min(72vw, 320px); height: 38px; overflow: hidden; margin-top: 4px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent); }
.cam-tape-in { position: absolute; top: 0; left: 50%; height: 100%; will-change: transform; }
.cam-tape-in i { position: absolute; bottom: 0; width: 1.5px; height: 8px; background: rgba(255, 255, 255, 0.7); }
.cam-tape-in i.mj { height: 14px; background: #fff; }
.cam-tape-in b { position: absolute; top: 0; transform: translateX(-50%); font-family: var(--mono); font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, 0.85); }
.cam-tape-in b.card { color: #f5c933; font-size: 14px; font-weight: 600; }
.cam-tape-mk { position: absolute; left: 50%; bottom: 0; width: 0; height: 0; margin-left: -7px; border: 7px solid transparent; border-bottom: 10px solid #f5c933; }
.cam-brg { display: flex; flex-direction: column; align-items: center; line-height: 1.1; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
.cam-brg b { font-family: var(--mono); font-size: 38px; font-weight: 600; color: #f5c933; letter-spacing: 0.02em; }
.cam-brg span { font-size: 14px; color: rgba(255, 255, 255, 0.85); margin-top: 2px; }

.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 0 calc(var(--safe-b) + 14px); background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.55) 75%, transparent); }
.cam-strip { margin: 0 12px 12px; padding: 10px 12px; border-radius: 12px; background: rgba(11, 11, 11, 0.78); border-top: 3px solid #f5c933; }
.cam-strip p { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.cs-1 { font-size: 15px; font-weight: 600; }
.cs-1 em { font-style: normal; font-family: var(--mono); font-size: 11px; color: #f5c933; letter-spacing: 0.08em; }
.cs-1 b { font-family: var(--mono); font-weight: 500; }
.cs-2 { margin-top: 2px; font-size: 13px; color: #a9aca4; }
.cs-2 b { font-family: var(--mono); font-size: 22px; font-weight: 600; color: #f5c933; }
.cs-2 small { font-family: var(--mono); font-size: 13px; color: #a9aca4; }
.cs-2 .cs-m { font-family: var(--mono); color: #eee; }
.cam-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 18px; }
.cam-native { justify-self: start; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: #ddd; padding: 6px; }
.cam-native .i { width: 26px; height: 26px; }
.cam-shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; display: grid; }
.cam-shutter i { border-radius: 50%; background: #fff; }
.cam-shutter:active i { background: #f5c933; }
.cam-done {
  justify-self: end; position: relative;
  width: 64px; height: 64px; padding: 0; overflow: visible;
  border-radius: 14px; border: 2px solid #fff;
  background: rgba(30, 32, 33, 0.92); color: #fff;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
.cam-done img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; display: block; }
.cam-done b { position: absolute; top: -9px; right: -9px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: #f5c933; color: #1a1500; font-family: var(--mono); font-size: 13px; line-height: 24px; text-align: center; }
.cam-done.pop { animation: cam-pop 0.3s ease-out; }
@keyframes cam-pop { 0% { transform: scale(0.82); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
/* toasts sit mid-screen while the camera is open, clear of the compass */
body:has(#overlay .cam) #toast { top: 42%; }

/* bottom sheets: pull down to close, close button on top, the page behind never scrolls */
#overlay.open { touch-action: none; overscroll-behavior: none; }
.sheet { touch-action: pan-y; overscroll-behavior: contain; padding-top: 10px; }
.sheet-x { position: sticky; top: 0; float: right; z-index: 2; width: 40px; height: 40px; margin: -4px -6px 0 0; border: 0; border-radius: 50%; background: var(--raise-2); color: var(--text); display: grid; place-items: center; }
.sheet-x .i { width: 20px; height: 20px; }
.sheet-grip { width: 48px; height: 5px; margin-bottom: 16px; cursor: grab; }
body:has(#overlay.open) main#view { overflow: hidden; }

/* ---------- v0.6: map pins coloured by rock, rock names, legend ---------- */
.st-icon .rk { position: absolute; left: 7px; top: 7px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #000; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85); }
.st-icon .sd { z-index: 1; }
.st-icon .st-lbl { line-height: 1.25; padding: 1px 5px 2px; }
.st-icon .st-lbl small { display: block; font-family: var(--font); font-size: 10px; color: #d8d8d0; }
.map-legend {
  position: absolute; left: 10px; top: 58px; z-index: 1000;
  max-width: min(72vw, 300px); max-height: 46%; overflow: auto;
  border-radius: 12px; background: var(--chip); border: 1px solid var(--rule);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: 13px; overscroll-behavior: contain;
}
.map-legend .lg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 7px 12px; border: 0; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; text-align: left; }
.map-legend .lg-head span { font-family: var(--mono); font-size: 16px; color: var(--text-2); }
.map-legend ul { list-style: none; margin: 0; padding: 0 10px 8px 12px; }
.map-legend li { display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: start; padding: 4px 0; border-top: 1px solid var(--rule); }
.map-legend li i { width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; border: 2px solid #000; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7); }
.map-legend li b { font-weight: 600; }
.map-legend li small { display: block; color: var(--text-3); font-size: 11px; line-height: 1.35; }
.map-legend li em { font-style: normal; font-family: var(--mono); color: var(--text-3); font-size: 12px; }

/* ---------- v0.7: full-screen viewer like Photos (swipe sideways, pull down to close, tap for the bar) ---------- */
.full .lightbox { --lb-bg: 1; display: block; padding: 0; background: rgba(0, 0, 0, var(--lb-bg)); }
.full:has(.lightbox) .scrim { background: transparent; }
.lightbox .lb-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lb-track { position: absolute; inset: 0; will-change: transform; }
.lb-slide { position: absolute; inset: 0; }
.lightbox .lb-slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 0.18s ease-out; transform-origin: 50% 50%; pointer-events: none; -webkit-user-drag: none; }
.lb-slide.ready img { opacity: 1; }
.lb-wait { position: absolute; left: 0; right: 0; top: 50%; margin-top: -10px; text-align: center; font-size: 13px; color: rgba(255, 255, 255, 0.5); opacity: 0; animation: lb-wait 0.25s 0.6s forwards; pointer-events: none; }
.lb-slide.ready .lb-wait, .lb-slide.empty .lb-wait { display: none; }
@keyframes lb-wait { to { opacity: 1; } }
.lightbox .lb-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 10px;
  padding: 36px 14px calc(12px + var(--safe-b));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.35) 55%, transparent);
  transition: opacity 0.2s, transform 0.2s;
}
.lightbox.ui-off .lb-bar, .lightbox.dragging .lb-bar { opacity: 0; transform: translateY(10px); pointer-events: none; }
.lightbox .lb-info { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 0; min-width: 0; text-align: center; }
.lightbox .lb-title { flex: none; font-family: var(--mono); font-size: 14px; color: #fff; }
.lightbox .lb-brg { max-width: 100%; min-height: 0; font-size: 12px; color: rgba(255, 255, 255, 0.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-ic { width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(40, 40, 40, 0.55); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.lb-ic .i { width: 21px; height: 21px; }
.lb-ic[disabled] { opacity: 0.35; }
.lb-ic.danger { color: #ff8a7a; }
.lb-ic:active { background: rgba(80, 80, 80, 0.7); }
body:has(#overlay .lightbox) #toast { top: calc(var(--safe-t) + 16px); bottom: auto; }

/* station list: first photo in front of the number */
.st-thumb { position: relative; width: 48px; height: 48px; border-radius: 9px; overflow: hidden; background: var(--raise); display: grid; place-items: center; color: var(--text-3); }
.st-thumb .i { width: 20px; height: 20px; opacity: 0.6; }
.st-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.2s; }
.st-thumb.ready img { opacity: 1; }
.st-row .st-num { font-size: 20px; }

/* map labels: station, 6-figure grid reference, rock */
.st-icon .st-lbl .gr { display: block; font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: #f5c933; letter-spacing: 0.02em; }

/* map / satellite switch */
.base-btn { flex: none; align-self: center; width: 66px; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 5px 4px; border-radius: 12px; border: 1px solid var(--rule-strong); background: var(--raise); color: var(--text); font-size: 11px; font-weight: 600; }
.base-btn .i { width: 22px; height: 22px; }
.base-btn span { white-space: nowrap; }
.base-btn + .base-btn { margin-left: -6px; }
#btnCmp { border-color: var(--accent); color: var(--accent); }
.base-btn:active { background: var(--raise-2); }
.base-btn.on { border-color: var(--accent); }
/* Map buttons with a word under the icon (หน่วยหิน, แผนที่/ดาวเทียม/ออฟไลน์): a little larger
   than the icon-only ones, icon and word centred with room above and below */
.fab-base, .fab-geol { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 60px; height: auto; min-height: 60px; padding: 8px 3px 7px; }
.fab-base .i, .fab-geol .i { width: 23px; height: 23px; }
.fab-base span, .fab-geol span { font-size: 11px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.map-fabs .fab:not(.fab-base):not(.fab-geol) { width: 60px; }
.fab-base.on { border-color: var(--accent); }
.is-sat .leaflet-control-attribution { max-width: calc(100% - 8px); white-space: normal; line-height: 1.3; }
@media (max-height: 700px) { .view-gps .base-btn { min-height: 46px; width: 60px; } }

/* rock units layer (v0.9) */
.fab-geol.on { border-color: var(--accent); color: var(--accent); }
.geol-dl { position: absolute; left: 50%; transform: translateX(-50%); bottom: 26px; z-index: 1000; display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--bg); color: var(--text); font-size: 13px; box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.7); max-width: calc(100% - 150px); white-space: nowrap; }
.geol-dl svg { width: 16px; height: 16px; flex: none; }
.geol-dl.busy { border-color: var(--accent); color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.geol-sw { display: inline-block; width: 11px; height: 11px; margin-right: 6px; border-radius: 3px; border: 1px solid #000; vertical-align: -1px; }
.geol-src { display: block; margin-top: 4px; opacity: 0.7; font-size: 10px; }
.geol-rock { font-size: 12px; opacity: 0.85; }
.geol-hint { margin: 6px 0 2px; font-size: 13px; color: var(--text-2); }
.geol-hint b { color: var(--text); }
.x-item.base-opt[aria-pressed="true"] { border-color: var(--accent); }
.x-item.base-opt b .i, .x-item.base-opt b svg { width: 18px; height: 18px; vertical-align: -3px; }
.is-offline { background: var(--offline-bg, #e2dfda) !important; }

/* offline data by region (Settings) */
.reg-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name btns" "state btns"; gap: 2px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--rule); }
.reg-row:first-child { border-top: 0; }
.reg-name { grid-area: name; display: flex; flex-direction: column; }
.reg-name small { color: var(--text-3); font-size: 12px; }
.reg-state { grid-area: state; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-3); }
.reg-state .ok { color: var(--text); }
.reg-state .ok::before { content: '✓ '; color: var(--accent); }
.reg-btns { grid-area: btns; display: flex; gap: 6px; }
.reg-btns .btn { white-space: nowrap; }

/* theme picker (Settings → ธีมสี): each card draws a small app screen in its own theme */
.theme-group { margin: 12px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.theme-group:first-of-type { margin-top: 6px; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.theme-card { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 7px 7px 10px; border: 1.5px solid var(--rule); border-radius: var(--r-lg); background: var(--raise); text-align: left; min-width: 0; }
.theme-card[aria-checked='true'] { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); }
.tp {
  position: relative; display: block; height: 96px; border-radius: 9px; overflow: hidden;
  background-color: var(--bg); background-image: var(--paper-img); background-size: var(--paper-size); background-position: var(--paper-pos);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.tp i { position: absolute; display: block; }
.tp .tp-bar { left: 0; right: 0; top: 0; height: 19px; background: var(--bar); border-bottom: var(--bar-edge); }
.tp .tp-bar::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: calc(var(--bar-band-h) * 0.7); background: var(--bar-band); }
.tp .tp-bar i { left: 50%; top: 7px; width: 30px; height: 5px; border-radius: 3px; background: var(--text); transform: translateX(-50%); }
.tp .tp-l1 { left: 10px; top: 32px; width: 58%; height: 5px; border-radius: 3px; background: var(--text); }
.tp .tp-l2 { left: 10px; top: 42px; width: 36%; height: 4px; border-radius: 2px; background: var(--text-3); }
.tp .tp-btn { left: 10px; right: 10px; top: 54px; height: 16px; border-radius: 6px; background: var(--accent-fill); }
.tp .tp-tab { left: 0; right: 0; bottom: 0; height: 17px; display: flex; align-items: center; justify-content: space-around; background: var(--tab-bg); border-top: var(--tab-edge); }
.tp .tp-tab i { position: static; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); opacity: 0.6; }
.tp .tp-tab i.on { background: var(--tab-on); opacity: 1; }
.theme-card b { display: flex; align-items: baseline; gap: 6px; margin-top: 3px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.theme-card b small { font-size: 11px; font-weight: 500; color: var(--text-3); }
.theme-desc { font-size: 12px; line-height: 1.35; color: var(--text-3); }

/* loading screen (index.html #splash): about 3 s once per launch, tap to skip */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 24px calc(28px + var(--safe-b));
  background: var(--bg); color: var(--text); overflow: hidden;
  transition: opacity 0.45s ease, visibility 0.45s;
}
.no-splash #splash, #splash.gone { display: none; }
#splash.out { opacity: 0; visibility: hidden; }
.sp-lines { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46%; fill: none; stroke: var(--rule); stroke-width: 1.4; opacity: 0.9; }
.sp-lines path:nth-child(2) { stroke: color-mix(in srgb, var(--accent) 22%, var(--rule)); }
.sp-center { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; margin-top: -6vh; }
.sp-icon {
  width: 132px; height: 132px; border-radius: 30px; margin-bottom: 18px;
  box-shadow: 0 18px 40px -18px rgba(23, 43, 58, 0.45), 0 0 0 1px rgba(23, 43, 58, 0.05);
  animation: sp-rise 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.sp-name { font-size: 34px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.15; animation: sp-fade 0.6s 0.25s ease both; }
.sp-tag { font-size: 15px; color: var(--text-3); letter-spacing: 0.02em; animation: sp-fade 0.6s 0.4s ease both; }
.sp-foot { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(220px, 60vw); font-size: 12px; color: var(--text-3); animation: sp-fade 0.6s 0.5s ease both; }
.sp-bar { width: 100%; height: 3px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.sp-bar i { display: block; height: 100%; width: 100%; border-radius: 2px; background: var(--accent); transform-origin: left center; animation: sp-fill 2.9s cubic-bezier(0.4, 0.1, 0.3, 1) both; }
@keyframes sp-rise { from { opacity: 0; transform: translateY(14px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes sp-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sp-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .sp-icon, .sp-name, .sp-tag, .sp-foot { animation: none; }
  .sp-bar i { animation-duration: 2.9s; animation-timing-function: linear; }
}
.summary-screen .seg[data-k='background'] button { font-size: 14px; padding: 0 2px; }

/* cross section (v1.4): the picture is white paper in every theme, like a printed figure */
.xsec-screen { gap: 10px; }
.xs-box { position: relative; border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; background: #ffffff; min-height: 120px; }
.xs-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.xs-scroll canvas { display: block; max-width: none; }
.xs-box.busy canvas { opacity: 0.5; }
.xs-box.busy::after { content: ''; position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; border: 3px solid var(--rule-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.xs-status { font-size: 13px; line-height: 1.55; color: var(--text-2); }
.xs-status .i { display: inline-block; width: 16px; height: 16px; margin-right: 2px; vertical-align: -3px; color: var(--good); }
.xs-status.warn { color: var(--fair); }
.xs-status .spinner { width: 14px; height: 14px; vertical-align: -2px; }
.xs-status .link-btn { padding: 0 2px; font-size: 13px; }
.xs-tip { display: block; color: var(--text-3); }
.seg[data-k='depth'] { display: flex; }
.seg[data-k='depth'] button { flex: 1 1 0; min-width: 0; padding: 0 2px; }
.seg[data-k='depth'] button:first-child { flex-grow: 2.2; }
.xs-notes:empty { display: none; }
.xs-notes p { margin-top: 6px; padding: 8px 10px; border-left: 3px solid var(--fair); border-radius: 0 8px 8px 0; background: var(--raise); font-size: 13px; line-height: 1.5; color: var(--text-2); }
input[type='range'] { width: 100%; height: 32px; margin: 0; accent-color: var(--accent); }
.xsec-screen .field { margin-top: 2px; }
.xs-ve { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.xs-ve .chip { flex: none; }
.xs-ve input[type='range'] { flex: 1; min-width: 0; }
.xs-ve b { min-width: 46px; text-align: right; font-size: 16px; font-weight: 500; }
.xs-sec { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--rule); }
.xs-rocks, .xs-list { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.xs-rock, .xs-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--text); text-align: left; }
.xs-rock:active, .xs-row:active { background: var(--raise); }
.xs-rock span { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.xs-rock span i { margin-left: 4px; font-style: normal; font-weight: 400; color: var(--text-3); }
.xs-rock small { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.xs-sw { flex: none; width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, 0.35); }
.xs-row .xs-sw { width: 14px; height: 14px; border-radius: 4px; }
.xs-code { flex: none; min-width: 62px; font-family: var(--mono); font-size: 14px; font-weight: 500; }
.xs-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.xs-body b { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.xs-body small { font-size: 12px; color: var(--text-3); }
.xs-tag { flex: none; max-width: 36%; padding: 1px 6px; border: 1px solid currentColor; border-radius: 6px; font-style: normal; font-size: 11px; line-height: 1.4; text-align: center; color: var(--accent); }
.xs-row.off { opacity: 0.6; }
.xs-row.off .xs-body b { text-decoration: line-through; }
.xs-row[disabled] { opacity: 0.45; }
.xs-sheet h3 { font-family: var(--mono); }
.xs-sheet .field { margin-top: 16px; }
.xs-toggle { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.xs-toggle input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.xs-toggle span { display: flex; flex-direction: column; gap: 2px; }
.xs-toggle b { font-size: 15px; font-weight: 600; }
.xs-toggle small { font-size: 13px; line-height: 1.45; color: var(--text-3); }
.xs-colors { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 12px; margin-top: 8px; }
.xs-pick { position: relative; width: 48px; height: 48px; border: 1px solid var(--rule-strong); border-radius: 12px; overflow: hidden; }
.xs-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.xs-pick i { position: absolute; inset: 4px; border-radius: 8px; pointer-events: none; }
.xs-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.xs-swb { width: 30px; height: 30px; padding: 0; border: 1px solid rgba(0, 0, 0, 0.3); border-radius: 50%; }
.xs-cbtns { grid-column: 1 / -1; display: flex; gap: 8px; }
.xs-att { margin-top: 8px; }
.xs-contact input[type='range'] { margin-top: 4px; }
.xs-ends { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.btn-row.one { grid-template-columns: 1fr; }
.view-section .cta { padding-bottom: calc(14px + var(--safe-b)); }
.proj-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.proj-btns .btn { padding: 0 10px; }
.dem-box { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; padding: 12px; border: 1px solid var(--rule); border-radius: var(--r-md); }
.dem-box b { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.dem-box b .i { width: 20px; height: 20px; flex: none; }
.dem-box span { font-size: 13px; line-height: 1.5; color: var(--text-2); }
.dem-box .btn { margin-top: 6px; }
.xs-sw-h { grid-column: 1 / -1; margin: 2px 0 -4px; font-size: 12px; color: var(--text-3); }
.xs-dmr { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.xs-dmrb { min-width: 46px; height: 30px; padding: 0 6px; border: 1px solid rgba(0, 0, 0, 0.3); border-radius: 7px; font-family: var(--mono); font-size: 12px; font-weight: 500; }

/* point symbols (js/pointtype.js): square = station, circle = check point, triangle = first/last */
.pt-shape, .st-icon svg.rk { overflow: visible; }
.pt-shape .halo, .st-icon svg.rk .halo { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 5; stroke-linejoin: round; }
.pt-shape .body, .st-icon svg.rk .body { stroke: #000; stroke-width: 2; stroke-linejoin: round; }
.st-icon svg.rk { position: absolute; left: 0; top: 0; width: 30px; height: 30px; border: 0; border-radius: 0; box-shadow: none; }
.pt-shape { display: inline-block; flex: none; width: 18px; height: 18px; vertical-align: -4px; }
.pt-shape.sm { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; }
.pt-shape .halo { stroke-width: 4; }
.kind-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 2px; padding: 0 4px; font-size: 14px; }
.kind-seg button .pt-shape { margin-right: 4px; }
.kind-tag { display: inline-flex; align-items: center; margin-left: 10px; font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--text-2); }
.kind-tag small { margin-left: 6px; font-size: 11px; color: var(--text-3); }
.st-lith .st-shape { display: inline-flex; vertical-align: -2px; }
.map-legend .lg-kinds { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; padding: 6px 12px 9px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--text-2); }
.map-legend .lg-kinds span { display: inline-flex; align-items: center; }
.pp .pp-kind { font-family: var(--font); font-size: 12px; font-weight: 500; color: #666; margin-left: 4px; }
.xs-row .xs-pt { width: 18px; height: 18px; }

/* v1.5 cross section: the picture is an example, not an interpretation; the part each rock plays */
.xs-disclaimer { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 6px; padding: 9px 11px; border: 1px solid color-mix(in srgb, var(--fair) 50%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--fair) 8%, transparent); font-size: 13px; line-height: 1.5; color: var(--text-2); }
.xs-disclaimer .i { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--fair); }
.xs-rock .xs-role { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid currentColor; border-radius: 6px; font-style: normal; font-size: 11px; font-weight: 500; line-height: 1.5; color: var(--accent); vertical-align: 1px; }

/* =====================================================================================
   v1.6 — smoother and easier to use
   ===================================================================================== */

/* screen changes (js/app.js animated()): the screen area moves, header and tab bar stay */
@supports (view-transition-name: none) {
  main#view { view-transition-name: screen; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  ::view-transition-group(screen) { animation: none; }
  ::view-transition-old(screen) { animation: vt-fade-out 0.14s ease-in both; }
  ::view-transition-new(screen) { animation: vt-fade-in 0.18s ease-out both; }
  html[data-nav='in'] ::view-transition-new(screen) { animation: vt-from-right 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  html[data-nav='out'] ::view-transition-old(screen) { animation: vt-to-right 0.2s ease-in both; }
  html[data-nav='out'] ::view-transition-new(screen) { animation: vt-fade-in 0.16s ease-out both; }
}
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
@keyframes vt-from-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes vt-to-right { to { opacity: 0; transform: translateX(28px); } }

/* sheets slide up over a darkening screen; buttons give way a little when pressed */
.scrim { animation: scrim-in 0.2s ease-out; }
@keyframes scrim-in { from { opacity: 0; } }
.sheet { animation: sheet-up 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes sheet-up { from { transform: translateY(100%); } }
.btn, .seg button, .x-item, .theme-card, .st-chip, .icon-btn { transition: transform 0.08s ease-out, background-color 0.12s; }
.btn:active, .seg button:active, .theme-card:active, .st-chip:active { transform: scale(0.97); }
.icon-btn:active { transform: scale(0.92); }

/* asking before deleting (ui.js confirmSheet) — above any open sheet */
#confirm { position: fixed; inset: 0; z-index: 2500; display: none; }
#confirm.open { display: grid; place-items: end center; }
.cf-box {
  position: relative; width: min(calc(100% - 24px), 460px);
  margin-bottom: calc(12px + var(--safe-b)); padding: 18px 16px 14px;
  background: var(--bg); border: 1px solid var(--rule-strong); border-radius: 20px;
  box-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.55);
  animation: cf-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cf-in { from { opacity: 0; transform: translateY(24px); } }
.cf-head { font-size: 17px; font-weight: 600; line-height: 1.45; }
.cf-body { margin-top: 6px; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.cf-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.cf-btns .btn { min-height: 48px; }
.cf-danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.cf-ok { background: var(--accent-fill); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
@media (min-width: 700px) { #confirm.open { place-items: center; } .cf-box { margin-bottom: 0; } }

/* a new version is ready (js/app.js showUpdateBar) */
#updBar {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 74px); z-index: 2800;
  display: flex; align-items: center; gap: 4px; width: max-content; max-width: calc(100vw - 24px);
  padding: 4px 4px 4px 14px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%); animation: upd-in 0.25s ease-out;
}
@keyframes upd-in { from { opacity: 0; transform: translate(-50%, 12px); } }
#updBar .upd-go { min-height: 40px; margin-left: 6px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent-fill); color: var(--accent-ink); font-weight: 600; }
#updBar .upd-x { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; color: inherit; }
#updBar .upd-x .i { width: 18px; height: 18px; }

/* messages sit above the buttons at the bottom, clear of the header */
#toast { top: auto; bottom: calc(var(--safe-b) + 150px); transform: translate(-50%, 12px); }
#toast.show { transform: translate(-50%, 0); }
.tabbar.hide ~ #toast, body:has(.tabbar.hide) #toast { bottom: calc(var(--safe-b) + 96px); }
body:has(#overlay .cam) #toast { bottom: auto; }
body:has(#overlay.open .sheet) #toast { top: calc(var(--safe-t) + 16px); bottom: auto; }

/* things to tap are at least about 44 px */
.pill, .pill-select { min-height: 44px; }
.pill-select select { min-height: 42px; }
@media (max-height: 700px) { .view-gps .coord-head .pill, .view-gps .coord-head .pill-select { min-height: 40px; } .view-gps .pill-select select { min-height: 38px; } }
.map-legend .lg-head { min-height: 44px; }
a.brand { min-height: 44px; justify-content: center; }
.seg button { min-height: 44px; }
.btn.sm, .link-btn, .st-chip, .chip, .info-btn, .btn-text { position: relative; }
.btn.sm::after, .chip::after, .btn-text::after { content: ''; position: absolute; inset: -4px -2px; }
.info-btn::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; }
.link-btn::after { content: ''; position: absolute; inset: -12px -6px; }
.st-chip::after { content: ''; position: absolute; inset: -3px -2px; }

/* station form: one line under "point type", the rule behind ⓘ */
#kindHint { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.info-btn { width: 40px; height: 40px; margin: -10px 0 -10px -4px; display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); }
.info-btn .i { width: 18px; height: 18px; }
.info-btn[aria-expanded='true'] { color: var(--accent); }
.kind-more { flex-basis: 100%; margin-top: 4px; }

/* stations list: grouped by day, rock tiles, chips to show one rock */
.st-list li.st-day {
  position: sticky; top: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 2px 6px; background: var(--bg);
  font-size: 14px; font-weight: 600; color: var(--text-2);
}
.st-list li.st-day small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.st-list li.sw-item { content-visibility: auto; contain-intrinsic-size: auto 72px; }
.st-thumb.none { background: color-mix(in srgb, var(--rk, var(--raise)) 22%, var(--raise)); }
.st-thumb .pt-shape.tile { width: 26px; height: 26px; }
.st-chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 4px 16px 8px; scrollbar-width: none; }
.st-chips::-webkit-scrollbar { display: none; }
.st-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 20px; background: transparent; font-size: 14px; font-weight: 500; white-space: nowrap; }
.st-chip i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #000; }
.st-chip small { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.st-chip[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.st-chip[aria-pressed='true'] small { color: inherit; opacity: 0.75; }

/* map: labels follow the zoom (js/map.js), and overlapping ones are hidden */
.lbl-z0 .st-icon .st-lbl { display: none; }
.lbl-z1 .st-icon .st-lbl .gr, .lbl-z1 .st-icon .st-lbl small { display: none; }
.st-icon.lbl-off .st-lbl { visibility: hidden; }
.map-legend { max-height: 40%; }

/* settings: problem report */
.err-box { margin-top: 10px; }
.err-box .btn-row { margin-top: 8px; }

/* loading screen: about 2 s */
.sp-bar i { animation-duration: 1.95s; }
#splash { transition-duration: 0.32s; }

/* phone turned sideways: everything scrolls, bars get thinner */
@media (orientation: landscape) and (max-height: 500px) {
  .topbar { min-height: 44px; padding-top: calc(var(--safe-t) + 0px); padding-bottom: 0; }
  .brand b { font-size: 16px; }
  .tab { min-height: 44px; flex-direction: row; gap: 6px; font-size: 13px; }
  .tab .i { width: 20px; height: 20px; }
  main#view.view-gps { overflow-y: auto; display: block; }
  .view-gps > .view-root, .view-gps .gps-screen { display: flex; overflow: visible; }
  .view-gps .minimap { flex: none; height: 150px; min-height: 0; }
  .view-gps .compass { display: none; }
  .cta, .view-gps .cta { position: static; padding-top: 10px; padding-bottom: 10px; background: none; }
  .btn-primary.xl { min-height: 50px; }
  .screen { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .sheet { max-height: 94vh; }
  #toast { bottom: calc(var(--safe-b) + 60px); }
  body:has(.tabbar.hide) #toast { bottom: calc(var(--safe-b) + 20px); }
}

/* =====================================================================================
   v1.7 — six themes, and who made the app
   ===================================================================================== */
.theme-grid.nine { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.theme-grid.nine .theme-card { padding: 6px 6px 8px; }
.theme-grid.nine .theme-card b { justify-content: center; margin-top: 4px; font-size: 14px; }
#themeDesc { margin-top: 8px; }

/* Settings opens with the app and its author */
.about-card { margin: 4px 0 10px; padding: 16px; border: 1px solid var(--rule); border-radius: 18px; background: var(--raise); }
.about-card .ac-app { display: flex; align-items: center; gap: 14px; }
.about-card .ac-app img { flex: none; width: 60px; height: 60px; border-radius: 14px; }
.about-card .ac-name { font-size: 22px; font-weight: 600; line-height: 1.2; }
.about-card .ac-name span { margin-left: 4px; font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--text-3); }
.about-card .ac-tag { font-size: 14px; color: var(--text-2); }
.about-card .ac-dev { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); }
.about-card .ac-by { font-size: 12px; letter-spacing: 0.04em; color: var(--text-3); }
.about-card .ac-who { margin-top: 1px; font-size: 17px; font-weight: 600; }
.about-card .ac-star { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-size: 13px; font-weight: 500; color: var(--sym); white-space: nowrap; }
.about-card .ac-star .star, .sp-sign svg { width: 13px; height: 13px; fill: currentColor; }
.about-card .ac-aff { margin-top: 2px; font-size: 13.5px; line-height: 1.55; color: var(--text-2); }

/* the loading screen is signed */
.sp-sign { display: inline-flex; align-items: center; gap: 4px; margin-top: -4px; font-size: 12px; letter-spacing: 0.03em; color: var(--sym); }

/* =====================================================================================
   v1.7 themes with their own backgrounds: Field book, Topo map, Leather journal (kept by North),
   and Mist, Rose granite, Survey, Northstar (new samples, waiting for approval)
   ===================================================================================== */

/* headings take the theme's typeface; buttons inside headings keep the normal one */
.sec-h, .proj h1, .sheet h3, .dt-lith, .about-card .ac-name { font-family: var(--display); font-weight: var(--display-w); }
.sec-h .btn { font-family: var(--font); font-weight: 500; }
.ro-row dd, .loc-rows dd, .hdr-st b, .st-num, .cl-read b { text-shadow: var(--num-glow); }

/* สมุดสนาม: the yellow all-weather geological field book: yellow cover around grid paper,
   red pen for symbols, highlighter yellow for marks, handwritten headings */
[data-theme='fieldbook'] {
  --bg: #fbf8ec;
  --raise: #f3edd6;
  --raise-2: #e9e1c3;
  --rule: #ddd3b0;
  --rule-strong: #6e6648;
  --text: #1c1a14;
  --text-2: #48432f;
  --text-3: #6a634b;
  --accent: #1c1a14;
  --accent-ink: #f6d33c;
  --accent-soft: rgba(246, 211, 60, 0.4);
  --sym: #b2311b;
  --good: #2c6e35;
  --fair: #8f5c00;
  --bad: #b2311b;
  --info: #1f5b93;
  --chip: rgba(251, 248, 236, 0.94);
  --focus: #1c1a14;
  --tab-on: #1c1a14;
  --btn-edge: transparent;
  --bar: #f6d33c;
  --bar-edge: 0 solid transparent;
  --bar-band: linear-gradient(rgba(70, 56, 8, 0.22), transparent);
  --bar-band-h: 5px;
  --bar-text: #1c1a14;
  --bar-text-2: #3d3412;
  --bar-text-3: #4a3f12;
  --bar-press: rgba(0, 0, 0, 0.08);
  --tab-edge: 0 solid transparent;
  --paper-img: linear-gradient(rgba(52, 120, 128, 0.26) 1px, transparent 1px), linear-gradient(90deg, rgba(52, 120, 128, 0.26) 1px, transparent 1px), linear-gradient(rgba(52, 120, 128, 0.12) 1px, transparent 1px), linear-gradient(90deg, rgba(52, 120, 128, 0.12) 1px, transparent 1px);
  --paper-size: 95px 95px, 95px 95px, 19px 19px, 19px 19px;
  --display: 'Itim', 'IBM Plex Sans Thai', sans-serif;
  --display-w: 400;
  color-scheme: light;
}

/* แผนที่ภูมิประเทศ: map paper with brown contour lines, a black-and-white map-frame border,
   woodland green for buttons and water blue for information */
[data-theme='contour'] {
  --bg: #f7f5ee;
  --raise: #edebe2;
  --raise-2: #e2dfd3;
  --rule: #d7d3c5;
  --rule-strong: #77736a;
  --text: #1d1d1b;
  --text-2: #46453f;
  --text-3: #66645c;
  --accent: #2d6a3e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(128, 178, 110, 0.26);
  --sym: #9a4f17;
  --good: #2d6a3e;
  --fair: #9c6008;
  --bad: #c0362c;
  --info: #1e6fa8;
  --chip: rgba(247, 245, 238, 0.94);
  --focus: #1d1d1b;
  --tab-on: #2d6a3e;
  --btn-edge: transparent;
  --bar: #f7f5ee;
  --bar-edge: 1px solid #1d1d1b;
  --bar-band: linear-gradient(#1d1d1b, #1d1d1b) 0 100% / 100% 1px no-repeat, repeating-linear-gradient(90deg, #1d1d1b 0 24px, #f7f5ee 24px 48px);
  --bar-band-h: 6px;
  --tab-bg: linear-gradient(#1d1d1b, #1d1d1b) 0 5px / 100% 1px no-repeat, repeating-linear-gradient(90deg, #1d1d1b 0 24px, #f7f5ee 24px 48px) 0 0 / 100% 5px no-repeat, #f7f5ee;
  --tab-edge: 1px solid #1d1d1b;
  --paper-img: url(../img/tex-contour.svg);
  --paper-size: 520px 520px;
  color-scheme: light;
}


/* สมุดปกหนัง: a stitched leather cover with gold-foil tabs around ruled cream pages,
   fountain-pen blue for symbols, handwritten headings */
[data-theme='leather'] {
  --bg: #f6f0e2;
  --raise: #eee5d1;
  --raise-2: #e3d7bd;
  --rule: #dacdb2;
  --rule-strong: #7a6852;
  --text: #2a2017;
  --text-2: #54473a;
  --text-3: #6e6053;
  --accent: #6a4327;
  --accent-ink: #fbf3e3;
  --accent-soft: rgba(106, 67, 39, 0.12);
  --sym: #23467a;
  --good: #3b6b33;
  --fair: #8f5d00;
  --bad: #a3321f;
  --info: #23467a;
  --chip: rgba(246, 240, 226, 0.94);
  --focus: #6a4327;
  --tab-on: #f0cf8a;
  --btn-edge: transparent;
  --bar: repeating-linear-gradient(90deg, rgba(236, 208, 160, 0.72) 0 7px, transparent 7px 12px) 0 calc(100% - 5px) / 100% 1.5px no-repeat, url(../img/tex-leather.svg), linear-gradient(#664329, #573822);
  --bar-edge: 1px solid #3a2414;
  --bar-band: linear-gradient(rgba(58, 36, 20, 0.28), transparent);
  --bar-band-h: 6px;
  --bar-text: #f4e6cb;
  --bar-text-2: #e0c9a5;
  --bar-text-3: #d2b892;
  --bar-press: rgba(255, 255, 255, 0.1);
  --tab-bg: repeating-linear-gradient(90deg, rgba(236, 208, 160, 0.72) 0 7px, transparent 7px 12px) 0 5px / 100% 1.5px no-repeat, url(../img/tex-leather.svg), linear-gradient(#573822, #4d311c);
  --tab-edge: 1px solid #3a2414;
  --paper-img: repeating-linear-gradient(transparent 0 31px, rgba(74, 106, 150, 0.17) 31px 32px);
  --paper-size: auto;
  --display: 'Sriracha', 'IBM Plex Sans Thai', sans-serif;
  --display-w: 400;
  color-scheme: light;
}


/* ---------- v1.7 second round: Mist, Rose granite, Survey, Northstar (samples) ---------- */
:root { --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l2.2 8.3 8.3 2.2-8.3 2.2L12 22.5l-2.2-8.3L1.5 12l8.3-2.2z'/%3E%3C/svg%3E"); }

/* Mist: pastel blue; a sea of mist around flat-topped sandstone hills (mesas and cuestas of the
   Khorat Plateau) stays still behind the screens; frosted cards; tab icons in a soft pill */
[data-theme='mist'] {
  --bg: #eaf2fb;
  --raise: rgba(255, 255, 255, 0.68);
  --raise-2: #dae7f5;
  --rule: #cbdbed;
  --rule-strong: #7a90aa;
  --text: #16304e;
  --text-2: #34506f;
  --text-3: #46607f;
  --accent: #8dbaea;
  --accent-ink: #0e2a49;
  --accent-soft: rgba(141, 186, 234, 0.3);
  --accent-fill: linear-gradient(180deg, #abcff3, #86b4e7);
  --sym: #2c68ad;
  --good: #2b7656;
  --fair: #985c08;
  --bad: #bd3f37;
  --info: #2c68ad;
  --chip: rgba(240, 246, 253, 0.92);
  --focus: #2c68ad;
  --tab-on: #1d4c82;
  --btn-edge: transparent;
  --bar: #eef5fc;
  --bar-edge: 1px solid #d3e2f2;
  --tab-bg: #eef5fc;
  --tab-edge: 1px solid #d3e2f2;
  --paper-img: url(../img/tex-mist.svg);
  --paper-size: cover;
  --paper-pos: center bottom;
  --paper-attach: scroll;
  --cta-bg: linear-gradient(to bottom, rgba(234, 242, 251, 0), rgba(234, 242, 251, 0.6) 45%);
  --display: 'Niramit', 'IBM Plex Sans Thai', sans-serif;
  --display-w: 600;
  --r-lg: 18px;
  --r-md: 14px;
  --pill: #cfe2f7;
  --icon-fill: rgba(141, 186, 234, 0.5);
  color-scheme: light;
}

/* Rose granite: pastel pink; grains of pink feldspar, quartz, a few dark biotite flecks and mica
   glints all over the page; tab icons in a soft pill */
[data-theme='rose'] {
  --bg: #fbeff3;
  --raise: #f8e2ea;
  --raise-2: #f2d1dd;
  --rule: #edc7d4;
  --rule-strong: #a27586;
  --text: #3b1829;
  --text-2: #66394d;
  --text-3: #85566a;
  --accent: #f2a6be;
  --accent-ink: #45122a;
  --accent-soft: rgba(242, 166, 190, 0.3);
  --accent-fill: linear-gradient(180deg, #f7bdcf, #ee9ab4);
  --sym: #b2306a;
  --good: #2b7451;
  --fair: #965a00;
  --bad: #bb3529;
  --info: #6549ad;
  --chip: rgba(251, 239, 243, 0.92);
  --focus: #b2306a;
  --tab-on: #9c2457;
  --btn-edge: transparent;
  --bar: #f9e2ea;
  --bar-edge: 1px solid #efc6d4;
  --tab-bg: #f9e2ea;
  --tab-edge: 1px solid #efc6d4;
  --paper-img: url(../img/tex-rosegranite.svg);
  --paper-size: 360px 360px;
  --display: 'Mali', 'IBM Plex Sans Thai', sans-serif;
  --display-w: 600;
  --r-lg: 18px;
  --r-md: 14px;
  --pill: #f6c5d5;
  --icon-fill: rgba(238, 154, 180, 0.45);
  color-scheme: light;
}
[data-theme='mist'] .tab.active::before, [data-theme='rose'] .tab.active::before { display: none; }
[data-theme='mist'] .tab .i, [data-theme='rose'] .tab .i { box-sizing: content-box; padding: 3px 16px; border-radius: 999px; transition: background-color 0.15s; }
[data-theme='mist'] .tab.active .i, [data-theme='rose'] .tab.active .i { background: var(--pill); fill: var(--icon-fill); }

/* Survey: red and white like a ranging pole; a red cover bar, survey-sheet crosses on white,
   a red triangle (trig point) over the chosen tab, technical lettering */
[data-theme='survey'] {
  --bg: #ffffff;
  --raise: #f8f4f4;
  --raise-2: #efe6e6;
  --rule: #e7dada;
  --rule-strong: #8a7373;
  --text: #1d1414;
  --text-2: #4a3b3b;
  --text-3: #6b5a5a;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(200, 16, 46, 0.09);
  --sym: #c8102e;
  --good: #1d7549;
  --fair: #955700;
  --bad: #a3141e;
  --info: #1f5a96;
  --chip: rgba(255, 255, 255, 0.94);
  --focus: #c8102e;
  --tab-on: #c8102e;
  --btn-edge: transparent;
  --bar: #c8102e;
  --bar-edge: 0 solid transparent;
  --bar-band: linear-gradient(#ffffff, #ffffff) 0 0 / 100% 1px no-repeat, repeating-linear-gradient(90deg, #c8102e 0 20px, #ffffff 20px 40px);
  --bar-band-h: 6px;
  --bar-text: #ffffff;
  --bar-text-2: #fff2f4;
  --bar-text-3: #ffe9ec;
  --bar-press: rgba(255, 255, 255, 0.16);
  --tab-bg: repeating-linear-gradient(90deg, #c8102e 0 20px, #ffffff 20px 40px) 0 0 / 100% 4px no-repeat, #ffffff;
  --tab-edge: 1px solid #e7dada;
  --tab-text: #1d1414;
  --tab-text-2: #4a3b3b;
  --tab-text-3: #6b5a5a;
  --tab-press: #efe6e6;
  --paper-img: url(../img/tex-reseau.svg);
  --paper-size: 200px 200px;
  --display: 'Chakra Petch', 'IBM Plex Sans Thai', sans-serif;
  --display-w: 600;
  --r-lg: 6px;
  --r-md: 4px;
  color-scheme: light;
}
[data-theme='survey'] .tab { padding-top: 5px; }
[data-theme='survey'] .tab.active::before { top: 4px; left: calc(50% - 6px); right: auto; width: 12px; height: 8px; border-radius: 0; clip-path: polygon(0 0, 100% 0, 50% 100%); }

/* Northstar: star trails circling the North Star, which glows at the top; gold for buttons, a
   twinkling star after the name, a star over the chosen tab; the loading screen circles the icon */
[data-theme='northstar'] {
  --bg: #070d24;
  --raise: rgba(17, 29, 70, 0.72);
  --raise-2: rgba(33, 50, 104, 0.82);
  --rule: rgba(132, 156, 230, 0.22);
  --rule-strong: #5a6ca8;
  --text: #eef1fb;
  --text-2: #bdc7e7;
  --text-3: #919ec8;
  --accent: #f4c86a;
  --accent-ink: #1b1404;
  --accent-soft: rgba(244, 200, 106, 0.16);
  --accent-fill: linear-gradient(180deg, #fbe2a4, #eab24e);
  --sym: #f4c86a;
  --good: #74e3ad;
  --fair: #f7b955;
  --bad: #ff8a8a;
  --info: #9cc0ff;
  --chip: rgba(7, 13, 36, 0.8);
  --focus: #f4c86a;
  --tab-on: #f4c86a;
  --btn-edge: transparent;
  --bar: #060b1f;
  --bar-edge: 1px solid rgba(132, 156, 230, 0.16);
  --tab-bg: #060b1f;
  --tab-edge: 1px solid rgba(132, 156, 230, 0.16);
  --paper-img: url(../img/tex-startrails.svg);
  --paper-size: cover;
  --paper-pos: center top;
  --paper-attach: scroll;
  --cta-bg: linear-gradient(to bottom, rgba(6, 11, 31, 0), rgba(6, 11, 31, 0.55) 45%);
  --display: 'Fahkwang', 'IBM Plex Sans Thai', sans-serif;
  --display-w: 600;
  color-scheme: dark;
}
[data-theme='northstar'] .proj h1 { font-size: 21px; }
[data-theme='northstar'] .btn-primary { box-shadow: 0 0 0 1px rgba(255, 228, 165, 0.45), 0 8px 26px -8px rgba(244, 200, 106, 0.55); }
[data-theme='northstar'] .tab.active::before { top: 7px; left: calc(50% + 9px); right: auto; width: 10px; height: 10px; border-radius: 0; -webkit-mask: var(--star) center / contain no-repeat; mask: var(--star) center / contain no-repeat; }
[data-theme='northstar'] .tab.active .i { filter: drop-shadow(0 0 6px rgba(244, 200, 106, 0.55)); }
[data-theme='northstar'] .brand b::after { content: ''; display: inline-block; width: 11px; height: 11px; margin-left: 5px; vertical-align: 6px; background: var(--accent); -webkit-mask: var(--star) center / contain no-repeat; mask: var(--star) center / contain no-repeat; }
@media (prefers-reduced-motion: no-preference) {
  [data-theme='northstar'] .brand b::after { animation: twinkle 3.4s ease-in-out infinite; }
}
@keyframes twinkle { 50% { opacity: 0.35; transform: scale(0.7) rotate(25deg); } }

/* loading screen: Mist shows its hills, Northstar its star trails circling the app icon */
[data-theme='mist'] #splash { background: url(../img/tex-mist.svg) center bottom / cover no-repeat, #eaf2fb; }
[data-theme='northstar'] #splash { background: url(../img/tex-startrails-splash.svg) center / cover no-repeat, #070d24; }
[data-theme='survey'] #splash, [data-theme='rose'] #splash { background: var(--bg) var(--paper-img) 0 0 / var(--paper-size); }
[data-theme='mist'] .sp-lines, [data-theme='northstar'] .sp-lines { display: none; }
[data-theme='northstar'] .sp-icon { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 70px rgba(244, 200, 106, 0.38); }

/* nine cards: names in English can be two words, so they may wrap */
.theme-grid.nine .theme-card b { text-align: center; font-size: 13.5px; line-height: 1.25; }

/* ---------- v1.7 third round: the kept themes get the same care, and Amethyst ---------- */
.sp-label { display: flex; flex-direction: column; align-items: center; gap: 2px; }

/* GeoNote: plain cream page in the app icon's colours, a light-grey header (the icon's frame),
   a sand index tab over the chosen tab */
[data-theme='geonote'] {
  --bar: #eef0ef;
}
[data-theme='geonote'] .tab.active::before { top: -8px; left: calc(50% - 23px); right: calc(50% - 23px); height: 8px; border-radius: 7px 7px 0 0; background: #c4a88c; }

/* Field book: 5 mm grid with a heavier line every 25 mm; the chosen tab is circled in red pen;
   the loading screen is the yellow cover with a label */
[data-theme='fieldbook'] .tab.active::before { display: none; }
[data-theme='fieldbook'] .tab .i { box-sizing: content-box; padding: 4px 13px; }
[data-theme='fieldbook'] .tab.active .i { background: url(../img/mark-redcircle.svg) center / 100% 100% no-repeat; }
[data-theme='fieldbook'] #splash { background: #f6d33c; }
[data-theme='fieldbook'] .sp-label { margin-top: 4px; padding: 10px 30px 12px; border: 2.5px solid #1c1a14; border-radius: 4px; background: #fbf8ec; }
[data-theme='fieldbook'] .sp-name { font-family: 'Itim', var(--font); font-weight: 400; }
[data-theme='fieldbook'] .sp-foot { color: #3d3412; }
[data-theme='fieldbook'] .sp-bar { background: rgba(28, 26, 20, 0.18); }

/* Topo map: the chosen tab sits on a little hill (contour rings); the loading screen is a map
   sheet: contours, a double neatline, a coordinate in the corner and a scale bar */
[data-theme='contour'] .tab.active::before { display: none; }
[data-theme='contour'] .tab .i { box-sizing: content-box; padding: 4px 13px; }
[data-theme='contour'] .tab.active .i { background: url(../img/mark-hill.svg) center / 100% 100% no-repeat; }
[data-theme='contour'] #splash { background: var(--bg) var(--paper-img) center / 520px 520px; }
[data-theme='contour'] #splash::before { content: ''; position: absolute; inset: calc(var(--safe-t) + 14px) 14px calc(var(--safe-b) + 14px); border: 1.5px solid #1d1d1b; box-shadow: inset 0 0 0 4px #f7f5ee, inset 0 0 0 5.5px #1d1d1b; pointer-events: none; }
[data-theme='contour'] #splash::after { content: '16°40′N   102°20′E'; position: absolute; left: 26px; top: calc(var(--safe-t) + 26px); font: 500 11px var(--mono); letter-spacing: 0.04em; color: #46453f; white-space: pre; }
[data-theme='contour'] .sp-label::after { content: '1 : 50 000'; display: block; margin-top: 12px; padding-top: 12px; font: 500 12px var(--mono); color: #46453f;
  background: linear-gradient(#1d1d1b, #1d1d1b) center 0 / 134px 1px no-repeat, linear-gradient(#1d1d1b, #1d1d1b) center 6px / 134px 1px no-repeat,
    repeating-linear-gradient(90deg, #1d1d1b 0 22px, #f7f5ee 22px 44px) center 1px / 132px 5px no-repeat; }

/* Leather journal: a ribbon bookmark hangs over the chosen tab; the loading screen is the
   stitched leather cover with the name pressed in gold */
[data-theme='leather'] .tab.active::before { top: -1px; left: calc(50% + 15px); right: auto; width: 9px; height: 24px; border-radius: 0; background: linear-gradient(90deg, #7a1d22, #ad3a40 45%, #7a1d22); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%); }
[data-theme='leather'] #splash { background: url(../img/tex-leather.svg), radial-gradient(120% 90% at 50% 40%, #6f482c, #4a2f1b); color: #f4e6cb; }
[data-theme='leather'] #splash::before { content: ''; position: absolute; inset: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); border: 2px dashed rgba(236, 208, 160, 0.6); border-radius: 18px; pointer-events: none; }
[data-theme='leather'] .sp-name { font-family: 'Sriracha', var(--font); font-weight: 400; color: #e8c27a; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55), 0 -1px 0 rgba(255, 236, 190, 0.25); }
[data-theme='leather'] .sp-tag, [data-theme='leather'] .sp-foot { color: #d9bf95; }
[data-theme='leather'] .sp-bar { background: rgba(0, 0, 0, 0.3); }
[data-theme='leather'] .sp-bar i, [data-theme='leather'] .sp-sign { color: #e8c27a; }
[data-theme='leather'] .sp-bar i { background: #e8c27a; }
[data-theme='leather'] .sp-icon { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 14px 32px -10px rgba(0, 0, 0, 0.7); }

/* the loading screens drawn above replace the wavy lines */
[data-theme='fieldbook'] .sp-lines, [data-theme='contour'] .sp-lines, [data-theme='leather'] .sp-lines, [data-theme='amethyst'] .sp-lines { display: none; }

/* Amethyst: looking into a geode: agate bands at the rim, violet crystals pointing in from the top
   and the bottom, glitter in the hollow; lavender buttons like a cut stone; the chosen tab in a
   faceted gem; the loading screen glows violet around the icon */
[data-theme='amethyst'] {
  --bg: #13091f;
  --raise: rgba(44, 22, 78, 0.72);
  --raise-2: rgba(70, 38, 118, 0.82);
  --rule: rgba(190, 150, 255, 0.2);
  --rule-strong: #7b5aa8;
  --text: #f4eeff;
  --text-2: #d0c2ea;
  --text-3: #a998cc;
  --accent: #c9a6ff;
  --accent-ink: #1d0b36;
  --accent-soft: rgba(201, 166, 255, 0.16);
  --accent-fill: linear-gradient(135deg, #e6d0ff 0%, #c7a0ff 45%, #a87cf0 100%);
  --sym: #f5c76b;
  --good: #7ee0b0;
  --fair: #f5c06b;
  --bad: #ff8fa3;
  --info: #a3c4ff;
  --chip: rgba(19, 9, 31, 0.8);
  --focus: #c9a6ff;
  --tab-on: #e6d4ff;
  --btn-edge: transparent;
  --bar: #13091f;
  --bar-edge: 1px solid rgba(190, 150, 255, 0.18);
  --tab-bg: #13091f;
  --tab-edge: 1px solid rgba(190, 150, 255, 0.18);
  --paper-img: url(../img/tex-amethyst.svg);
  --paper-size: cover;
  --paper-pos: center;
  --paper-attach: scroll;
  --cta-bg: linear-gradient(to bottom, rgba(19, 9, 31, 0), rgba(19, 9, 31, 0.55) 45%);
  --display: 'Chonburi', 'IBM Plex Sans Thai', serif;
  --display-w: 400;
  color-scheme: dark;
}
[data-theme='amethyst'] .proj h1 { font-size: 21px; }
[data-theme='amethyst'] .btn-primary { box-shadow: 0 0 0 1px rgba(236, 220, 255, 0.45), 0 8px 26px -8px rgba(170, 120, 255, 0.6); }
[data-theme='amethyst'] .tab.active::before { display: none; }
[data-theme='amethyst'] .tab .i { box-sizing: content-box; padding: 4px 16px; }
[data-theme='amethyst'] .tab.active .i { background: linear-gradient(135deg, rgba(222, 194, 255, 0.45), rgba(128, 74, 210, 0.4)); clip-path: polygon(16% 0, 84% 0, 100% 50%, 84% 100%, 16% 100%, 0 50%); }
[data-theme='amethyst'] #splash { background: url(../img/tex-amethyst-splash.svg) center / cover no-repeat, #13091f; }
[data-theme='amethyst'] .sp-icon { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 70px rgba(185, 140, 255, 0.5); }
[data-theme='amethyst'] .sp-foot { margin-bottom: 22px; }
