/* Yksi palsta puhelimelle; numerot monospacella, pinkki = tehty/ehdotus. */
:root {
  --bg: #0b0a0b;
  --surface: #161215;
  --line: #2b2228;
  --fg: #f6eef2;
  --dim: #8d7d87;
  --pink: #ff5fa8;
  --pink-soft: #ff5fa833;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 500 16px/1.4 var(--display);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: grid;
  gap: 28px;
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--pink);
}

.log { display: grid; gap: 16px; }
.log[hidden], .table-wrap[hidden] { display: none; }

.switch { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border-radius: 10px; padding: 4px; }
.switch button {
  border: 0;
  background: none;
  padding: 8px;
  border-radius: 7px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--dim);
}
.switch button[aria-selected="true"] { background: var(--pink); color: var(--bg); }

.lifts { display: grid; gap: 12px; }
.lift {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 14px;
}
.lift-head { display: grid; gap: 4px; }
.lift-name { flex: none; font-size: 18px; font-weight: 700; }
.prev { min-width: 0; font: 400 13px var(--mono); color: var(--dim); }
.prev b { color: var(--fg); font-weight: 600; }
.prev-line { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; white-space: nowrap; align-items: baseline; font: 400 13px var(--mono); color: var(--dim); }
.prev-line b { color: var(--fg); font-weight: 600; }
.prev-line .arrow { text-align: center; color: var(--pink); }
.prev-line .now { text-align: right; font-weight: 600; color: var(--pink); }

.controls { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
/* × keskellä sarjojen ja toistojen välissä, ei omaa saraketta */
.controls .x { position: absolute; left: calc((200% + 12px) / 3 + 6px); top: 50%; transform: translate(-50%, -50%); font: 400 18px var(--mono); color: var(--dim); }
.vstep { display: grid; gap: 6px; justify-items: stretch; }
.vstep button {
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: none;
  font: 600 22px var(--mono);
  color: var(--pink);
}
.vstep button:active { background: var(--pink-soft); }
.vstep button:disabled { opacity: .3; cursor: default; }
.vstep button:disabled:active { background: none; }
.vstep input:disabled { opacity: 1; -webkit-text-fill-color: var(--fg); }
.vstep .val {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  font: 700 28px var(--mono);
  font-variant-numeric: tabular-nums;
  min-height: 36px;
}
.vstep input {
  width: 4ch;
  min-width: 1ch;
  border: 0;
  background: none;
  text-align: right;
  font: inherit;
  color: var(--fg);
  padding: 0;
}
.vstep .unit { font: 400 14px var(--mono); color: var(--dim); }

.save {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--bg);
  color: var(--fg);
  font-size: 18px;
  font-weight: 800;
}
.hold {
  position: relative;
  overflow: hidden;
  height: 60px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 18px;
  font-weight: 800;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.hold-fill {
  position: absolute;
  inset: 0;
  background: var(--pink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease-out;
}
.hold.holding .hold-fill { transform: scaleX(1); transition: transform 900ms linear; }
.hold-label { position: relative; }
.hold:disabled { color: var(--dim); cursor: default; }

.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 400 9px var(--mono); fill: var(--dim); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--pink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--pink); }
.chart .dot.miss { fill: var(--surface); stroke: var(--pink); stroke-width: 1.5; }
.chart .end { font: 700 11px var(--mono); fill: var(--fg); }
.chart .fc { fill: none; stroke: var(--pink); stroke-width: 1.5; stroke-dasharray: 3 4; opacity: .6; }
.chart .fc-dot { fill: var(--surface); stroke: var(--pink); stroke-width: 1; opacity: .6; }
.chart .fc-end { fill: var(--pink); }

.ghost {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  background: none;
  color: var(--dim);
  font-size: 14px;
  font-weight: 700;
}
.ghost[aria-expanded="true"] { color: var(--pink); border-color: var(--pink); }

.all { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-family: var(--mono); font-size: 13px; }
.group { background: var(--surface); border-radius: 12px; padding: 4px 10px 6px; min-width: 0; }
.ghead, .sess { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8px; }
.ghead { padding: 8px 0; font: 700 14px var(--display); }
.sess { padding: 12px 0 14px; border-top: 1px solid var(--line); }
.smeta { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.sess .d { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; color: var(--dim); }
.sess .x { border: 0; background: none; color: var(--dim); font: 600 16px var(--mono); padding: 4px 6px; margin: -4px -6px; line-height: 1; }
.sess .x.armed { color: var(--pink); font-size: 11px; }
.cell { min-width: 0; }
.cell .w { display: block; font-weight: 700; overflow-wrap: anywhere; }
.cell .r { display: block; color: var(--fg); }

.summary { display: grid; gap: 12px; }
.summary[hidden] { display: none; }
.sum-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sum-lift-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge { font: 600 11px var(--mono); color: var(--bg); background: var(--pink); border-radius: 6px; padding: 3px 8px; }
.sum-main { font: 700 28px var(--mono); }
.sum-main .unit { font: 400 14px var(--mono); color: var(--dim); margin: 0 6px 0 2px; }
.sum-rows { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font: 400 13px var(--mono); }
.sum-rows span { color: var(--dim); }
.sum-rows b { font-weight: 600; text-align: right; }
.sum-rows i { font-style: normal; color: var(--dim); }
.sum-rows .next { color: var(--pink); }

@media (prefers-reduced-motion: no-preference) {
  .save { transition: background .2s; }

  /* sisääntulo: kortit nousevat porrastetusti, viiva piirtyy, ennuste tulee perään */
  .anim { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }
  .chart .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s .2s cubic-bezier(.4, 0, .2, 1) forwards; }
  .chart .area { animation: fade .8s .3s both; }
  .chart .dot { animation: fade .4s .7s both; }
  .chart .fc, .chart .fc-dot, .chart .fc-end { animation: fade .6s 1.1s both; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes fade { from { opacity: 0; } }
}
