:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #141922;
  --panel-soft: #1b2230;
  --border: #2b3545;
  --text: #f5f7fb;
  --muted: #aab4c3;
  --accent: #63e6be;
  --accent-strong: #32d296;
  --warning: #ffd166;
  --danger: #ff7a7a;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(99, 230, 190, 0.12), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header,
.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1rem 0.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.app-header h1,
.section-title h2,
.hero h2 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: clamp(1.35rem, 6vw, 2.4rem);
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.unit-pill {
  min-width: 3rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 800;
  text-align: center;
}

.account-pill {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 6.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 0.45rem 0.6rem;
}

.account-pill span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.account-pill a {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.account-pill a + a {
  margin-top: 0.1rem;
}

.app-shell {
  padding: 0.75rem 1rem 6rem;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.hero,
.panel,
.metric-card,
.result-card,
.history-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(20, 25, 34, 0.96);
  box-shadow: var(--shadow);
}

.hero {
  padding: 1.2rem;
}

.hero h2,
.section-title h2 {
  font-size: clamp(1.6rem, 7vw, 2.7rem);
}

.muted,
.empty-state {
  color: var(--muted);
}

.hero-actions,
.button-row,
.panel-heading,
.workout-topline {
  display: flex;
  gap: 0.75rem;
}

.hero-actions,
.button-row {
  flex-wrap: wrap;
  margin-top: 1rem;
}

.panel-heading,
.workout-topline {
  align-items: center;
  justify-content: space-between;
}

.workout-topline,
.workout-actions {
  flex-wrap: wrap;
}

.workout-actions {
  display: flex;
  gap: 0.5rem;
}

.panel-heading h3 {
  margin: 0;
}

.primary,
.secondary,
.ghost,
.text-button {
  min-height: 2.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.7rem 1rem;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #03100c;
}

.secondary {
  background: var(--panel-soft);
  border-color: var(--border);
  color: var(--text);
}

.ghost,
.text-button {
  background: transparent;
  color: var(--accent);
}

.ghost {
  border-color: var(--border);
}

.text-button {
  min-height: auto;
  padding: 0.25rem;
  border: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.metric-card {
  padding: 1rem;
}

.metric-card span,
.workout-topline span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.metric-card strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.5rem;
}

.panel,
.result-card,
.history-card {
  margin-top: 0.85rem;
  padding: 1rem;
}

.section-title {
  margin: 0.25rem 0 0.85rem;
}

.form-stack {
  display: grid;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1118;
  color: var(--text);
  padding: 0.72rem 0.8rem;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(99, 230, 190, 0.35);
  border-color: var(--accent);
}

.form-message {
  min-height: 1.25rem;
  margin: 0;
  color: var(--warning);
}

.form-message.success {
  color: var(--accent);
}

.result-stack {
  display: grid;
  gap: 0.85rem;
}

.result-card {
  box-shadow: none;
}

.result-card.exact {
  border-color: rgba(99, 230, 190, 0.7);
}

.result-card.warning {
  border-color: rgba(255, 209, 102, 0.7);
}

.result-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.result-label h3,
.result-label p {
  margin: 0;
}

.plate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.plate-chip {
  min-width: 3.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 0.5rem 0.65rem;
  text-align: center;
  font-weight: 800;
}

.inventory-list {
  display: grid;
  gap: 0.65rem;
}

.inventory-row,
.set-row {
  display: grid;
  gap: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1118;
  padding: 0.75rem;
}

.inventory-row {
  grid-template-columns: minmax(5rem, 1fr) minmax(4rem, 0.8fr) auto;
  align-items: end;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.85rem;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
}

.inline-form,
.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.inline-form button {
  grid-column: 1 / -1;
}

.workout-panel {
  margin-top: 0;
}

.draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  border: 1px solid rgba(99, 230, 190, 0.6);
  border-radius: 8px;
  background: rgba(20, 25, 34, 0.96);
  padding: 0.85rem;
}

.draft-banner[hidden] {
  display: none;
}

.draft-banner strong {
  display: block;
  margin-top: 0.15rem;
}

.draft-actions {
  margin-top: 0;
}

.set-list {
  display: grid;
  gap: 0.65rem;
}

.set-row {
  grid-template-columns: 1fr;
}

.set-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.set-action {
  min-height: 2.35rem;
  padding: 0.45rem 0.75rem;
}

.danger-action {
  border-color: rgba(255, 122, 122, 0.55);
  color: var(--danger);
}

.active-set-editor {
  border-color: rgba(99, 230, 190, 0.55);
}

.active-subtotals[hidden] {
  display: none;
}

.active-subtotal-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.active-subtotal-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.active-subtotal-row strong {
  overflow-wrap: anywhere;
}

.active-subtotal-row span {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}

.set-row strong,
.history-card strong {
  font-size: 1.05rem;
}

.set-meta,
.history-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.history-list {
  display: grid;
  gap: 0.85rem;
}

.history-card ul {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.history-card-heading,
.detail-title-row,
.detail-exercise-heading,
.detail-set-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-view {
  min-height: 2.35rem;
  padding: 0.45rem 0.75rem;
}

.exercise-link,
.detail-exercise-link {
  font-size: inherit;
  text-align: left;
}

.detail-content,
.detail-exercise-list {
  display: grid;
  gap: 0.85rem;
}

.detail-summary {
  margin-top: 0;
}

.detail-time {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.detail-metric-grid div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1118;
  padding: 0.65rem;
}

.detail-metric-grid span,
.detail-notes span,
.detail-exercise-heading span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.detail-metric-grid strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.detail-notes {
  margin-top: 0.85rem;
}

.detail-notes p {
  margin: 0.25rem 0 0;
  overflow-wrap: anywhere;
}

.detail-exercise {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(20, 25, 34, 0.96);
  padding: 0.85rem;
}

.detail-exercise-heading {
  margin-bottom: 0.7rem;
}

.detail-exercise-heading h3,
.detail-exercise-list h3 {
  margin: 0;
  font-size: 1rem;
}

.detail-set,
.detail-history-set {
  gap: 0.4rem;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.2rem;
  border-top: 1px solid var(--border);
  background: rgba(9, 11, 15, 0.96);
  padding: 0.45rem;
}

.bottom-nav button {
  min-height: 3rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.bottom-nav button.is-active {
  background: var(--panel-soft);
  color: var(--accent);
}

.test-link {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  padding: 0.7rem 1rem;
  font-weight: 800;
  text-decoration: none;
}

.test-shell {
  padding-bottom: 2rem;
}

.test-title {
  margin: 0;
}

.test-summary {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  font-weight: 800;
}

.test-summary.passed {
  border-color: rgba(99, 230, 190, 0.7);
  color: var(--accent);
}

.test-summary.failed {
  border-color: rgba(255, 122, 122, 0.8);
  color: var(--danger);
}

.test-results {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.test-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 1rem;
}

.test-card.passed {
  border-color: rgba(99, 230, 190, 0.45);
}

.test-card.failed {
  border-color: rgba(255, 122, 122, 0.8);
}

.test-card p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.auth-shell {
  padding-bottom: 2rem;
}

.auth-panel {
  max-width: 34rem;
  margin-right: auto;
  margin-left: auto;
}

.auth-message {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1rem 0;
  padding: 0.85rem;
}

.auth-message.error {
  border-color: rgba(255, 122, 122, 0.8);
  color: var(--danger);
}

.auth-message p {
  margin: 0;
}

.auth-message p + p {
  margin-top: 0.4rem;
}

.auth-alt {
  margin: 1rem 0 0;
  color: var(--muted);
}

.auth-alt a,
.auth-summary a {
  color: var(--accent);
}

.auth-summary {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.auth-summary div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1118;
  padding: 0.85rem;
}

.auth-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-summary strong {
  display: block;
  margin-top: 0.25rem;
}

.auth-button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

@media (min-width: 760px) {
  .app-shell {
    padding-bottom: 2rem;
  }

  .screen.is-active {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .section-title,
  .hero,
  #history .history-list,
  .detail-content,
  #workout .draft-banner,
  #workout .active-subtotals {
    grid-column: 1 / -1;
  }

  .bottom-nav {
    right: auto;
    left: 50%;
    width: min(100%, 920px);
    transform: translateX(-50%);
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
  }

  .inline-form {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }

  .inline-form button {
    grid-column: auto;
  }
}
