:root {
  --bg: #0a0a0c;
  --surface: #18181c;
  --surface-2: #212127;
  --surface-3: #2b2b32;
  --border: #2c2c33;
  --border-soft: #232329;
  --text: #f5f5f7;
  --text-muted: #9797a1;
  --text-faint: #6b6b74;
  --accent: #4c8bff;
  --accent-soft: rgba(76, 139, 255, 0.16);
  --done: #32d47e;
  --done-soft: rgba(50, 212, 126, 0.15);
  --danger: #f2555c;
  --danger-soft: rgba(242, 85, 92, 0.14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.3), 0 10px 24px -14px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 2px 4px rgba(0, 0, 0, 0.3), 0 16px 32px -16px rgba(0, 0, 0, 0.6);
  --ease: cubic-bezier(0.22, 0.8, 0.32, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f1f1f4;
    --surface: #ffffff;
    --surface-2: #f2f2f5;
    --surface-3: #e7e7ec;
    --border: #e1e1e6;
    --border-soft: #ececf0;
    --text: #17171b;
    --text-muted: #6d6d76;
    --text-faint: #9a9aa3;
    --accent: #2f6bef;
    --accent-soft: rgba(47, 107, 239, 0.1);
    --done: #189a56;
    --done-soft: rgba(24, 154, 86, 0.12);
    --danger: #e0343d;
    --danger-soft: rgba(224, 52, 61, 0.1);

    --shadow-card: 0 1px 2px rgba(20, 20, 30, 0.04), 0 8px 20px -12px rgba(20, 20, 30, 0.12);
    --shadow-pop: 0 2px 6px rgba(20, 20, 30, 0.06), 0 16px 32px -16px rgba(20, 20, 30, 0.18);
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark light;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font-family: inherit;
}

button {
  transition: transform 0.15s var(--ease), background-color 0.15s var(--ease), opacity 0.15s var(--ease),
    border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-soft);
}

/* ---- topbar / navegação ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.nav-btn {
  flex: 1;
  min-height: 44px;
  padding: 10px 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px -4px var(--accent-soft);
}

.nav-icon-btn {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.nav-icon-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ---- layout / tipografia ---- */

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px;
  padding-bottom: 72px;
}

#app > * {
  animation: subir-desvanecer 0.32s var(--ease) backwards;
}

@keyframes subir-desvanecer {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #app > *,
  button {
    animation: none !important;
    transition: none !important;
  }
}

h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 18px;
}

h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.eyebrow,
.section-label,
.painel-card .rotulo {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 22px 0 10px;
}

.painel-card .rotulo {
  margin: 0 0 6px;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

.vazio {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---- cards ---- */

.card,
.painel-card,
.manage-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 12px;
}

.painel-card {
  padding: 18px 16px;
}

.card-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.card-btn:active {
  transform: scale(0.985);
}

.card-compact {
  border-left: 3px solid var(--cor, var(--accent));
}

.painel-card.card-btn {
  border-left: 3px solid var(--cor, var(--accent));
  position: relative;
}

.painel-card.card-btn::after {
  content: "›";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-faint);
}

.painel-card .destaque {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums;
}

.hoje-data {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
  margin: 0 0 14px;
}

.semana-barra {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.semana-barra .dia {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  transition: background-color 0.2s var(--ease);
}

.semana-barra .dia.feito {
  background: var(--done);
}

.treino-header {
  border-top: 3px solid var(--cor, var(--accent));
  padding-top: 14px;
  margin-bottom: 6px;
}

/* ---- botões ---- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
  color: var(--text-muted);
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
}

.back-link:active {
  color: var(--accent);
}

.btn-primary {
  min-height: 46px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 6px 16px -8px var(--accent-soft);
}

.btn-full {
  width: 100%;
  margin-top: 10px;
}

.btn-secondary {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.collapse-btn {
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  border: 1px dashed var(--done);
  border-radius: var(--radius-md);
  background: var(--done-soft);
  color: var(--done);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ---- exercícios ---- */

.exercicio-card.completo {
  padding: 13px 16px;
  background: var(--done-soft);
  border-color: var(--done);
  border-color: color-mix(in srgb, var(--done) 35%, var(--border-soft));
}

.exercicio-card.completo .exercicio-nome {
  color: var(--done);
  display: flex;
  align-items: center;
  gap: 6px;
}

.exercicio-nome {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.exercicio-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 7px 0 10px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
}

.ultima-vez {
  font-size: 13px;
  margin: 0 0 12px;
  color: var(--text-muted);
}

.ultima-vez strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.series-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  font-size: 14px;
}

.series-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums;
}

.series-list li:last-child {
  border-bottom: none;
}

.del-serie {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.del-serie:active {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ---- formulário de série ---- */

.serie-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}

.field label,
.manage-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
}

.stepper:focus-within {
  border-color: var(--accent);
}

.stepper input {
  border: none;
  border-radius: 0;
  background: transparent;
  text-align: center;
  min-width: 0;
  flex: 1;
  padding: 10px 2px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.step-btn {
  flex-shrink: 0;
  width: 34px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.step-btn:active {
  background: var(--accent-soft);
}

/* ---- inputs de texto / select / data ---- */

input[type="date"],
input[type="number"],
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input[type="date"]:focus,
input[type="number"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

input[type="date"] {
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* ---- calendário ---- */

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.calendar-header h1 {
  margin: 0;
  font-size: 19px;
}

.calendar-header button {
  min-width: 40px;
  min-height: 40px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-size: 17px;
  color: var(--accent);
  cursor: pointer;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  text-align: center;
}

.calendar-grid .weekday {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  padding-bottom: 6px;
}

.day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  padding: 0;
}

.day-cell.empty {
  background: transparent;
  border: none;
  cursor: default;
}

.day-cell.hoje {
  border-width: 2px;
  border-color: var(--accent);
  font-weight: 800;
}

.day-cell.selecionado {
  box-shadow: 0 0 0 2px var(--accent);
}

.day-cell .badge {
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---- gerenciar ---- */

.manage-field {
  margin-bottom: 12px;
}

.manage-exercicio {
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  margin-top: 14px;
  transition: opacity 0.2s var(--ease);
}

.manage-exercicio.inativo {
  opacity: 0.45;
}

.manage-exercicio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.manage-exercicio-nome {
  font-weight: 700;
  font-size: 15px;
}

.reorder-btns {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.reorder-btns button {
  width: 28px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 10px;
  cursor: pointer;
  padding: 0;
}

.manage-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ---- estado de erro ---- */

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

.error:empty {
  display: none;
}
