:root {
  --bg: #F2F1ED;
  --card: #FFFFFF;
  --ink: #000000;
  --ink-2: #3a3a3a;
  --muted: #7a7a76;
  --line: #E7E5DF;
  --pill: #ECEBE7;
  --lilac: #D4A3F2;
  --lilac-soft: #EFE3FB;
  --lilac-ink: #7A3FA8;
  --orange: #FF7341;
  --orange-soft: #FFE2D6;
  --orange-ink: #B8431A;
  --yellow: #FFC84B;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- top strip + nav ---------- */
.strip {
  background: var(--lilac);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  letter-spacing: .01em;
}
.topbar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand img { height: 46px; width: auto; display: block; }
.brand .event { border-left: 1px solid #cfccc4; padding-left: 14px; line-height: 1.2; }
.brand .event b { display: block; font-size: 15px; }
.brand .event span { font-size: 12.5px; color: var(--muted); }
.nav { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.nav a {
  text-decoration: none;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
}
.nav a:hover { background: rgba(0,0,0,.05); }
.nav a.active { background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
.btn-outline {
  border: 2px solid var(--lilac);
  background: transparent;
  color: var(--lilac-ink);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-outline:hover { background: var(--lilac-soft); }
.btn {
  border: 0;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 999px;
  cursor: pointer;
}
.btn:disabled { opacity: .35; cursor: default; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }

main { max-width: 1280px; margin: 0 auto; padding: 0 24px 64px; }
.card { background: var(--card); border-radius: var(--radius); }
.pad { padding: 22px 24px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.eyebrow { font-size: 13px; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: calc(100vh - 34px); display: grid; place-items: center; padding: 32px 16px; }
.login { width: 100%; max-width: 400px; }
.login .logo { display: block; height: 78px; margin: 0 auto 28px; }
.login h1 { font-size: 24px; }
.login p { margin: 4px 0 22px; color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfaf8;
}
.field input:focus, textarea:focus { outline: 2px solid var(--lilac); outline-offset: 1px; border-color: transparent; }
.login .btn { width: 100%; margin-top: 6px; padding: 13px; }
.error { color: var(--orange-ink); font-size: 13.5px; min-height: 20px; margin-top: 10px; }

/* ---------- score page ---------- */
.score-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.sidebar { position: sticky; top: 16px; display: grid; gap: 14px; }
.progress-num { font-size: 26px; font-weight: 800; margin-top: 2px; }
.progress-num small { font-size: 17px; font-weight: 500; color: var(--muted); }
.bar { height: 6px; background: var(--pill); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; background: var(--lilac); border-radius: 999px; transition: width .3s; }
.plist { position: relative; padding: 8px; display: grid; gap: 2px; max-height: calc(100vh - 230px); overflow-y: auto; }
.pitem {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%;
}
.pitem:hover { background: #f6f5f2; }
.pitem.active { background: var(--lilac-soft); box-shadow: inset 3px 0 0 var(--orange); }
.pitem .tick {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #d8d6cf; display: grid; place-items: center;
}
.pitem .tick.started { border-color: var(--lilac); }
.pitem .tick.done { background: var(--lilac); border-color: var(--lilac); }
.pitem .tick.done::after {
  content: ""; width: 5px; height: 9px; border: solid var(--ink);
  border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px);
}
.pitem .txt { flex: 1; min-width: 0; }
.pitem .txt b { display: block; font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pitem .txt span { font-size: 12.5px; color: var(--muted); }
.pitem .mine { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.panel { display: grid; gap: 14px; }
.presenter-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.presenter-head h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.presenter-head .disc { font-size: 16px; color: var(--ink-2); margin-top: 2px; }
.save-state { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.save-state .dot { width: 8px; height: 8px; border-radius: 50%; background: #9bd39b; }
.save-state.saving .dot { background: var(--yellow); }
.save-state.error { color: var(--orange-ink); }
.save-state.error .dot { background: var(--orange); }

.crit { padding: 20px 24px; border-top: 1px solid var(--line); }
.crit:first-child { border-top: 0; }
.crit-head { display: flex; justify-content: space-between; gap: 12px; }
.crit-head h3 { font-size: 16px; font-weight: 800; }
.crit-head h3 small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.crit-head p { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }
.readout { font-size: 20px; font-weight: 800; white-space: nowrap; }
.readout small { font-size: 14px; font-weight: 500; color: var(--muted); }
.pills { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-top: 14px; }
.pill {
  height: 42px; border: 0; border-radius: 10px;
  background: var(--pill); color: #6d6c68; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: background .12s, transform .06s;
  font-variant-numeric: tabular-nums;
}
.pill:hover { background: #e2e0da; }
.pill:active { transform: scale(.96); }
.pill.below { background: var(--lilac-soft); color: var(--ink); }
.pill.sel { background: var(--ink); color: #fff; font-weight: 800; }

.notes { padding: 20px 24px; }
.notes h3 { font-size: 16px; font-weight: 800; }
.notes p { margin: 3px 0 12px; font-size: 13.5px; color: var(--muted); }
textarea {
  width: 100%; min-height: 130px; resize: vertical;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfaf8;
}
.pager { display: flex; justify-content: space-between; gap: 12px; }

/* ---------- results page ---------- */
.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 18px; font-weight: 800; }
.section-head p { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 18px 0 20px; font-size: 13.5px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend small { color: var(--muted); }

.chart { display: grid; gap: 8px; }
.crow { display: grid; grid-template-columns: 190px 1fr 56px; align-items: center; gap: 14px; }
.crow .nm { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow .nm em { font-style: normal; color: var(--muted); font-weight: 500; margin-right: 8px; font-variant-numeric: tabular-nums; }
.track { height: 28px; position: relative; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--line) calc(10% - 1px) 10%); border-radius: 6px; }
.segs { display: flex; height: 100%; gap: 2px; }
.segs i { display: block; height: 100%; border-radius: 5px; transition: width .4s; }
.crow .tot { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.crow .tot.none { color: var(--muted); font-weight: 500; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
thead th {
  background: #F7F6F3; font-size: 12.5px; font-weight: 600; color: var(--muted);
  text-align: right; padding: 12px 16px; white-space: nowrap;
}
thead th:nth-child(-n+2) { text-align: left; }
tbody td { padding: 14px 16px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
tbody td:nth-child(-n+2) { text-align: left; }
td.rank { font-weight: 700; width: 56px; }
td.team b { display: block; font-weight: 700; }
td.team span { font-size: 12.5px; color: var(--muted); }
td.total { font-size: 18px; font-weight: 800; }
td.cell { color: var(--ink-2); }
td.cell.flag { background: var(--orange-soft); color: var(--orange-ink); font-weight: 700; box-shadow: inset 0 0 0 1px #ffc3ad; }
tr.row-flag td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--orange-soft); color: var(--orange-ink);
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-left: 8px;
}
tr.expandable { cursor: pointer; }
tr.expandable:hover td { background-color: #FBFAF8; }
tr.expandable:hover td.cell.flag { background-color: var(--orange-soft); }
.chev { display: inline-block; width: 16px; color: var(--muted); transition: transform .15s; }
tr.open .chev { transform: rotate(90deg); }
tr.detail td { background: #FBFAF8; padding: 0 16px 18px; text-align: left; border-top: 0; }
.detail-grid { display: grid; gap: 8px; }
.jrow {
  display: grid; grid-template-columns: 170px repeat(var(--n, 5), 92px) 70px 1fr; gap: 0 8px; align-items: start;
  background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 13.5px;
}
.jrow.head { background: transparent; padding: 10px 14px 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.jrow .v { text-align: center; font-variant-numeric: tabular-nums; border-radius: 6px; padding: 1px 0; }
.jrow .v.extreme { background: var(--orange-soft); color: var(--orange-ink); font-weight: 800; }
.jrow .t { text-align: center; font-weight: 800; }
.jrow .n { white-space: pre-wrap; color: var(--ink-2); }
.jrow.pending { color: var(--muted); }

.progress-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; }
.jprog { background: #F7F6F3; border-radius: 12px; padding: 12px 14px; }
.jprog b { font-size: 14px; }
.jprog .row { display: flex; justify-content: space-between; font-size: 13px; }
.flag-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 12px 24px 18px; }
.flag-note i { width: 14px; height: 14px; border-radius: 4px; background: var(--orange-soft); box-shadow: inset 0 0 0 1px #ffc3ad; }
.updated { font-size: 12.5px; color: var(--muted); }

/* ---------- manage page ---------- */
.manage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grip-inline { font-weight: 800; color: var(--ink); }
.mlist { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.mlist .empty { color: var(--muted); padding: 12px 0; }
.mrow {
  display: flex; align-items: center; gap: 10px;
  background: #F7F6F3; border-radius: 12px; padding: 8px 10px;
  transition: box-shadow .15s, background .15s;
}
.mrow .pos { width: 20px; text-align: center; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.mrow .fields { flex: 1; min-width: 0; display: grid; }
.mrow .count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.handle {
  border: 0; background: transparent; cursor: grab; font-size: 18px; line-height: 1;
  padding: 6px 4px; color: #9a9893; touch-action: none; border-radius: 6px;
}
.handle:hover, .handle:focus-visible { color: var(--ink); background: rgba(0,0,0,.05); }
.sorting, .sorting * { cursor: grabbing !important; user-select: none; }
.mrow.dragging { background: var(--lilac-soft); box-shadow: 0 8px 24px rgba(0,0,0,.12), inset 3px 0 0 var(--orange); position: relative; z-index: 1; }
input.inline {
  width: 100%; border: 1px solid transparent; background: transparent; border-radius: 8px;
  padding: 2px 6px; margin-left: -6px; text-overflow: ellipsis;
}
input.inline:hover { border-color: var(--line); background: #fff; }
input.inline:focus { outline: 2px solid var(--lilac); background: #fff; }
input.inline.strong { font-weight: 700; }
input.inline.muted { font-size: 13px; color: var(--muted); }
.remove {
  border: 0; background: transparent; color: #9a9893; font-size: 20px; line-height: 1;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; flex: none;
}
.remove:hover { background: var(--orange-soft); color: var(--orange-ink); }
.link-btn { border: 0; background: transparent; color: var(--lilac-ink); font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 4px; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }
.add-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.add-form input {
  flex: 1 1 140px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfaf8;
}
.add-form input:focus { outline: 2px solid var(--lilac); border-color: transparent; }
.add-form .btn { padding: 10px 20px; }
.add-form input.grow { flex: 3 1 220px; }
.span-2 { grid-column: 1 / -1; }
.weight-field { display: inline-flex; align-items: center; gap: 2px; flex: none; font-weight: 700; color: var(--muted); }
.add-form .weight-field input { width: 76px; flex: none; text-align: right; }
.weight-field.compact input.inline { width: 58px; margin: 0; text-align: right; font-weight: 700; color: var(--ink); }
.weight-field.compact input.inline::-webkit-inner-spin-button { opacity: .4; }
.weight-note { margin: 10px 2px 0; font-size: 13px; }
.weight-note.ok { color: var(--muted); }
.weight-note.warn { color: var(--orange-ink); font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--orange-ink); }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .manage-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .score-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; }
  .plist { display: flex; overflow-x: auto; max-height: none; gap: 6px; scroll-snap-type: x proximity; }
  .pitem { min-width: 190px; scroll-snap-align: start; background: #f6f5f2; }
}
@media (max-width: 640px) {
  .topbar { padding: 14px 16px; gap: 12px; flex-wrap: wrap; }
  .brand img { height: 38px; }
  .brand .event { display: none; }
  .nav { margin-left: auto; }
  .nav a { padding: 7px 12px; }
  .who { width: 100%; justify-content: space-between; order: 3; }
  main { padding: 0 16px 48px; }
  .pad, .crit, .notes { padding: 18px 16px; }
  .presenter-head h1 { font-size: 28px; }
  .pills { gap: 4px; }
  .pill { height: 44px; font-size: 13.5px; border-radius: 8px; }
  .crow { grid-template-columns: 96px 1fr 40px; gap: 8px; }
  .crow .nm { font-size: 13px; }
  .crow .nm em { display: none; }
  .jrow { grid-template-columns: 110px repeat(var(--n, 5), 40px) 48px; }
  .jrow.head .v { font-size: 0; }
  .jrow.head .v::first-letter { font-size: 12px; }
  .jrow .n { grid-column: 1 / -1; margin-top: 6px; }
  .jrow.head .n { display: none; }
}
