:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #111;
  --panel-soft: #181818;
  --text: #f7f7f7;
  --muted: #b7b7b7;
  --line: rgba(255, 255, 255, 0.13);
  --orange: #ff6a00;
  --orange-soft: rgba(255, 106, 0, 0.16);
  --green: #65d67a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(255, 106, 0, 0.26), transparent 34rem),
    linear-gradient(135deg, #050505 0%, #111 58%, #1b0d03 100%);
  font-family: Inter, Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}

.app-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.app-header,
.calendar-card,
.stats-card,
.settings-card,
.day-dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.88);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto auto auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.brand,
.month-controls,
.view-switcher,
.health-logout {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--orange);
  font-weight: 900;
  text-decoration: none;
}

.brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.health-logout,
.health-tool-link {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #fff;
  background: #1d1d1d;
  font-weight: 900;
  text-decoration: none;
}

.health-tool-link {
  border-color: var(--orange);
  background: var(--orange);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.9);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.auth-card img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.auth-card p {
  margin: 16px 0 5px;
  color: var(--orange);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 0;
  font-size: 2rem;
}

.auth-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: #d7d7d7;
  font-size: 0.78rem;
  font-weight: 900;
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #fff;
  background: #0d0d0d;
}

.auth-form button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--orange);
  border-radius: 6px;
  color: #fff;
  background: var(--orange);
  font-weight: 900;
}

.auth-error {
  display: block;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 106, 0, 0.42);
  border-radius: 6px;
  color: #ffd9bf;
  background: rgba(255, 106, 0, 0.12);
}

.header-copy p,
.calendar-toolbar p,
.dialog-heading p,
.stats-heading p,
.settings-heading p,
.workout-settings-heading p,
.chart-card span,
.stats-summary span {
  margin: 0 0 5px;
  color: var(--orange);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-copy h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2.5rem);
  letter-spacing: 0;
}

.month-controls,
.view-switcher {
  gap: 8px;
}

.month-controls strong {
  min-width: 150px;
  text-align: center;
}

.month-controls button,
.calendar-toolbar button,
.stats-heading button,
.view-switcher button,
.pb-form button,
.health-entry button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #fff;
  background: #1d1d1d;
  font-weight: 900;
}

.month-controls button {
  min-width: 40px;
  padding: 0 12px;
}

.view-switcher button,
.calendar-toolbar button,
.stats-heading button,
.pb-form button,
.health-entry button {
  padding: 0 14px;
}

.month-controls [data-today],
.calendar-toolbar button,
.stats-heading button,
.view-switcher button.is-active,
.pb-form button,
.health-entry button {
  border-color: var(--orange);
  background: var(--orange);
}

.reminder-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin: 0 0 18px;
  padding: 18px;
  border: 1px solid rgba(255, 106, 0, 0.26);
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.88);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.reminder-card span {
  display: block;
  margin: 0 0 5px;
  color: var(--orange);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reminder-card strong {
  display: block;
  font-size: 1.1rem;
}

.reminder-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.reminder-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.reminder-actions button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #fff;
  background: #1d1d1d;
  font-weight: 900;
}

.reminder-actions [data-enable-reminders],
.reminder-actions [data-test-reminder] {
  border-color: var(--orange);
  background: var(--orange);
}

.reminder-status {
  grid-column: 1 / -1;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
}

.calendar-card,
.stats-card,
.settings-card {
  padding: 18px;
}

.calendar-toolbar,
.stats-heading,
.settings-heading,
.workout-settings-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.calendar-toolbar h2,
.stats-heading h2,
.settings-heading h2,
.workout-settings-heading h3 {
  margin: 0;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.calendar-grid {
  gap: 8px;
}

.day-cell {
  display: grid;
  min-height: 174px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}

.day-cell:hover,
.day-cell.is-selected {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.day-cell.is-muted {
  opacity: 0.42;
}

.day-cell.is-today {
  box-shadow: inset 0 0 0 2px rgba(255, 106, 0, 0.76);
}

.day-cell.is-pb {
  border-color: rgba(101, 214, 122, 0.7);
  background: rgba(101, 214, 122, 0.12);
}

.day-cell.is-logged {
  border-color: rgba(255, 106, 0, 0.64);
}

.day-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.day-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.day-number {
  font-size: 1rem;
  font-weight: 900;
}

.day-badge {
  padding: 4px 7px;
  border-radius: 999px;
  color: #09220e;
  background: var(--green);
  font-size: 0.65rem;
  font-weight: 900;
}

.day-badge.is-log {
  color: #1b1100;
  background: #ffb36b;
}

.mini-workouts {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-workouts li {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-workouts strong {
  color: #fff;
}

.day-dialog {
  width: min(920px, calc(100% - 28px));
  max-height: calc(100vh - 34px);
  padding: 22px;
  color: var(--text);
  overflow-y: auto;
}

.day-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  font-size: 1.4rem;
}

.dialog-heading h2 {
  margin: 0 0 16px;
  font-size: 1.8rem;
}

.day-log-form {
  display: grid;
  gap: 14px;
}

.day-log-form h3,
.health-entry h3 {
  margin: 0 0 12px;
}

.workout-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.workout-entry,
.pb-form label,
.day-log-form section,
.pb-history,
.stats-summary article,
.chart-card,
.empty-stats {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.workout-entry,
.day-log-form section {
  padding: 14px;
}

.workout-entry {
  display: grid;
  grid-template-columns: 1fr 78px 78px 84px;
  gap: 10px;
  align-items: end;
}

.workout-entry span,
.pb-form span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.workout-entry strong {
  display: block;
  margin-top: 4px;
  font-size: 1.1rem;
}

.workout-entry label,
.health-entry label {
  display: grid;
  gap: 7px;
  color: #d7d7d7;
  font-size: 0.75rem;
  font-weight: 900;
}

.health-entry {
  display: grid;
  gap: 12px;
}

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.fasting-check {
  display: flex !important;
  align-items: center;
  width: max-content;
}

.fasting-check input {
  width: 17px;
  height: 17px;
}

.pb-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pb-form label {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.pb-health-form {
  margin-top: 14px;
}

.pb-form input,
.workout-entry input,
.health-entry input,
.health-entry textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #fff;
  background: #0d0d0d;
}

.health-entry textarea {
  min-height: 92px;
  resize: vertical;
}

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

.pb-history {
  margin-top: 14px;
  padding: 14px;
}

.pb-history h3 {
  margin: 0 0 10px;
}

.pb-history dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  margin: 0;
}

.pb-history dt {
  color: var(--muted);
}

.pb-history dd {
  margin: 0;
  font-weight: 900;
}

.save-notice {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid rgba(101, 214, 122, 0.38);
  border-radius: 6px;
  color: #c9ffd1;
  background: rgba(101, 214, 122, 0.13);
  font-weight: 900;
}

.day-cross-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.day-cross-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #fff;
  background: #1d1d1d;
  font-size: 0.8rem;
  font-weight: 900;
  text-decoration: none;
}

.day-cross-links a:hover {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats-summary article {
  padding: 14px;
}

.stats-summary strong {
  display: block;
  font-size: 1.6rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chart-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.chart-card h3 {
  margin: 0;
}

.chart-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.chart-card canvas {
  width: 100%;
  height: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.empty-stats {
  grid-column: 1 / -1;
  padding: 22px;
}

.empty-stats h3,
.empty-stats p {
  margin: 0;
}

.empty-stats p {
  margin-top: 8px;
  color: var(--muted);
}

.workout-settings {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 24, 24, 0.72);
}

.workout-settings-heading {
  margin-bottom: 16px;
}

.workout-settings-heading button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #fff;
  background: #1d1d1d;
  font-weight: 900;
}

.workout-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.workout-group-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.workout-group-card span {
  display: block;
  margin: 0 0 5px;
  color: var(--orange);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workout-group-card h4 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.workout-group-card ul {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.workout-group-card li,
.workout-group-card form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.workout-group-card form {
  grid-template-columns: 1fr auto;
}

.workout-group-card input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #fff;
  background: #0d0d0d;
}

.workout-group-card button {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #fff;
  background: #242424;
  font-weight: 900;
}

.workout-group-card [data-update-workout],
.workout-group-card form button {
  border-color: var(--orange);
  background: var(--orange);
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: auto 1fr;
  }

  .view-switcher,
  .month-controls,
  .health-logout,
  .health-tool-link {
    justify-content: flex-start;
  }
}

@media (max-width: 980px) {
  .app-header,
  .reminder-card,
  .stats-summary,
  .stats-grid,
  .workout-library {
    grid-template-columns: 1fr;
  }

  .month-controls {
    justify-content: space-between;
  }

  .reminder-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .workout-group-card li {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 1440px);
  }

  .calendar-card {
    overflow-x: auto;
  }

  .weekdays,
  .calendar-grid {
    min-width: 900px;
  }

  .workout-entry-grid,
  .pb-form,
  .vitals-grid {
    grid-template-columns: 1fr;
  }

  .workout-entry {
    grid-template-columns: 1fr 1fr;
  }

  .workout-entry > div {
    grid-column: 1 / -1;
  }
}
