:root {
  --bg: #0B1A24;
  --bg-deep: #06111A;
  --card: #10222F;
  --card-2: #13293A;
  --line: #1E3546;
  --line-2: #2A4558;
  --text: #E6EEF2;
  --muted: #9DB3BF;
  --teal: #2BB3A8;
  --teal-text: #5FD3CB;
  --amber: #F2A93B;
  --red: #F08A7E;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg-deep); color: var(--text); }
body { font-family: Inter, system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
a { color: var(--teal-text); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, .h2, .brand { font-family: 'Space Grotesk', system-ui, sans-serif; }
h1 { font-size: 28px; line-height: 1.15; margin: 8px 0 0; }
h2 { font-size: 20px; margin: 0; }
.h2 { font-size: 22px; font-weight: 700; }
.eyebrow { font-family: Inter, sans-serif; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #8FA6B3; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.warn { color: var(--amber); }
.mono { font-family: ui-monospace, monospace; }
em { font-style: normal; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; letter-spacing: -0.3px; }

/* Layout */
.shell { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.topbar { padding: 18px 20px 8px; }
.page { flex: 1; padding: 8px 16px 100px; max-width: 520px; width: 100%; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; }
.row.gap, .gap { gap: 12px; }
.between { justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.mentor { background: #0E2A2C; border-color: #1F4E4C; }

/* Auth */
.auth { max-width: 440px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; gap: 16px; min-height: 100vh; background: var(--bg); }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 6px; }
fieldset.field > legend { margin-bottom: 8px; }
input, select, textarea {
  background: var(--bg-deep); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 12px; min-height: 46px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--teal-text); outline-offset: 2px;
}
.field.file input[type=file], .file-btn input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.field.file { position: relative; background: var(--bg-deep); border: 1px dashed var(--line-2); border-radius: 12px; padding: 12px; cursor: pointer; }
.field.file:focus-within { outline: 2px solid var(--teal-text); }
.file-btn { position: relative; }

/* Buttons */
.btn { border-radius: 999px; padding: 12px 20px; min-height: 46px; font-weight: 600; border: 1px solid transparent; cursor: pointer; text-align: center; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.btn.primary { background: var(--teal); color: var(--bg-deep); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn.dashed { background: transparent; border: 1px dashed var(--line-2); color: var(--teal-text); border-radius: 12px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.link { background: none; border: 0; color: var(--teal-text); padding: 10px; cursor: pointer; min-height: 44px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card-2); border: 1px solid var(--line-2); color: #CFE0E8; border-radius: 999px; padding: 8px 14px; min-height: 40px; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--teal); border-color: var(--teal); color: var(--bg-deep); font-weight: 600; }

.badge { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.badge.approved { background: var(--amber); color: #1A1206; }
.badge.pending { border: 1px solid #4A5D6A; color: #BFD4DE; }
.badge.rejected { border: 1px solid var(--red); color: var(--red); }

.notice { border-radius: 14px; padding: 12px 14px; font-size: 14px; background: #1F1A0E; border: 1px solid #4A3A16; color: #F4D9A6; }
.notice.error { background: #2A1414; border-color: #5A2A2A; color: #F6C1BA; }

.avatar { border-radius: 50%; background: var(--teal); color: var(--bg-deep); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-family: 'Space Grotesk', sans-serif; object-fit: cover; flex-shrink: 0; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-size: 14px; }

.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.photos img { width: 100%; border-radius: 10px; display: block; }

/* Bottom tabs */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px;
  display: flex; background: #0A1620; border-top: 1px solid var(--line);
  padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; min-height: 52px; color: #8FA6B3; font-size: 12px; font-weight: 600; text-decoration: none; }
.tabbar a.on { color: var(--teal-text); }

/* Stage 2: trips, Discover, Buddies */
.center { text-align: center; justify-content: center; align-items: center; }
.gap-lg { gap: 28px; }
.small-gap { gap: 8px; }
.big { font-size: 17px; }
.left { text-align: left; }
.card.trip { background: #0E2A2C; border-color: #1F4E4C; }
.pill { font-size: 12px; background: var(--card-2); color: #BFD4DE; border-radius: 999px; padding: 6px 12px; }
.tag { font-size: 12px; border: 1px solid var(--line-2); color: #CFE0E8; border-radius: 999px; padding: 5px 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--teal); }

.card.flush { padding: 0; overflow: hidden; }
.pad { padding: 16px; }
.swipe { touch-action: pan-y; user-select: none; cursor: grab; will-change: transform; }
.swipe-head { position: relative; height: 240px; background: #163447; }
.swipe-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.swipe-photo.empty { display: flex; align-items: center; justify-content: center; }
.swipe-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 16px 14px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 10px;
  background: linear-gradient(transparent, rgba(6, 17, 26, 0.9));
}
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge.mentor { background: #5FD3CB; color: #06111A; }
.stamp { position: absolute; top: 20px; padding: 6px 14px; border-radius: 10px; font-weight: 700; font-size: 22px; letter-spacing: 2px; border: 3px solid; }
.stamp.like { left: 20px; color: var(--teal-text); border-color: var(--teal-text); transform: rotate(-12deg); }
.stamp.pass { right: 20px; color: var(--red); border-color: var(--red); transform: rotate(12deg); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats div { background: var(--card-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.stats b { font-family: 'Space Grotesk', sans-serif; font-size: 18px; }
.stats span { font-size: 11px; color: var(--muted); }
.tripline { background: #0E2A2C; border: 1px solid #1F4E4C; border-radius: 12px; padding: 10px 12px; font-size: 13px; color: #CDEDEA; }
.mentorline { background: #1F1A0E; border: 1px solid #4A3A16; border-radius: 12px; padding: 10px 12px; font-size: 13px; color: #F4D9A6; }

.round { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--card); color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.round.go { background: var(--teal); border-color: var(--teal); color: var(--bg-deep); }

.overlay {
  position: fixed; inset: 0; z-index: 10; background: rgba(6, 17, 26, 0.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 32px; text-align: center;
}
.h1 { font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 700; }
.overlay .avatar { border: 3px solid var(--bg); }

.buddy-row { background: none; border: 0; padding: 0; width: 100%; cursor: pointer; text-align: left; min-height: 48px; }

/* Update 003: bulk certs, CCR units, instructors */
.h3 { font-family: 'Space Grotesk', sans-serif; font-size: 17px; font-weight: 700; margin: 0; }
.filelist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.filelist li { border-bottom: 1px solid var(--line); padding: 2px 0; }
.file-btn { position: relative; display: flex; align-items: center; justify-content: center; }
.file-btn input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--teal-text); outline-offset: 2px; }
.photos figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.review-item { border-top: 1px solid var(--line); padding-top: 12px; }
.multiselect { background: var(--bg-deep); border: 1px solid var(--line-2); border-radius: 12px; }
.multiselect summary { padding: 12px; min-height: 46px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.multiselect summary::after { content: '▾'; color: var(--muted); margin-left: 8px; }
.multiselect[open] summary::after { content: '▴'; }
.multiselect summary::-webkit-details-marker { display: none; }
.ms-list { border-top: 1px solid var(--line); padding: 4px 12px 12px; max-height: 320px; overflow-y: auto; }
.ms-other { margin-top: 8px; }
.badge.instructor { background: #E6EEF2; color: #06111A; }
.instructorline { color: #CFE0E8; }

/* Stage 3: chat */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plain { background: none; border: 0; padding: 0; cursor: pointer; min-height: 44px; }
.buddy-row.card { padding: 12px 16px; }
.chat { display: flex; flex-direction: column; gap: 10px; min-height: calc(100vh - 170px); }
.chat-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 48px; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; min-width: 160px; z-index: 5; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px 16px; min-height: 44px; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--card); }
.menu .danger { color: var(--red); }
.dived { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #1F1A0E; border: 1px solid #4A3A16; color: #F4D9A6; border-radius: 14px; padding: 10px 12px; font-size: 13px; }
.dived.done { background: #0E2A2C; border-color: #1F4E4C; color: #CDEDEA; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 6px 0; }
.day { text-align: center; margin: 8px 0 2px; }
.bubble { max-width: 80%; padding: 9px 12px 18px; border-radius: 16px; position: relative; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.bubble.mine { align-self: flex-end; background: var(--teal); color: var(--bg-deep); border-bottom-right-radius: 4px; }
.bubble.theirs { align-self: flex-start; background: var(--card-2); border-bottom-left-radius: 4px; }
.bubble .time { position: absolute; right: 10px; bottom: 3px; font-size: 10px; opacity: 0.7; }
.composer { position: sticky; bottom: 76px; background: var(--bg); padding: 8px 0; align-items: flex-end; }
.composer textarea { resize: none; max-height: 120px; }
.evidence { white-space: pre-wrap; font-size: 12px; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 300px; overflow: auto; margin: 0; }

/* Netlify's badge: keep it visible, but in the header strip instead of over the tab bar */
#nl-badge-frame { top: 2px !important; bottom: auto !important; }
.topbar { position: sticky; top: 0; z-index: 4; background: var(--bg); min-height: 58px; display: flex; align-items: center; }
.chat-head { top: 58px; }
.button-labels { margin-top: -8px; }
.button-labels span { width: 64px; text-align: center; font-size: 12px; }

/* AI pre-check */
.full { width: 100%; text-align: left; }
.aicheck { border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.aicheck.good { background: #0E2A2C; border-color: #1F4E4C; }
.aicheck.maybe { background: #1A2230; }
.aicheck.warn { background: #2A1A12; border-color: #5A3A1E; }
.aicheck.none { flex-direction: row; flex-wrap: wrap; }
.aifields { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.aifields .match::marker { content: '✓  '; color: var(--teal-text); }
.aifields .mismatch::marker { content: '✕  '; color: var(--red); }
.aifields .unreadable::marker { content: '?  '; color: var(--amber); }
.aifields .not_on_card::marker { content: '–  '; color: var(--muted); }

/* Line-arrow buttons: red pointing left = not now, green pointing right = dive with */
.arrow-buttons { gap: 40px; }
.arrow-btn { background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 10px; min-height: 64px; border-radius: 14px; font-size: 13px; font-weight: 600; transition: transform .12s ease; }
.arrow-btn:active { transform: scale(0.94); }
.arrow-btn.pass { color: #F0624D; }
.arrow-btn.go { color: #3CCB74; }
.arrow-btn span { color: var(--text); }
.arrow-btn svg { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35)); }
