:root {
  --green: #0b3d2e;
  --green-soft: #14543f;
  --cream: #f5f2e6;
  --ink: #16241d;
  --muted: #5d6b63;
  --line: #e3e1d6;
  --note: #9a6b00;
  /* left label column shared by the contact/direction grids, their extras
     rows, and the recent strip so every section lines up on the same edges */
  --gutter: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  font: 16px/1.4 system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--cream);
  /* respect the iPhone safe areas in standalone mode */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--green);
  color: var(--cream);
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.hdr-back {
  border: 0;
  background: transparent;
  color: var(--cream);
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 0.25rem;
  margin: -0.25rem 0;
  cursor: pointer;
}

main {
  flex: 1;
  overflow-y: auto;
}

.empty {
  margin: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.session-row {
  position: relative;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

/* The tappable face slides left to uncover the Delete latched behind it. */
.session-face {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'when badge'
    'summary badge';
  gap: 0.1rem 0.75rem;
  align-items: center;
  padding: 1rem 1.25rem;
  min-height: 64px;
  background: #fff;
  transition: transform 0.18s ease;
}

.session-del {
  position: absolute;
  top: 0;
  right: 0;
  width: 88px;
  height: 100%;
  border: 0;
  background: var(--danger, #c0392b);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.session-row.is-open .session-face {
  transform: translateX(-88px);
}

.session-when {
  grid-area: when;
  font-weight: 600;
}

.session-summary {
  grid-area: summary;
  color: var(--muted);
  font-size: 0.95rem;
}

.session-badge {
  grid-area: badge;
}

.session-badge.is-exported {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--cream);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.app-footer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--cream);
}

button.ghost {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button.ghost:active {
  background: var(--line);
}

button.primary {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: var(--cream);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

button.primary:active {
  background: var(--green-soft);
}

/* ---- session hub (block menu) ---- */

.seclabel {
  margin: 1.25rem 1.25rem 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.blocks {
  display: flex;
  flex-direction: column;
}

.block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.block.done {
  border-left: 3px solid var(--green);
}

.bname {
  font-weight: 600;
}

.bsub {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.bstat {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.1rem;
}

.minidots {
  display: flex;
  gap: 5px;
  margin-top: 0.4rem;
}

.minidots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--cream);
}

.minidots i.on {
  background: var(--green);
  border-color: var(--green);
}

.chev {
  color: var(--muted);
  font-size: 1.4rem;
}

/* ---- short-game entry ---- */

.prog {
  display: flex;
  gap: 6px;
  padding: 0.9rem 1.25rem 0;
}

.seg {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 7px 2px;
  text-align: center;
  line-height: 1.2;
  cursor: pointer;
}

.seg .segd {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}

.seg .segv {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  min-height: 1.2em;
  color: var(--muted);
}

.seg.cur {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green) inset;
}

.seg.done .segv {
  color: var(--green);
}

.hero {
  text-align: center;
  margin: 1.25rem 0 1rem;
}

.hero .dist {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero .dist-unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
}

.hero .goal {
  color: var(--green-soft);
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.3rem;
}

.hero .of {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.pad {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 1.25rem;
}

.prow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.prow.one > .num {
  grid-column: 2;
}

.num {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  padding: 1rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
}

.num.sel {
  background: var(--green);
  border-color: var(--green);
  color: var(--cream);
}

.skip {
  margin: 1rem 1.25rem 0;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 0.9rem 0;
  font-size: 1rem;
  cursor: pointer;
}

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

.navbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--cream);
  position: sticky;
  bottom: 0;
}

.navbtn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.7rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navbtn.hub {
  background: var(--green);
  border-color: var(--green);
  color: var(--cream);
  font-weight: 600;
}

.navbtn.off {
  visibility: hidden;
}

/* ---- full-swing entry ---- */

.gtot {
  padding: 0.9rem 1.25rem 0;
  text-align: right;
  color: var(--muted);
  font-size: 0.85rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0.5rem 1.25rem 0;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: var(--cream);
}

.chip .tally {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.7;
}

.label {
  display: flex;
  justify-content: space-between;
  margin: 0.9rem 1.25rem 0.4rem;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-crumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.5rem 1.25rem 0.9rem;
  text-align: center;
}

.step-crumb .step-n {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.step-crumb .step-name {
  color: var(--green);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.step-crumb .step-pick {
  color: var(--muted);
  font-size: 0.85rem;
}

.gridpad {
  padding: 0 1.25rem;
}

/* matrix grid: a gutter column for the row labels + three data columns */
.matrix {
  display: grid;
  grid-template-columns: var(--gutter) repeat(3, 1fr);
  gap: 7px;
  align-items: stretch;
}

.matrix.big {
  gap: 10px;
}

.mhead {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mhead.mrowhead {
  justify-content: flex-end;
  padding-right: 2px;
}

.cell {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.9rem 0.25rem;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.15;
  user-select: none;
  cursor: pointer;
}

.cell.big {
  padding: 1.4rem 0.25rem;
  font-size: 0.95rem;
}

.cell.sel {
  background: var(--green);
  border-color: var(--green);
  color: var(--cream);
  font-weight: 700;
}

.cell.q {
  color: var(--muted);
}

.cell.mcell {
  color: var(--muted);
  font-size: 1.4rem;
}

.cell.mcell.big {
  padding: 1.6rem 0.25rem;
}

.cell.mcell.sel {
  color: var(--cream);
}

.cell.fat {
  border-color: #b08a4a;
}

.cell.thin {
  border-color: #8a6aa0;
}

.cell.mishit {
  border-color: #b3605a;
}

.harrow {
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 700;
}

/* axis-group headers: a cap over the columns and a rotated cap down the rows */
.hcap {
  margin-left: var(--gutter);
  margin-bottom: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--green);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.matrixwrap {
  position: relative;
}

.vcap {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--green);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* extras rows reuse the gutter so their left/right edges match the grid */
.extras {
  display: grid;
  grid-template-columns: var(--gutter) repeat(4, 1fr);
  gap: 7px;
  margin-top: 7px;
}

.extras.big {
  gap: 10px;
}

.extras-dir {
  display: grid;
  grid-template-columns: var(--gutter) repeat(3, 1fr);
  gap: 7px;
  margin-top: 7px;
}

.qwide {
  grid-column: 2 / -1;
}

.recent-empty {
  padding: 0.6rem 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.recentlist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 1.25rem;
}

.rrow {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--rcols, 3), 1fr);
  gap: 7px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.rrow.editing {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green) inset;
}

.rseq {
  text-align: right;
  padding-right: 2px;
  color: var(--muted);
}

.rclub {
  text-align: center;
  font-weight: 700;
}

.rcell {
  text-align: center;
}

.ndot {
  color: var(--note);
  font-size: 0.6rem;
}

.editbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0.9rem 1.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--green);
  border-radius: 12px;
  background: #fff;
  font-size: 0.9rem;
}

.editbtns {
  display: flex;
  gap: 6px;
}

.editbar button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.editbar button.del {
  border-color: #b3261e;
  color: #b3261e;
}

.editbar button.done {
  background: var(--green);
  border-color: var(--green);
  color: var(--cream);
  font-weight: 700;
}

.notepreview {
  margin: -0.25rem 1.25rem 0.5rem;
  color: var(--note);
  font-size: 0.85rem;
  font-style: italic;
}
