:root {
  --ground: #101218;
  --card: #1A1D26;
  --raised: #242836;
  --line: #2E3242;
  --line-soft: #262938;
  --text: #F2EFE8;
  --muted: #9497A6;
  --dim: #6E7183;
  --gold: #F4B63F;
  --on-gold: #241A04;
  --gold-deep: #2A2413;
  --gold-mid: #4A3D1C;
  --gold-rail: #C98F1E;
  --gold-text: #C9B98F;
  --green: #5FD39A;
  --green-deep: #12261C;
  --green-line: #2F6B4C;
  --green-text: #CFE9DB;
  --blue: #8AB8FF;
  --display: 'Big Shoulders Display', 'Arial Narrow', 'Helvetica Neue', sans-serif;
  --body: 'Figtree', system-ui, -apple-system, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--ground); height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; margin: 0; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.app { min-height: 100vh; min-height: 100dvh; }

.screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--sat) + 18px) 20px calc(var(--sab) + 28px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.screen.center { align-items: stretch; }

.display { font-family: var(--display); font-weight: 900; text-transform: uppercase; line-height: 0.95; letter-spacing: 0.01em; }
.display.w800 { font-weight: 800; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.gold { color: var(--gold); }
.green { color: var(--green); }
.blue { color: var(--blue); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.label { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.label.gold { color: var(--gold); }
.label.goldtext { color: var(--gold-text); }
.label.green { color: var(--green); }
.label.text { color: var(--text); }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.base { align-items: baseline; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.mt-auto { margin-top: auto; }

.card { padding: 18px; border-radius: 20px; background: var(--card); display: flex; flex-direction: column; gap: 12px; }
.card.tight { padding: 14px; gap: 8px; border-radius: 16px; }
.card.gold { background: var(--gold); color: var(--on-gold); border-radius: 22px; padding: 20px; gap: 12px; }
.card.gold .label { color: var(--on-gold); }
.card.golddeep { background: var(--gold-deep); }
.card.greendeep { background: var(--green-deep); border: 1px solid var(--green-line); color: var(--green-text); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 18px; border-radius: 16px;
  font-weight: 700; font-size: 17px; text-decoration: none;
  background: var(--raised); color: var(--text);
}
.btn.gold { background: var(--gold); color: var(--on-gold); }
.btn.dark { background: var(--ground); color: var(--gold); }
.btn.green { background: var(--green); color: #0B1F14; }
.btn.outline { background: transparent; border: 1.5px solid currentColor; }
.btn.outline.ongold { color: var(--on-gold); min-height: 48px; font-size: 15px; font-weight: 600; border-radius: 14px; }
.btn.outline.green { color: var(--green-text); border-color: var(--green-line); background: transparent; }
.btn.sub { min-height: 52px; font-size: 16px; font-weight: 600; }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: 14px; font-weight: 600; border-radius: 14px; background: var(--card); color: var(--muted); }
.btn.pill { min-height: 32px; padding: 0 12px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--raised); color: var(--text); }
.btn.danger { color: #FF8A8A; }
.btn:active { filter: brightness(0.92); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.iconbtn { width: 44px; height: 44px; border-radius: 14px; background: var(--card); color: var(--text); display: flex; align-items: center; justify-content: center; flex: none; }
.iconbtn svg { width: 20px; height: 20px; }

.rail { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.rail > i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.rail.gold { background: var(--gold-mid); }
.rail.gold > i { background: var(--gold); }
.rail.thin { height: 4px; }
.rail.thick { height: 10px; }
.rail.ongold { background: var(--gold-rail); }
.rail.ongold > i { background: var(--on-gold); }

.segs { display: grid; gap: 6px; }
.segs.tight { gap: 4px; }

.diamond { display: inline-block; width: 10px; height: 10px; transform: rotate(45deg); border-radius: 2px; background: var(--gold); flex: none; }
.diamond.empty { background: transparent; border: 1.5px solid var(--dim); }
.diamond.lg { width: 18px; height: 18px; border-radius: 4px; }

/* Home */
.brand { font-family: var(--display); font-weight: 900; font-size: 22px; letter-spacing: 0.18em; text-transform: uppercase; }
.rankbadge {
  flex: none; width: 68px; height: 68px; border-radius: 18px; background: var(--gold-deep); border: 2px solid var(--gold);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; color: var(--gold);
}
.rankbadge.none { border-color: var(--line); background: var(--card); color: var(--muted); }
.rankbadge b { font-family: var(--display); font-weight: 900; font-size: 30px; }
.rankbadge span { font-size: 9px; font-weight: 700; letter-spacing: 0.12em; margin-top: 2px; }
.rankname { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: 0.02em; text-transform: uppercase; }
.bignum { font-family: var(--display); font-weight: 800; font-size: 48px; line-height: 1; color: var(--green); }
.bignum.gold { color: var(--gold); }
.weekslot { display: flex; flex-direction: column; gap: 6px; }
.weekslot i { display: block; height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.weekslot i > b { display: block; height: 100%; background: var(--green); }
.weekslot i.on { background: var(--green); }
.weekslot i.half > b { width: 50%; }
.weekslot span { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); text-align: center; min-height: 12px; white-space: nowrap; overflow: visible; }
.weekslot span.gold { color: var(--gold); }
.nextname { font-family: var(--display); font-weight: 900; font-size: 56px; line-height: 0.9; text-transform: uppercase; }
.pickgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; min-height: 52px; border-radius: 14px; background: var(--card); text-align: left; color: var(--text); }
.pick b { font-family: var(--display); font-weight: 800; font-size: 19px; letter-spacing: 0.02em; text-transform: uppercase; }
.pick span { font-size: 12px; color: var(--muted); }

/* Log */
.exname { font-family: var(--display); font-weight: 900; font-size: 40px; line-height: 0.95; text-transform: uppercase; overflow-wrap: anywhere; }
.exname.mid { font-size: 32px; }
.exname.long { font-size: 26px; line-height: 1; }
.weightctl { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); flex: none; }
.weightctl button.pm { width: 44px; height: 44px; border-radius: 10px; background: var(--raised); color: var(--text); font-size: 22px; font-weight: 600; }
.weightctl .wval { display: flex; flex-direction: column; align-items: center; line-height: 1.05; min-width: 72px; }
.weightctl input { width: 76px; height: 28px; padding: 0; border: 0; border-bottom: 1px dashed #4A4E60; background: transparent; color: var(--text); font-size: 20px; font-weight: 800; text-align: center; border-radius: 0; }
.weightctl .wsub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.weightctl .wsub.changed { color: var(--blue); font-weight: 700; }
.weightctl .wsub.planned { color: var(--gold); font-weight: 700; }

.tiles { display: grid; gap: 8px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 10px; border-radius: 16px; min-height: 92px; text-align: left; color: var(--text); background: transparent; border: 1px dashed #3A3E4E; }
.tile .label { font-size: 10px; }
.tile .n { font-family: var(--display); font-weight: 800; font-size: 38px; line-height: 1; color: var(--dim); }
.tile .sub { font-size: 12px; color: var(--dim); line-height: 1.2; }
.tile.current { background: var(--gold-deep); border: 2px solid var(--gold); }
.tile.current .n { color: var(--gold); }
.tile.current .sub { color: var(--gold); font-weight: 700; }
.tile.logged { background: var(--card); border: 1px solid var(--card); }
.tile.logged .n { color: var(--text); }
.tile.logged .sub { color: var(--muted); }
.tile.logged.up .n { color: var(--green); }
.tile.logged.up .sub { color: var(--green); font-weight: 700; }
.tile.logged.editing { border-color: var(--blue); }

.repgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.rep { height: 48px; border-radius: 12px; font-size: 18px; font-weight: 700; background: var(--card); color: var(--text); }
.rep.on { background: var(--gold); color: var(--on-gold); }
.rep.more { font-size: 14px; color: var(--muted); }

.donepanel { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 18px; background: var(--green-deep); border: 1px solid var(--green-line); }
.donepanel .title { font-family: var(--display); font-weight: 900; font-size: 30px; text-transform: uppercase; color: var(--green); }
.donepanel .title.gold { color: var(--gold); }
.donepanel .line { font-size: 14px; line-height: 1.45; color: var(--green-text); }

.nudge { padding: 12px 14px; border-radius: 14px; background: #1C2233; border: 1px solid #2B3550; color: var(--blue); font-size: 13px; line-height: 1.4; }

.notebox { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--card); }
.notebox .text { font-size: 15px; line-height: 1.4; white-space: pre-wrap; }
.notebox .text.empty { color: var(--dim); }
.notebox textarea { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--ground); padding: 10px; font-size: 16px; color: var(--text); resize: none; line-height: 1.4; }

/* Sheet */
.sheetwrap { position: fixed; inset: 0; background: rgba(6, 7, 11, 0.72); display: flex; flex-direction: column; justify-content: flex-end; z-index: 20; }
.sheet { max-width: 480px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding: 20px 20px calc(var(--sab) + 28px); border-radius: 28px 28px 0 0; background: var(--card); }
.sheet .grip { width: 40px; height: 5px; border-radius: 99px; background: #3A3E4E; align-self: center; }
.sheet h2 { margin: 0; font-family: var(--display); font-weight: 900; font-size: 38px; line-height: 0.95; text-transform: uppercase; }
.halfbox { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 16px; background: var(--green-deep); }
.halfbox b { flex: none; font-family: var(--display); font-weight: 900; font-size: 30px; color: var(--green); }
.halfbox span { font-size: 14px; line-height: 1.4; color: var(--green-text); }
.halfbox.zero { background: var(--raised); }
.halfbox.zero b { color: var(--muted); }
.halfbox.zero span { color: var(--muted); }

/* Session done */
.donehead { font-family: var(--display); font-weight: 900; font-size: 54px; line-height: 0.92; text-transform: uppercase; }
.quote { padding: 0; color: var(--gold); font-size: 17px; line-height: 1.4; font-weight: 600; text-align: left; }
.twocol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { font-family: var(--display); font-weight: 900; font-size: 36px; line-height: 1; }
.list { display: flex; flex-direction: column; border-radius: 16px; background: var(--card); overflow: hidden; }
.list > .li { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line-soft); color: var(--text); text-align: left; width: 100%; }
.list > .li:first-child { border-top: 0; }
.li .name { font-weight: 600; font-size: 15px; }
.li .detail { font-size: 12px; color: var(--muted); }
.li .res { font-size: 13px; font-weight: 700; min-width: 56px; text-align: right; }
.li .res.mark { color: var(--gold); }
.li .res.held { color: var(--muted); font-weight: 600; }

/* Rank up */
.rankdiamond { width: 140px; height: 140px; border-radius: 36px; transform: rotate(45deg); border: 3px solid var(--gold); background: var(--gold-deep); display: flex; align-items: center; justify-content: center; margin: 14px auto; }
.rankdiamond > div { transform: rotate(-45deg); display: flex; flex-direction: column; align-items: center; line-height: 1; }
.rankdiamond b { font-family: var(--display); font-weight: 900; font-size: 72px; color: var(--gold); }
.rankdiamond span { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; color: var(--gold-text); }
.rankbig { font-family: var(--display); font-weight: 900; font-size: 64px; line-height: 0.9; text-transform: uppercase; text-align: center; margin-top: 10px; }
.ladder { display: flex; flex-direction: column; border-radius: 18px; background: var(--card); padding: 4px 0; }
.ladder .lrow { display: flex; align-items: center; gap: 14px; padding: 10px 16px; }
.ladder .lrow.now { background: #22252F; }
.ladder .dot { flex: none; width: 12px; height: 12px; border-radius: 99px; border: 2px solid #4A4E60; }
.ladder .dot.done { background: var(--green); border-color: var(--green); }
.ladder .dot.now { width: 16px; height: 16px; background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 5px #3A2F12; }
.ladder .lname { flex: 1; font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--dim); }
.ladder .ltag { font-size: 12px; color: var(--dim); text-align: right; }
.ladder .lrow.done .lname { color: var(--text); }
.ladder .lrow.done .ltag { color: var(--muted); }
.ladder .lrow.now .lname, .ladder .lrow.now .ltag { color: var(--gold); }
.ladder .lrow.now .ltag { font-weight: 700; }

/* Program editor + settings */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.input { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--ground); color: var(--text); font-size: 16px; }
select.input { appearance: none; -webkit-appearance: none; }
.exrow { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: var(--card); }
.exrow .top { display: flex; align-items: center; gap: 8px; }
.exrow .top b { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; }
.exrow .meta { font-size: 12px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 2px; border-radius: 12px; background: var(--raised); padding: 2px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; font-size: 20px; font-weight: 600; color: var(--text); }
.stepper b { min-width: 28px; text-align: center; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 99px; background: var(--raised); color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; }
.chip.on { background: var(--gold); color: var(--on-gold); }

.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 22px); transform: translateX(-50%); z-index: 50; max-width: calc(100% - 40px); padding: 12px 16px; border-radius: 14px; background: var(--raised); color: var(--text); font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.toast[hidden] { display: none; }

.hr { height: 1px; background: var(--line-soft); }
.plain { color: var(--gold); text-decoration: none; font-weight: 600; }
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

@media (max-width: 360px) {
  .nextname { font-size: 48px; }
  .exname { font-size: 34px; }
  .donehead { font-size: 46px; }
}
