/* Golf Companion — visual language carried from AS_golf.
   Fraunces serif + JetBrains Mono, green/cream palette, mobile-first. */

:root {
  --bg: #e6ecf2;
  --bg-card: #f6f9fc;
  --ink: #0d1b2a;
  --ink-soft: #44546e;
  --ink-faint: #8a96a8;
  --green: #1d4a3e;
  --green-soft: #2d6a52;
  --green-pale: #c4d6cc;
  --accent: #2c5b9c;
  --accent-rgb: 44, 91, 156;
  --line: #c8d2dd;
  --line-soft: #dde5ee;
  --gold: #b8954a;
  --plum: #6b4f8a;
  --red: #c64a3c;
  --shadow: 0 1px 2px rgba(13, 27, 42, 0.05), 0 4px 14px rgba(13, 27, 42, 0.07);
  --nav-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Fraunces', Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-feature-settings: "ss01", "ss02";
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font-family: inherit; }

.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---------- layout ---------- */

#app {
  min-height: 100%;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

header .brand {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

header .brand em { font-style: italic; color: var(--green); }

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 5px 9px;
  border-radius: 2px;
  cursor: pointer;
}

.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.sync-dot.ok { background: var(--green-soft); }
.sync-dot.busy { background: var(--gold); animation: pulse 1.2s infinite; }
.sync-dot.err { background: var(--red); }
.sync-dot.local { background: var(--ink-faint); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

main { padding: 20px 20px 32px; max-width: 760px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

/* ---------- bottom nav ---------- */

nav.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--line);
  z-index: 100;
}

nav.tabbar button {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-faint);
  padding: 6px 2px;
}

nav.tabbar button .ico { font-size: 17px; line-height: 1; }
nav.tabbar button .lbl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
nav.tabbar button.active { color: var(--green); }
nav.tabbar button.active .lbl { font-weight: 500; }

/* ---------- generic blocks ---------- */

.view-title {
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.view-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  margin-bottom: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-faint);
  font-style: italic;
}

.section-divider {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 26px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line-soft);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 11px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  min-height: 44px;
}
.btn:active { background: var(--green-soft); }
.btn.alt { background: var(--accent); }
.btn.ghost {
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn.full { width: 100%; }
.btn.sm { min-height: 34px; padding: 7px 12px; font-size: 10px; }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 15px;
  background: var(--bg-card);
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--green);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

/* ---------- today ---------- */

.today-hero {
  background: var(--green);
  color: #fff;
  border-radius: 4px;
  padding: 22px 22px 24px;
  margin-bottom: 16px;
}
.today-hero .label { color: var(--green-pale); }
.today-hero h2 {
  font-size: 28px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
  margin: 2px 0 10px;
}
.today-hero .meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--green-pale);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.mic-btn {
  width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--green);
  border-radius: 4px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 16px;
}
.mic-btn .mic-ico { font-size: 30px; }
.mic-btn .mic-lbl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--green);
}
.mic-btn.recording {
  border-color: var(--red);
  background: #fbeae8;
}
.mic-btn.recording .mic-lbl { color: var(--red); }
.mic-btn.recording .mic-ico { animation: pulse 1s infinite; }

/* ---------- voice notes ---------- */

.vnote {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.vnote .vnote-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}
.vnote .vnote-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}
.vnote .vnote-text { font-size: 15px; line-height: 1.5; }
.vnote .vnote-text.pending { color: var(--ink-faint); font-style: italic; }
.vnote .vnote-actions { display: flex; gap: 6px; }
.tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  background: var(--green-pale);
  color: var(--green);
}
.tag.warn { background: #f5e7cc; color: var(--gold); }

.icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  color: var(--ink-soft);
}

/* ---------- trips ---------- */

.trip-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.trip-cost .num {
  font-size: 30px;
  font-weight: 500;
  color: var(--green);
  letter-spacing: -0.02em;
}

.day-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.day-card.played { border-left: 3px solid var(--green); }
.day-card .day-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.day-card .day-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.day-card .day-fee {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--green);
  font-weight: 500;
}
.day-card .day-course { font-size: 17px; font-weight: 500; }
.day-card .day-course.empty-course { color: var(--ink-faint); font-style: italic; font-weight: 400; }
.day-card .day-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 3px;
}
.day-card .day-notes {
  font-size: 14px;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 7px;
  white-space: pre-line;
}

/* ---------- network ---------- */

.net-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.net-stat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px;
  text-align: center;
}
.net-stat .num {
  font-size: 22px;
  font-weight: 500;
  color: var(--green);
}
.net-stat .label { margin: 2px 0 0; }

.club-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 6px;
}
.club-row.played { background: #e7efe9; }
.club-check {
  width: 22px; height: 22px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.club-row.played .club-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-size: 12px;
}
.club-row .club-name { flex: 1; font-size: 15px; font-weight: 500; }
.club-row .club-fee {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--green);
}
.club-row .club-fee.unknown { color: var(--gold); font-size: 10px; }
.fee-note {
  font-size: 12px;
  color: var(--gold);
  font-style: italic;
  margin: 2px 0 8px 36px;
}

/* ---------- rounds ---------- */

.round-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 6px;
}
.round-row .round-score {
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
}

/* ---------- modal ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 42, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 620px;
  border-radius: 10px 10px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 16px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-head .close {
  background: none; border: none; cursor: pointer;
  font-size: 24px; color: var(--ink-faint); line-height: 1;
}

@media (min-width: 620px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 10px; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 4px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  max-width: 90vw;
}
.toast.show { opacity: 1; }
