:root {
  --bg: #101519;
  --surface: #1b2227;
  --surface2: #252e34;
  --field: #f4f6f7;
  --ink: #f7f8f8;
  --muted: #aab4bb;
  --line: #3b484f;
  --red: #e51d2a;
  --orange: #f28a00;
  --green: #8cda3f;
  --shadow: 0 16px 45px #0005;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
#workoutHistory {
  scroll-margin-top: 95px;
}
body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0, #334149 0, transparent 32%),
    linear-gradient(145deg, #1d272d, #0a0e11 72%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  font-size: 16px;
}
.topbar {
  height: 80px;
  border-bottom: 1px solid #ffffff14;
  background: #101519cc;
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  text-decoration: none;
  display: flex;
  align-items: baseline;
  font-weight: 950;
  font-style: italic;
  letter-spacing: -2px;
  font-size: 25px;
}
.brand span {
  color: #ffd82b;
}
.brand b {
  color: var(--red);
  font-size: 31px;
}
.brand small {
  color: #fff;
  font-size: 11px;
  letter-spacing: 0;
  margin-left: 5px;
}
.shell {
  max-width: 1180px;
  margin: auto;
  padding: 32px 24px 100px;
}
.hero-card,
.panel,
.stats article {
  background: linear-gradient(145deg, #252e34ee, #171d21ee);
  border: 1px solid #46535a;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.hero-card {
  padding: 30px;
  display: flex;
  justify-content: space-between;
  gap: 25px;
  align-items: center;
}
.eyebrow {
  color: var(--orange);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
  margin: 0 0 7px;
}
h1,
h2,
p {
  margin-top: 0;
}
h1 {
  font-size: clamp(27px, 4vw, 45px);
  line-height: 1.08;
  margin-bottom: 9px;
}
h2 {
  margin-bottom: 0;
  font-size: 21px;
}
.hero-card p:last-child {
  color: var(--muted);
  margin-bottom: 0;
}
.weight-box {
  min-width: 210px;
}
.weight-box label,
label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.weight-box div {
  display: flex;
  background: var(--field);
  border-radius: 9px;
  align-items: center;
  padding-right: 13px;
  color: #4e5b62;
}
.weight-box input {
  width: 150px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin: 18px 0;
}
.stats article {
  padding: 20px;
}
.stats span,
.stats small {
  display: block;
  color: var(--muted);
}
.stats strong {
  font-size: 29px;
  display: block;
  margin: 3px 0;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}
.panel {
  padding: 23px;
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.history-actions {
  display: flex;
  align-items: center;
  gap: 13px;
}
.import-link {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.import-status {
  min-height: 18px;
  margin: -12px 0 12px;
  color: var(--muted);
  font-size: 12px;
}
.history-search {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto auto;
  gap: 9px;
  align-items: end;
  margin-bottom: 10px;
}
.history-search .danger {
  grid-column: 1 / -1;
  justify-self: end;
}
.history-search-status {
  min-height: 18px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 12px;
}
.history-search button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.history-heading p:last-child {
  color: var(--muted);
  margin-bottom: 0;
}
.history-filter-panel {
  margin-bottom: 18px;
}
.history-filter-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(5, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}
.history-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 14px;
}
.history-filter-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.lift-results-panel {
  padding: 0;
  overflow: hidden;
}
.lift-results-head,
.lift-result-row {
  display: grid;
  grid-template-columns: 105px minmax(150px, 1fr) 125px 110px 110px 92px;
  gap: 12px;
  align-items: center;
}
.lift-results-head {
  padding: 13px 17px;
  background: #11171a;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lift-results {
  max-height: 65vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.lift-result-row {
  padding: 13px 17px;
  border-top: 1px solid #ffffff10;
  color: inherit;
}
.lift-result-row a {
  color: inherit;
  text-decoration: none;
}
.lift-result-row:hover {
  background: #ffffff08;
}
.lift-result-row strong {
  color: #fff;
}
.competition-badge {
  display: block;
  width: fit-content;
  margin-top: 3px;
  border-radius: 999px;
  background: #8cda3f22;
  color: var(--green);
  padding: 2px 6px;
  font-size: 8px;
  font-style: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.competition-no-button {
  border: 1px solid #f28a00;
  border-radius: 7px;
  background: #f28a0018;
  color: #ffc066;
  padding: 7px 8px;
  font: 800 11px inherit;
  cursor: pointer;
}
.competition-no-button:disabled {
  cursor: wait;
  opacity: 0.55;
}
.competition-no-value {
  color: var(--muted);
  text-align: center;
}
.lift-result-row span:nth-last-child(-n + 2) {
  color: #ff8a91;
  font-weight: 800;
}
.live-dot {
  color: var(--muted);
  font-size: 12px;
}
.live-dot:before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
}
.primary,
.secondary,
.danger {
  border: 0;
  border-radius: 9px;
  padding: 13px 18px;
  color: #fff;
  font: 700 15px inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary {
  background: linear-gradient(135deg, var(--red), #ad0812);
  box-shadow: 0 8px 20px #d5122044;
}
.secondary {
  background: #303a40;
  border: 1px solid #536169;
}
.danger {
  background: var(--red);
}
.ghost {
  background: transparent;
  color: #ff727b;
  border: 1px solid #773840;
}
.compact {
  padding: 10px 15px;
}
.text-link {
  color: #ff7a82;
  text-decoration: none;
  font-size: 14px;
}
.bar-chart {
  height: 245px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-bottom: 1px solid #536169;
  padding: 20px 8px 0;
}
.bar {
  flex: 1;
  min-width: 22px;
  background: linear-gradient(0deg, var(--red), var(--orange));
  border-radius: 7px 7px 0 0;
  position: relative;
  min-height: 3px;
}
.bar span {
  position: absolute;
  bottom: -29px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 11px;
}
.bar i {
  position: absolute;
  top: -22px;
  width: 100%;
  text-align: center;
  font-size: 11px;
  font-style: normal;
}
.history {
  display: grid;
  gap: 9px;
  max-height: 460px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-gutter: stable;
}
.history::-webkit-scrollbar {
  width: 10px;
}
.history::-webkit-scrollbar-track {
  background: #151b20;
  border-radius: 10px;
}
.history::-webkit-scrollbar-thumb {
  background: #68757c;
  border: 2px solid #151b20;
  border-radius: 10px;
}
.history::-webkit-scrollbar-thumb:hover {
  background: #f28a00;
}
.history-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 12px;
  background: #ffffff08;
  border: 1px solid #ffffff10;
  padding: 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}
.history-row small {
  color: var(--muted);
}
.history-row strong:last-child {
  color: #ff8a91;
}
.empty {
  color: var(--muted);
  padding: 35px 0;
  text-align: center;
}
.workout-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.head-actions {
  display: flex;
  gap: 9px;
}
.session-info {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 2fr;
  gap: 14px;
  margin-bottom: 18px;
}
input,
select,
textarea {
  display: block;
  width: 100%;
  height: 47px;
  border-radius: 8px;
  border: 1px solid #bfc8cd;
  background: var(--field);
  color: #172027;
  padding: 0 13px;
  font: 600 16px inherit;
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px #f28a0033;
}
textarea {
  min-height: 47px;
  height: 47px;
  padding-top: 12px;
  padding-bottom: 12px;
  resize: vertical;
  line-height: 1.35;
}
.notes-field textarea {
  min-height: 47px;
  max-height: 320px;
}
.exercise {
  background: #ffffff08;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.exercise-top {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 13px;
}
.exercise-name {
  flex: 1;
}
.exercise-name input {
  font-weight: 800;
}
.est-max {
  min-width: 110px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.est-max strong {
  display: block;
  color: #fff;
  font-size: 20px;
}
.remove {
  background: transparent;
  border: 0;
  color: #ff727b;
  font-size: 25px;
  cursor: pointer;
  padding: 8px;
}
.sets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.set-card {
  background: #11171a;
  border: 1px solid #3b474d;
  border-radius: 9px;
  padding: 10px;
}
.set-card span {
  font-size: 11px;
  color: var(--orange);
  font-weight: 800;
}
.set-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 7px;
}
.set-inputs label {
  font-size: 10px;
  margin: 0;
}
.set-inputs input {
  height: 40px;
  margin-top: 3px;
}
.savebar {
  position: sticky;
  bottom: 18px;
  margin-top: 18px;
  background: #1c2429ee;
  backdrop-filter: blur(12px);
  border: 1px solid #536169;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.savebar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.savebar strong {
  font-size: 23px;
}
.mobile-nav {
  display: none;
}
@media (max-width: 760px) {
  body {
    padding-bottom: 70px;
  }
  .topbar {
    height: 65px;
    padding: 0 16px;
  }
  .topbar .secondary {
    display: none;
  }
  .shell {
    padding: 18px 13px 105px;
  }
  .hero-card {
    align-items: stretch;
    flex-direction: column;
    padding: 21px;
  }
  .weight-box {
    min-width: 0;
  }
  .weight-box input {
    width: 100%;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .stats article:last-child {
    grid-column: 1/-1;
  }
  .history-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 7px;
  }
  .history-search {
    grid-template-columns: 1fr 1fr;
  }
  .history-search button {
    width: 100%;
  }
  .history-search .danger {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
  .history-heading {
    gap: 12px;
  }
  .history-heading .head-actions {
    margin-top: 0;
  }
  .history-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .history-filter-grid label:first-child {
    grid-column: 1 / -1;
  }
  .history-filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .history-filter-actions .danger {
    grid-column: 1 / -1;
  }
  .lift-results-head {
    display: none;
  }
  .lift-result-row {
    grid-template-columns: 54px minmax(68px, 1fr) 62px 55px 58px 60px;
    gap: 5px;
    padding: 10px 7px;
    font-size: 10px;
  }
  .competition-no-button {
    padding: 6px 3px;
    font-size: 9px;
  }
  .lift-result-row > * {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .chart-panel {
    order: 2;
  }
  .panel {
    padding: 17px;
  }
  .session-info {
    grid-template-columns: 1fr 1fr;
  }
  .session-info label:last-child {
    grid-column: 1/-1;
  }
  .workout-head {
    align-items: flex-start;
  }
  .workout-head .head-actions {
    margin-top: 32px;
  }
  .workout-head .head-actions button {
    padding: 9px;
    font-size: 12px;
  }
  .sets {
    display: flex;
    overflow-x: auto;
    padding-bottom: 7px;
    scroll-snap-type: x mandatory;
  }
  .set-card {
    min-width: 145px;
    scroll-snap-align: start;
  }
  .exercise-top {
    align-items: center;
  }
  .est-max {
    min-width: 78px;
  }
  .savebar {
    bottom: 78px;
  }
  .mobile-nav {
    position: fixed;
    display: flex;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: #12181cf5;
    border-top: 1px solid #47535a;
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav a {
    flex: 1;
    color: var(--muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 22px;
  }
  .mobile-nav a span {
    font-size: 11px;
  }
  .mobile-nav .active {
    color: #ff4d58;
  }
  .brand {
    font-size: 19px;
  }
  .brand b {
    font-size: 24px;
  }
}
.record-nav {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 9px;
  align-items: center;
  margin: 18px auto 0;
  max-width: 760px;
}
.record-nav button {
  gap: 7px;
}
.record-nav button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.record-nav div {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
@media (max-width: 760px) {
  .record-nav {
    grid-template-columns: repeat(4, 1fr);
  }
  .record-nav button {
    padding: 10px 6px;
    flex-direction: column;
    gap: 1px;
    font-size: 20px;
  }
  .record-nav button span {
    font-size: 11px;
  }
  .record-nav div {
    grid-column: 1/-1;
    grid-row: 1;
  }
}
@media (max-width: 430px) {
  .session-info {
    grid-template-columns: 1fr;
  }
  .session-info label:last-child {
    grid-column: auto;
  }
  .stats strong {
    font-size: 23px;
  }
  .history-row {
    grid-template-columns: 72px 1fr auto;
  }
  .live-dot {
    display: none;
  }
}
.history-row {
  grid-template-columns: 78px minmax(110px, 1fr) auto auto auto;
}
.history-row span small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.history-row span b {
  font-size: 13px;
  white-space: nowrap;
}
.history-best-set b {
  color: #ff8a91;
}
@media (max-width: 430px) {
  .history {
    max-height: 58vh;
  }
  .history-row {
    grid-template-columns: 56px minmax(65px, 1fr) 48px 52px 55px;
    gap: 5px;
    padding: 8px 6px;
  }
  .history-row span {
    min-width: 0;
    padding: 0;
    text-align: center;
  }
  .history-row > small,
  .history-row > strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }
  .history-row span small {
    font-size: 8px;
    letter-spacing: 0;
  }
  .history-row span b {
    font-size: 10px;
  }
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sync-button {
  border: 1px solid #536169;
  background: #20292e;
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 13px;
  font: 700 13px inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}
.sync-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #849097;
}
.sync-button.connected .sync-indicator {
  background: var(--green);
  box-shadow: 0 0 0 3px #8cda3f20;
}
.sync-button.syncing .sync-indicator {
  background: var(--orange);
  animation: pulse 1s infinite;
}
.sync-button.error .sync-indicator {
  background: #ff5c66;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}
.sync-dialog {
  width: min(92vw, 480px);
  border: 1px solid #536169;
  border-radius: 16px;
  padding: 0;
  background: #1b2227;
  color: var(--ink);
  box-shadow: 0 24px 80px #000b;
}
.sync-dialog::backdrop {
  background: #050809bb;
  backdrop-filter: blur(3px);
}
.sync-dialog form {
  padding: 27px;
  position: relative;
}
.sync-dialog h2 {
  font-size: 26px;
  margin-bottom: 10px;
}
.sync-dialog p {
  color: var(--muted);
  line-height: 1.5;
}
.sync-dialog label {
  margin-top: 20px;
}
.dialog-close {
  position: absolute;
  right: 13px;
  top: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}
.sync-warning {
  font-size: 12px;
}
.sync-message {
  min-height: 20px;
  margin: 12px 0 0 !important;
  font-size: 13px;
}
.sync-message.error {
  color: #ff7a82;
}
.sync-message.success {
  color: var(--green);
}
@media (max-width: 760px) {
  .sync-button {
    padding: 8px 10px;
  }
  .sync-button span:last-child {
    font-size: 11px;
  }
  .workout-head {
    flex-direction: column;
  }
  .workout-head .head-actions {
    margin-top: 12px;
    flex-wrap: wrap;
  }
  .workout-head .head-actions .primary {
    padding: 9px;
    font-size: 12px;
  }
}
