/* App layer on top of nocturne.css: the design's teal accent ramp, and the
   layout of the TrainingsAppV3 screens (one 440px column, timeline list,
   bottom tab bar). Colors, type, radii and shadows all come from the tokens. */

:root {
  color-scheme: dark;
  /* TrainingsAppV3 retunes the Nocturne accent from blurple to teal. */
  --color-accent: #20B2AA;
  --color-accent-100: #d6faf6;
  --color-accent-200: #9ff0e7;
  --color-accent-300: #4fdccf;
  --color-accent-400: #2cc7bc;
  --color-accent-500: #20B2AA;
  --color-accent-600: #189690;
  --color-accent-700: #137872;
  --color-accent-800: #0f5a56;
  --color-accent-900: #0c3b39;
}

[x-cloak] { display: none !important; }

html, body { min-height: 100%; }
body { -webkit-tap-highlight-color: transparent; }
a { color: var(--color-accent-300); }
a:hover { color: var(--color-accent-200); }
button { font: inherit; color: inherit; }

.app-bg {
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 50% at 0% 0%, var(--color-accent-900), var(--color-bg) 60%) var(--color-bg);
  background-attachment: fixed;
}

.page {
  max-width: 440px;
  margin: 0 auto;
  padding: 0 16px calc(110px + env(safe-area-inset-bottom));
}

/* — headers — */
.page-head {
  padding: calc(28px + env(safe-area-inset-top)) 0 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.page-head h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: 0; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-sub { font-size: 13px; color: var(--color-neutral-400); }
.muted-icon { color: var(--color-neutral-500); font-size: 18px; margin-top: -2px; }
.muted-icon:hover { color: var(--color-neutral-300); }

.btn i { font-size: 1.1em; }
.btn-lg { height: 48px; font-size: 15px; gap: 8px; }
.btn-44 { height: 44px; }
.btn-40 { height: 40px; }
.btn-icon.btn-44 { width: 44px; }
.btn-icon.btn-40 { width: 40px; }
.btn-icon.btn-44 i { font-size: 18px; }
.btn-wide { width: 100%; }
.page-head .btn-wide { margin-top: 12px; }
.add-btn { margin-top: 12px; }

.train-head {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px; padding: calc(16px + env(safe-area-inset-top)) 16px 14px;
  background: var(--color-bg);
  display: flex; flex-direction: column; gap: 10px;
}
.train-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.train-head-stats { display: flex; flex-direction: column; gap: 2px; }
.train-head-stats .page-sub { font-size: 12px; font-variant-numeric: tabular-nums; }
.train-count { font-size: 22px; font-weight: 500; }
.train-count span { color: var(--color-neutral-500); }
.train-head-actions { display: flex; align-items: center; gap: 8px; }
.progress { height: 3px; border-radius: 2px; background: var(--color-neutral-800); overflow: hidden; }
.progress > div {
  height: 100%; background: var(--color-accent);
  box-shadow: 0 0 12px var(--color-accent); transition: width .3s ease;
}

/* — timeline — */
.timeline { display: flex; flex-direction: column; padding-top: 4px; }
.tl-section {
  padding: 6px 0 12px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--color-neutral-400);
}
.tl-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-line { flex: 1; width: 2px; margin: 4px 0; border-radius: 1px; }
.node { flex: none; border-radius: 50%; }
.node-done {
  width: 18px; height: 18px; margin-top: 2px;
  background: var(--color-accent); box-shadow: 0 0 12px var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-bg); font-size: 11px;
}
.node-current {
  width: 14px; height: 14px; margin-top: 2px;
  border: 2px solid var(--color-accent); background: var(--color-bg);
  box-shadow: 0 0 10px color-mix(in srgb, var(--color-accent) 60%, transparent);
}
.node-idle {
  width: 10px; height: 10px; margin-top: 6px;
  border: 2px solid var(--color-neutral-700); background: var(--color-bg);
}
.tl-content { display: flex; flex-direction: column; gap: 10px; padding-bottom: 20px; min-width: 0; }
.tl-head { display: flex; flex-direction: column; gap: 3px; cursor: pointer; border-radius: var(--radius-sm); }
.tl-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tl-muscle {
  font-size: 11px; color: var(--color-accent-300); text-transform: uppercase;
  letter-spacing: .08em; padding-top: 2px;
}
.tl-machine {
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px; margin-bottom: -28px;
  color: var(--color-accent-300);
}
.tl-machine span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.tl-machine span:last-child { font-size: 22px; font-weight: 500; line-height: 1.1; }
.tl-name { font-size: 18px; font-weight: 500; line-height: 1.3; text-wrap: pretty; }
.tl-name.has-machine { padding-right: 64px; }
.tl-meta { font-size: 13px; color: var(--color-neutral-400); }
.tl-note { font-size: 13px; color: var(--color-accent-300); display: flex; align-items: center; gap: 5px; }
.tl-body {
  background: var(--color-surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.empty { font-size: 14px; color: var(--color-neutral-400); margin: 8px 0 4px; }

/* — set rows while training — */
.sets { display: flex; flex-direction: column; gap: 6px; }
.set-grid {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) 48px;
  gap: 8px; align-items: center; margin: 0;
}
.set-grid-head {
  font-size: 11px; color: var(--color-neutral-500);
  text-transform: uppercase; letter-spacing: .06em;
}
.set-grid-head span:nth-child(2), .set-grid-head span:nth-child(3) { text-align: center; }
.set-n { font-size: 15px; font-weight: 500; color: var(--color-neutral-300); padding-left: 4px; }
.input-44 { height: 44px; font-size: 16px; min-width: 0; }
.set-grid .input, .input.num { text-align: center; font-size: 16px; }
.input.is-invalid { border-color: var(--color-accent-300); box-shadow: 0 0 0 1px var(--color-accent-300); }
.set-check {
  width: 48px; height: 44px; border-radius: var(--radius-md);
  border: 1px solid var(--color-neutral-700); background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.set-check:hover { border-color: var(--color-accent-600); background: var(--color-accent-900); }
.set-check:active { background: var(--color-accent-800); }
.set-check.is-done {
  border-color: var(--color-accent); background: var(--color-accent-800); color: var(--color-accent-200);
  box-shadow: 0 0 14px color-mix(in srgb, var(--color-accent) 35%, transparent);
}
.adopt-btn { height: 40px; color: var(--color-accent-300); }

/* — exercise edit form — */
.edit { display: flex; flex-direction: column; gap: 12px; }
.edit .field { margin: 0; }
.edit .input { font-size: 16px; } /* 16px keeps iOS from zooming into the field */
.edit-grid { display: grid; gap: 10px; }
.edit-grid-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.edit-grid-3 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.chip { cursor: pointer; background: transparent; font-size: 11px; }
.chip:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.stepper { display: flex; gap: 4px; }
.stepper .btn-icon { width: 36px; height: 44px; flex: none; }
.stepper .input { flex: 1; }
.spark { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.spark-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--color-neutral-400); }
.spark svg { width: 100%; height: 48px; overflow: visible; display: block; }
.last { font-size: 13px; color: var(--color-neutral-400); display: flex; gap: 6px; align-items: center; }
.edit-actions { display: flex; gap: 4px; align-items: center; padding-top: 2px; }
.edit-actions form { margin: 0; }
.delete-btn { color: var(--color-neutral-300); }
.done-btn { margin-left: auto; }

/* — stats (summary dialog, all-done screen) — */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; color: var(--color-neutral-500); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.summary { z-index: 40; padding: 16px; }
.summary .dialog { width: min(380px, 100%); gap: 14px; }
.summary-icon { font-size: 28px; color: var(--color-accent); }

/* — history — */
.sessions { display: flex; flex-direction: column; gap: 10px; }
.session { background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.session-head {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 44px;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.session-head:hover { background: var(--color-accent-900); }
.session-head i { font-size: 16px; color: var(--color-neutral-500); }
.session-title { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.session-date { font-size: 16px; font-weight: 500; }
.session-meta { font-size: 13px; color: var(--color-neutral-400); }
.session-rows { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.session-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.session-row span:first-child { color: var(--color-neutral-300); }
.session-row span:last-child { color: var(--color-neutral-400); font-variant-numeric: tabular-nums; text-align: right; }

/* — tab bar — */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--color-divider);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar-inner { max-width: 440px; margin: 0 auto; display: flex; }
.tab {
  flex: 1; height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font: 500 11px var(--font-body); color: var(--color-neutral-400); text-decoration: none;
}
.tab i { font-size: 22px; }
.tab.active, .tab.active:hover { color: var(--color-accent-300); }
.tab:hover { color: var(--color-neutral-300); }

/* — auth — */
.auth .page-head { padding-top: calc(72px + env(safe-area-inset-top)); }
.auth-mark { font-size: 32px; color: var(--color-accent); margin-bottom: 8px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.auth-form .field { margin: 0; }
.auth-form .input { height: 44px; font-size: 16px; }
.auth-form .btn { margin-top: 6px; }
.auth-alt { margin-top: 18px; font-size: 13px; color: var(--color-neutral-400); }
.form-error { font-size: 13px; color: var(--color-accent-300); display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.field-error { font-size: 12px; color: var(--color-accent-300); margin-top: 4px; }

/* — all-done screen — */
@keyframes tc-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes tc-draw { to { stroke-dashoffset: 0 } }
@keyframes tc-pop { 0% { transform: scale(1) } 40% { transform: scale(1.08) } 100% { transform: scale(1) } }
@keyframes tc-pulse { from { opacity: .7; transform: scale(1) } to { opacity: 0; transform: scale(2.1) } }
@keyframes tc-spark {
  0% { opacity: 0; transform: rotate(var(--a)) translateY(-50px) scaleY(.3) }
  25% { opacity: 1 }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(-112px) scaleY(1) }
}
@keyframes tc-up { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }

.celebrate {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  padding: calc(72px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
  background: radial-gradient(90% 45% at 20% 22%, var(--color-accent-900), var(--color-bg) 70%) var(--color-bg);
  animation: tc-fade .35s ease-out both;
}
.celebrate-inner { flex: 1; width: 100%; max-width: 392px; margin: 0 auto; display: flex; flex-direction: column; }
.celebrate-mark { position: relative; width: 112px; height: 112px; flex: none; }
.celebrate-pulse {
  position: absolute; inset: 4px; border-radius: 50%; border: 1px solid var(--color-accent);
  animation: tc-pulse 1.1s .8s ease-out both;
}
.spark-ray {
  position: absolute; left: 50%; top: 50%; width: 2px; margin: -8px 0 0 -1px; border-radius: 1px;
  background: var(--color-accent-300); box-shadow: 0 0 8px var(--color-accent);
  animation: tc-spark .9s cubic-bezier(.2, .7, .3, 1) both;
}
.celebrate-mark svg {
  position: relative; overflow: visible;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--color-accent) 55%, transparent));
  animation: tc-pop .5s .75s ease-out both;
}
.celebrate-ring { stroke-dasharray: 315; stroke-dashoffset: 315; animation: tc-draw .8s .1s cubic-bezier(.6, 0, .3, 1) both; }
.celebrate-check { stroke-dasharray: 60; stroke-dashoffset: 60; animation: tc-draw .35s .72s ease-out both; }
.celebrate-text { margin-top: 32px; display: flex; flex-direction: column; gap: 6px; }
.celebrate-when { font-size: 13px; color: var(--color-accent-300); }
.celebrate h2 { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: 0; }
.celebrate-stats { margin-top: 24px; }
.celebrate-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.celebrate-actions form { margin: 0; }
.up { animation: tc-up .5s cubic-bezier(.2, .7, .3, 1) both; }

@media (prefers-reduced-motion: reduce) {
  [data-tc], [data-tc] * { animation-duration: .01s !important; animation-delay: 0s !important; }
}
