:root {
  --bg: #000;
  --panel: #111;
  --panel-2: #1b1b1b;
  --text: #fff;
  --muted: #d8d8d8;
  --border: #fff;
  --focus: #ffd800;
  --danger: #ffb3b3;
  --button-min: 3rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 20px;
}

body {
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: var(--text);
  background: var(--panel);
  border: 3px solid var(--border);
  border-radius: 0.8rem;
  min-height: var(--button-min);
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 6px solid var(--focus);
  outline-offset: 4px;
}

button:active {
  transform: scale(0.98);
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) 0.75rem env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2rem;
  min-height: 2rem;
  padding: 0.15rem 0;
}

.app-header h1 {
  margin: 0;
  padding: 0 6.9rem 0 4.2rem;
  font-size: 0.75rem;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-button {
  position: absolute;
  left: 0;
  top: 0.15rem;
  min-height: 1.7rem;
  min-width: 3.6rem;
  border-width: 2px;
  border-radius: 0.45rem;
  font-size: 0.75rem;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.screen-container {
  width: 100%;
  max-width: 54rem;
  margin: 0 auto;
  padding-bottom: 0.25rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.home-today {
  margin: 0.2rem 0 0.65rem;
  padding: 0.45rem;
  background: var(--panel);
  border: 3px solid var(--border);
  border-radius: 0.8rem;
  text-align: center;
}

.home-today-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.home-today-value {
  display: block;
  font-size: clamp(1.4rem, 8vw, 2.2rem);
  font-weight: 900;
  line-height: 1;
}

.tile-grid,
.exercise-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tile-button,
.exercise-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 0;
  padding: 0.5rem;
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  font-weight: 900;
}

.exercise-button {
  min-height: 0;
}

.icon-holder {
  width: clamp(2.2rem, 12vw, 3.6rem);
  height: clamp(2.2rem, 12vw, 3.6rem);
}

.icon-holder svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.info-card {
  margin: 0.2rem 0 0.45rem;
  padding: 0.45rem;
  border: 3px solid var(--border);
  border-radius: 0.8rem;
  background: var(--panel);
  text-align: center;
}

.info-card .label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
}

.info-card .primary-value {
  margin-top: 0.4rem;
  font-size: clamp(1.5rem, 9vw, 2.5rem);
  font-weight: 900;
  line-height: 1;
}

.info-card .secondary-values {
  margin-top: 0.25rem;
  font-size: clamp(0.8rem, 3.8vw, 1.1rem);
  font-weight: 800;
  line-height: 1.35;
}

.weight-adjuster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: stretch;
  margin: 0.35rem 0;
}

.adjust-column {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 0.25rem;
  min-width: 0;
}

.adjust-label {
  text-align: center;
  font-size: clamp(0.75rem, 3.5vw, 1rem);
  font-weight: 900;
  color: var(--muted);
}

.adjust-value {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.1rem;
  padding: 0.15rem;
  border: 4px solid var(--border);
  border-radius: 1rem;
  background: var(--panel-2);
  font-size: clamp(1.8rem, 9vw, 3rem);
  font-weight: 900;
  line-height: 1;
}

.adjust-button {
  min-height: 1.7rem;
  font-size: clamp(1.3rem, 7vw, 2rem);
  font-weight: 900;
  line-height: 1;
}

.live-conversion {
  margin: 0.35rem 0;
  padding: 0.45rem;
  border: 3px solid var(--border);
  border-radius: 0.8rem;
  background: var(--panel);
  text-align: center;
  font-size: clamp(0.85rem, 4vw, 1.1rem);
  font-weight: 900;
  line-height: 1.4;
}

.bottom-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-top: auto;
}

.bottom-actions button {
  min-height: 3.4rem;
  font-size: clamp(1.2rem, 6vw, 1.8rem);
  font-weight: 900;
}

.cancel-button {
  color: var(--danger);
}

.placeholder-page {
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 4px dashed var(--border);
  border-radius: 1.2rem;
  padding: 2rem;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  font-weight: 900;
}

.exercise-entry-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25rem 1fr 1.45fr;
  grid-template-areas:
    "weightLabel weightLabel dotSpacer repsLabel repsLabel"
    "kgWhole kgDecimal dot reps reps";
  gap: 0.25rem;
  align-items: end;
  margin-top: 1rem;
}

.weight-section-label {
  grid-area: weightLabel;
}

.reps-section-label {
  grid-area: repsLabel;
}

.weight-section-label,
.reps-section-label {
  text-align: center;
  font-size: clamp(1.5rem, 7vw, 2.4rem);
  font-weight: 900;
  color: var(--muted);
}

.kg-whole {
  grid-area: kgWhole;
}

.kg-decimal {
  grid-area: kgDecimal;
}

.decimal-point {
  grid-area: dot;
  align-self: center;
  justify-self: center;
  padding-top: 4.7rem;
  font-size: clamp(3rem, 13vw, 5rem);
  font-weight: 900;
}

.reps-control {
  grid-area: reps;
  margin-left: 0.6rem;
}

.exercise-entry-layout .adjust-column {
  grid-template-rows: auto 1fr auto;
}

.exercise-entry-layout .adjust-value {
  min-height: 6.2rem;
}

.exercise-entry-layout .adjust-button {
  min-height: 5.5rem;
}

@media (max-width: 420px) {
  .app-shell {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .exercise-entry-layout {
    grid-template-columns: 1fr 1fr 0.9rem 1fr;
    grid-template-areas:
      "weightLabel weightLabel dotSpacer repsLabel"
      "kgWhole kgDecimal dot reps";
    gap: 0.35rem;
  }

  .reps-control {
    margin-left: 0.25rem;
  }
}


/* Version 1.1 fixed-screen refinements */
.tile-grid {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.exercise-grid {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.tile-button {
  font-size: clamp(1.05rem, 5.8vw, 1.8rem);
}

.weight-adjuster .adjust-button {
  min-height: 1.55rem;
  border-width: 3px;
  border-radius: 0.65rem;
}

.weight-adjuster .adjust-value {
  min-height: 2.9rem;
}

@media (max-height: 720px) {
  .info-card .primary-value {
    font-size: clamp(1.25rem, 7vw, 2rem);
  }

  .weight-adjuster .adjust-value {
    min-height: 2.4rem;
  }

  .bottom-actions button {
    min-height: 2.8rem;
  }
}


/* Version 1.2 visual simplification */
:root {
  --panel: #242424;
  --panel-2: #242424;
  --border: transparent;
}

button {
  background: var(--panel);
  border: 0;
}

.home-today {
  margin: 0.1rem 0 0.35rem;
  padding: 0.25rem 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.home-today-label {
  font-size: 0.7rem;
  margin-bottom: 0.05rem;
}

.home-today-value {
  font-size: clamp(1.05rem, 6vw, 1.65rem);
}

.tile-grid {
  gap: 0;
}

.tile-grid > .tile-button {
  align-self: center;
  justify-self: center;
  width: min(78%, 11rem);
  height: min(64%, 8.5rem);
  min-height: 0;
  padding: 0.45rem;
  background: var(--panel);
  border: 0;
  border-radius: 0.9rem;
  font-size: clamp(0.95rem, 5vw, 1.5rem);
}

.tile-grid .icon-holder {
  width: clamp(1.8rem, 10vw, 3rem);
  height: clamp(1.8rem, 10vw, 3rem);
}

.info-card {
  margin: 0.1rem 0 0.3rem;
  padding: 0.25rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.info-card .label {
  font-size: 0.65rem;
}

.info-card .primary-value {
  margin-top: 0.15rem;
  font-size: clamp(1.2rem, 7vw, 1.9rem);
}

.info-card .secondary-values {
  margin-top: 0.15rem;
  font-size: clamp(0.65rem, 3.2vw, 0.9rem);
}

.weight-adjuster {
  gap: 1.6rem;
  margin: 0.25rem 0;
}

.adjust-value {
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
}

.weight-adjuster .adjust-button,
.bottom-actions button,
.back-button,
.exercise-button,
.exercise-entry-layout .adjust-button {
  background: var(--panel);
  border: 0;
}

.weight-adjuster .adjust-button {
  min-height: 1.25rem;
  border-radius: 0.5rem;
  font-size: clamp(1.05rem, 6vw, 1.55rem);
}

.weight-adjuster .adjust-value {
  min-height: 2.25rem;
}

.live-conversion {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 0.5rem;
  margin: 0.2rem 0;
  padding: 0.2rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: clamp(0.7rem, 3.4vw, 0.95rem);
  line-height: 1.15;
}

.live-conversion span {
  display: block;
  text-align: center;
  white-space: nowrap;
}

.placeholder-page {
  border: 0;
}


/* Version 1.3 Log Weight vertical layout refinements */
.screen-container[data-screen="logWeight"] {
  display: flex;
  flex-direction: column;
}

.screen-container[data-screen="logWeight"] .info-card {
  flex: 0 0 auto;
  margin-bottom: 0.15rem;
}

.screen-container[data-screen="logWeight"] .weight-adjuster {
  flex: 1 1 auto;
  min-height: 0;
  align-items: center;
  margin: 0;
  padding: 0 0.15rem;
}

.screen-container[data-screen="logWeight"] .adjust-column {
  align-self: center;
  grid-template-rows: auto auto auto auto;
  gap: 0.35rem;
}

.screen-container[data-screen="logWeight"] .adjust-label {
  font-size: clamp(0.7rem, 3.2vw, 0.95rem);
}

.screen-container[data-screen="logWeight"] .weight-adjuster .adjust-button {
  min-height: clamp(2.4rem, 10vh, 3.4rem);
  border-radius: 0.75rem;
  font-size: clamp(2rem, 10vw, 3.2rem);
}

.screen-container[data-screen="logWeight"] .weight-adjuster .adjust-value {
  min-height: clamp(4.2rem, 15vh, 5.4rem);
  font-size: clamp(3rem, 15vw, 5rem);
}

.screen-container[data-screen="logWeight"] .live-conversion {
  flex: 0 0 auto;
  margin: 0 0 0.3rem;
  padding: 0.1rem 0 0.2rem;
  font-size: clamp(1.45rem, 7.8vw, 2.25rem);
  font-weight: 900;
  line-height: 1;
}

.screen-container[data-screen="logWeight"] .bottom-actions {
  flex: 0 0 auto;
  margin-top: 0;
}

@media (max-height: 640px) {
  .screen-container[data-screen="logWeight"] .weight-adjuster .adjust-button {
    min-height: 2.05rem;
    font-size: clamp(1.7rem, 9vw, 2.6rem);
  }

  .screen-container[data-screen="logWeight"] .weight-adjuster .adjust-value {
    min-height: 3.35rem;
    font-size: clamp(2.4rem, 13vw, 4rem);
  }
}

/* Version 1.6 View Weight layout */
.screen-container[data-screen="logWeight"] .live-conversion {
  font-size: clamp(1.3rem, 7vw, 2rem);
}

.header-unit-toggle-bar {
  position: absolute;
  right: 0;
  top: 0.15rem;
  display: flex;
  gap: 0.2rem;
}

.unit-toggle-button {
  min-height: 1.7rem;
  min-width: 2rem;
  padding: 0.1rem 0.2rem;
  border-width: 2px;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  line-height: 1;
  font-weight: 900;
  background: var(--panel);
}

.unit-toggle-button.selected {
  outline: 3px solid var(--text);
  outline-offset: -3px;
}

.view-weight-page {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.25rem;
  overflow: hidden;
}

.view-weight-today {
  text-align: center;
  align-self: start;
}

.view-label {
  color: var(--muted);
  font-size: clamp(0.75rem, 3.2vw, 0.95rem);
  font-weight: 900;
  margin-bottom: 0.1rem;
}

.view-today-value {
  font-size: clamp(2.2rem, 12vw, 4rem);
  line-height: 1;
  font-weight: 900;
}

.weight-stats-table {
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 5vh, 1.6rem);
  width: 100%;
}

.weight-comparison-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto;
  column-gap: 0.35rem;
  row-gap: 0.15rem;
  align-items: center;
  text-align: center;
}

.weight-comparison-label {
  grid-column: 1 / 4;
  color: var(--muted);
  font-size: clamp(0.85rem, 4vw, 1.15rem);
  line-height: 1;
  font-weight: 900;
}

.weight-comparison-value,
.weight-comparison-change {
  font-size: clamp(1.15rem, 6vw, 2rem);
  line-height: 1.05;
  font-weight: 900;
  white-space: nowrap;
}

.history-button {
  flex: 0 0 auto;
  min-height: 3.1rem;
  font-size: clamp(1.15rem, 5.8vw, 1.7rem);
  font-weight: 900;
  border-radius: 0.75rem;
  background: var(--panel);
}

@media (max-height: 640px) {
  .view-today-value {
    font-size: clamp(1.8rem, 9.5vw, 3.1rem);
  }

  .weight-stats-table {
    gap: 0.55rem;
  }

  .weight-comparison-label {
    font-size: clamp(0.75rem, 3.4vw, 0.95rem);
  }

  .weight-comparison-value,
  .weight-comparison-change {
    font-size: clamp(0.95rem, 5vw, 1.55rem);
  }

  .history-button {
    min-height: 2.65rem;
  }
}


/* Version 1.7 View Weight spacing and readability refinements */
.weight-stats-table {
  gap: clamp(1.35rem, 7vh, 2.45rem);
}

.weight-comparison-row {
  row-gap: 0.45rem;
}

.weight-comparison-value,
.weight-comparison-change {
  font-size: clamp(1.45rem, 7vw, 2.45rem);
  font-weight: 400;
}

@media (max-height: 640px) {
  .weight-stats-table {
    gap: 0.95rem;
  }

  .weight-comparison-row {
    row-gap: 0.3rem;
  }

  .weight-comparison-value,
  .weight-comparison-change {
    font-size: clamp(1.15rem, 5.8vw, 1.75rem);
    font-weight: 400;
  }
}

/* Version 1.8 View Weight number-only table and history screen */
.weight-comparison-value {
  font-variant-numeric: tabular-nums;
}

.weight-history-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.4rem 0.15rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  -webkit-overflow-scrolling: touch;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  align-items: center;
  min-height: 3rem;
  background: var(--panel);
  border-radius: 0.65rem;
  padding: 0.45rem 0.25rem;
  box-sizing: border-box;
}

.history-date,
.history-weight,
.history-change {
  text-align: center;
  font-size: clamp(1.05rem, 5.2vw, 1.7rem);
  line-height: 1.05;
  font-weight: 400;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-empty {
  margin: auto;
  text-align: center;
  font-size: clamp(1.4rem, 7vw, 2.2rem);
  font-weight: 400;
}

@media (max-height: 640px) {
  .history-list {
    gap: 0.4rem;
    padding-top: 0.25rem;
  }

  .history-row {
    min-height: 2.55rem;
    padding-block: 0.35rem;
  }

  .history-date,
  .history-weight,
  .history-change {
    font-size: clamp(0.95rem, 4.7vw, 1.45rem);
  }
}

/* Version 1.9 history weekday and exercise comparison panel */
.history-date {
  font-size: clamp(0.9rem, 4.6vw, 1.45rem);
}

.screen-container[data-screen="exerciseLog"] .exercise-entry-layout {
  flex: 0 0 auto;
  margin-top: 0.4rem;
}

.exercise-comparison-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0.55rem 0 0.45rem;
  padding: 0.15rem 0.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.exercise-comparison-row,
.exercise-comparison-empty {
  color: var(--muted);
  font-size: clamp(0.95rem, 4.8vw, 1.45rem);
  line-height: 1.1;
  text-align: center;
  font-weight: 400;
  white-space: nowrap;
}

.exercise-comparison-row.active {
  color: var(--text);
  font-size: clamp(1.15rem, 5.6vw, 1.75rem);
}

@media (max-height: 640px) {
  .screen-container[data-screen="exerciseLog"] .exercise-entry-layout {
    margin-top: 0.15rem;
  }

  .exercise-entry-layout .adjust-button {
    min-height: 4.7rem;
  }

  .exercise-entry-layout .adjust-value {
    min-height: 5.1rem;
  }

  .exercise-comparison-panel {
    margin-top: 0.3rem;
    gap: 0.25rem;
  }

  .exercise-comparison-row,
  .exercise-comparison-empty {
    font-size: clamp(0.85rem, 4.2vw, 1.25rem);
  }

  .exercise-comparison-row.active {
    font-size: clamp(1rem, 4.9vw, 1.45rem);
  }
}


/* Version 1.10 Log Exercise responsiveness, heading consistency, no decimal marker, and test data support */
.screen-container[data-screen="exerciseLog"] .exercise-entry-layout {
  grid-template-columns: 1fr 1fr 0.5fr 1.45fr;
  grid-template-areas:
    "weightLabel weightLabel spacer repsLabel"
    "kgWhole kgDecimal spacer reps";
  column-gap: 0.25rem;
}

.screen-container[data-screen="exerciseLog"] .weight-section-label,
.screen-container[data-screen="exerciseLog"] .reps-section-label {
  font-size: clamp(0.75rem, 3.5vw, 1rem);
  font-weight: 900;
  color: var(--muted);
  line-height: 1;
}

.decimal-point {
  display: none !important;
}

.screen-container[data-screen="exerciseLog"] .adjust-button {
  touch-action: manipulation;
}

@media (max-width: 420px) {
  .screen-container[data-screen="exerciseLog"] .exercise-entry-layout {
    grid-template-columns: 1fr 1fr 0.35fr 1.35fr;
    grid-template-areas:
      "weightLabel weightLabel spacer repsLabel"
      "kgWhole kgDecimal spacer reps";
  }
}

/* Version 1.12 View Exercise history */
.exercise-history-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.exercise-history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.25rem 0.15rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

.exercise-history-row {
  display: grid;
  grid-template-columns: 0.85fr 1.35fr 1fr;
  gap: 0.35rem;
  align-items: start;
  background: transparent;
  padding: 0.45rem 0.1rem;
  box-sizing: border-box;
}

.exercise-history-date,
.exercise-history-sets,
.exercise-history-changes {
  font-size: clamp(0.95rem, 4.8vw, 1.55rem);
  line-height: 1.25;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.exercise-history-date {
  text-align: center;
  white-space: nowrap;
}

.exercise-history-sets {
  text-align: left;
}

.exercise-history-changes {
  text-align: center;
  white-space: nowrap;
}

.exercise-history-sets > div,
.exercise-history-changes > div {
  min-height: 1.35em;
  margin-bottom: 0.15rem;
}

.exercise-history-empty {
  margin: auto;
  text-align: center;
  font-size: clamp(1.4rem, 7vw, 2.2rem);
  font-weight: 400;
}

@media (max-height: 640px) {
  .exercise-history-list {
    gap: 0.55rem;
  }

  .exercise-history-row {
    padding-block: 0.25rem;
  }

  .exercise-history-date,
  .exercise-history-sets,
  .exercise-history-changes {
    font-size: clamp(0.85rem, 4.2vw, 1.3rem);
  }
}
