* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: #f4f5f7;
  color: #1f2430;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f2430;
  color: #fff;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.topbar .brand {
  color: #fff;
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
}

.topnav {
  display: flex;
  gap: 0.25rem;
  background: #2a3040;
  padding: 0 max(1rem, env(safe-area-inset-left));
}

.topnav a {
  color: #cfd3dc;
  text-decoration: none;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
  flex: 1 1 0;
  text-align: center;
}

.topnav a:hover { color: #fff; }
.topnav a.active { color: #fff; border-bottom-color: #2f6fed; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(2rem + env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

h1 { margin-top: 0; }

section {
  background: #fff;
  border: 1px solid #e0e2e8;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  row-gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.section-header h1 { margin: 0; }

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2f6fed;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
  min-height: 44px;
}

.button:hover, button:hover { background: #2559c7; }

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: #2f6fed;
  text-decoration: none;
  padding: 0.4rem 0;
}

/* Sessions and exercises are shown as tappable cards, not tables, so nothing
   ever needs sideways scrolling on a phone. */
.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.session-card {
  display: block;
  background: #fff;
  border: 1px solid #e0e2e8;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: inherit;
  min-height: 44px;
}

.session-card:active { background: #f0f3ff; }

.session-card-date {
  font-weight: 600;
  font-size: 1.05rem;
  color: #1f2430;
}

.session-card-exercises {
  color: #555;
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

.session-card-note {
  color: #888;
  font-size: 0.85rem;
  margin-top: 0.3rem;
  font-style: italic;
}

.session-note {
  color: #555;
  font-style: italic;
  margin-top: -0.5rem;
}

/* Sets within a session: stacked rows, big enough to read/tap at arm's length. */
.set-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.set-row {
  border: 1px solid #e8e9ee;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.set-row-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

.set-exercise { font-weight: 600; }
.set-meta { color: #333; }

.set-row-extra {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.set-note { color: #777; font-size: 0.85rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid #e8e9ee;
}

.data-table tbody tr[onclick] { cursor: pointer; }
.data-table tbody tr[onclick]:active { background: #f0f3ff; }

.tag {
  display: inline-block;
  background: #e4f7e9;
  color: #1a7a3a;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
}

.form label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
}

.form input, .form select, .form textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}

/* Add-forms (add a set / add an exercise): stack full-width on mobile so
   nothing is squeezed and every field is a full-size thumb target; sit in a
   row on wider screens. */
.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.add-form label {
  display: flex;
  flex-direction: column;
  flex: 1 1 100%;
  font-size: 0.8rem;
  color: #555;
  font-weight: 500;
}

.add-form label.add-form-narrow { flex: 1 1 calc(33% - 0.4rem); }

.add-form input {
  margin-top: 0.3rem;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  min-height: 44px;
}

.add-form button { flex: 1 1 100%; }

.empty { color: #777; }

.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.flash-success { background: #e4f7e9; color: #1a7a3a; }
.flash-error { background: #fbe4e4; color: #a12b2b; }

@media (min-width: 640px) {
  .container { max-width: 900px; }

  .add-form { align-items: flex-end; }
  .add-form label { flex: 1 1 160px; }
  .add-form label.add-form-narrow { flex: 0 1 100px; }
  .add-form button { flex: 0 0 auto; }
}
