@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --ink: #17221d;
  --muted: #68746e;
  --paper: #f2f5ef;
  --card: #ffffff;
  --line: #dce3dc;
  --lime: #c9f75d;
  --lime-dark: #507600;
  --blue: #2864ff;
  --red: #d84832;
  --shadow: 0 18px 50px rgba(23, 34, 29, 0.1);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body { min-height: 100vh; min-height: 100dvh; margin: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); color: var(--ink); background: var(--paper); font-family: "DM Sans", sans-serif; overscroll-behavior-y: none; touch-action: pan-y; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(40, 100, 255, 0.35); outline-offset: 2px; }
.hidden { display: none !important; }

#app { min-height: 100vh; min-height: 100dvh; }
.app-header { position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100vw - 820px) / 2)); color: white; background: var(--ink); }
.app-header h1 { display: flex; align-items: center; gap: 10px; margin: 0; font: 20px "Archivo Black", sans-serif; letter-spacing: -0.04em; }
.app-header h1 img { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn { width: 42px; height: 42px; border: 0; border-radius: 50%; color: inherit; background: transparent; font-size: 22px; }
.icon-btn:hover { background: rgba(255,255,255,.1); }

main { width: min(100%, 820px); margin: 0 auto; padding: 28px 20px 100px; }
.view { display: none; }
.view.active { display: block; animation: enter .24s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
.view-title { margin: 0 0 24px; font: 30px/1.05 "Archivo Black", sans-serif; letter-spacing: -0.055em; }

.drawer { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, 340px); padding: 24px; color: white; background: var(--ink); box-shadow: var(--shadow); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.drawer-header h2 { font-family: "Archivo Black", sans-serif; }
.drawer-menu { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }
.menu-item { width: 100%; padding: 15px 16px; border: 0; border-radius: 14px; color: #d9dfdc; background: transparent; text-align: left; font-weight: 700; }
.menu-item.active, .menu-item:hover { color: var(--ink); background: var(--lime); }
.overlay { position: fixed; z-index: 30; inset: 0; background: rgba(7, 14, 10, .55); backdrop-filter: blur(4px); }
.offline-banner { position: fixed; z-index: 60; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); left: 14px; padding: 12px 16px; border-radius: 14px; color: white; background: var(--red); box-shadow: var(--shadow); text-align: center; font-size: 13px; font-weight: 800; }

.date-bar { display: flex; align-items: end; justify-content: space-between; margin-bottom: 16px; color: var(--muted); text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: .1em; }
#currentDay { color: var(--ink); }
.treino-card { overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: var(--card); box-shadow: var(--shadow); }
.treino-header { display: flex; gap: 16px; align-items: center; padding: 24px; background: var(--lime); }
.treino-emoji { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: rgba(255,255,255,.55); font-size: 25px; }
.treino-header h2 { margin: 0 0 4px; font: 26px/1.05 "Archivo Black", sans-serif; letter-spacing: -.045em; }
.treino-header p { margin: 0; color: #46611c; font-weight: 700; }
.late-badge { display: inline-block; margin: 16px 24px 0; padding: 6px 10px; border-radius: 999px; color: #72362b; background: #ffe2dc; font-size: 12px; font-weight: 700; }
.progress-wrap { padding: 20px 24px 4px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.progress { overflow: hidden; height: 8px; border-radius: 999px; background: #e8ece8; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--blue); transition: width .25s ease; }
.group { padding: 16px 24px 4px; }
.group h3 { margin: 0 0 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.exercise { display: flex; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.exercise input { width: 22px; height: 22px; accent-color: var(--blue); }
.exercise label { flex: 1; font-weight: 700; }
.exercise small { color: var(--muted); font-weight: 500; }
.exercise.done label { color: var(--muted); text-decoration: line-through; }
.treino-actions { padding: 20px 24px 24px; }

.btn-primary, .btn-secondary, .btn-danger, .btn-small { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 800; }
.btn-primary { width: 100%; color: white; background: var(--blue); }
.btn-primary:disabled { cursor: not-allowed; color: #8b9690; background: #e2e7e3; }
.btn-secondary { color: white; background: var(--ink); }
.btn-danger { color: white; background: var(--red); }
.btn-small { padding: 9px 12px; color: var(--ink); background: var(--lime); }
.empty-state, .status-card, .form-card, .actions-card { padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }

.semana-list, .treinos-list, .historico-list, .events-list { display: grid; gap: 12px; }
.btn-add-treino { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-bottom: 18px; padding: 14px 18px; border: 1px dashed #9fb0a6; border-radius: 18px; color: var(--ink); background: transparent; font-weight: 800; }
.btn-add-treino:hover { border-color: var(--blue); color: var(--blue); background: rgba(40,100,255,.05); }
.btn-add-treino span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: white; background: var(--blue); font-size: 21px; line-height: 1; }
.day-card, .plan-card, .history-card, .event-card { display: flex; gap: 14px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.day-card.today { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(40,100,255,.12); }
.day-icon { font-size: 22px; }
.day-copy, .plan-copy { flex: 1; }
.day-copy strong, .plan-copy strong { display: block; }
.day-copy small, .plan-copy small, .history-card small, .event-card small { color: var(--muted); }
.status { padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status.done { color: #245800; background: #ddf8bd; }
.status.pending { color: #7b5100; background: #fff0c2; }

.form-card { display: grid; gap: 18px; margin-top: 14px; }
.form-card label, .modal-body label { display: grid; gap: 7px; font-weight: 700; }
.form-card input, .modal-body input, .modal-body select { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; }
.form-card small { color: var(--muted); font-weight: 400; }
.actions-card { display: flex; gap: 10px; margin-top: 14px; }
.status-card.connected { color: #245800; border-color: #b7db91; background: #edfadd; }

.modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: end center; padding-top: 40px; background: rgba(7,14,10,.6); }
.modal-content { width: min(100%, 680px); max-height: 92vh; overflow: auto; border-radius: 28px 28px 0 0; background: var(--paper); }
.modal-header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; background: var(--ink); color: white; }
.modal-header h3 { margin: 0; font-family: "Archivo Black", sans-serif; }
.modal-close { border: 0; color: white; background: transparent; font-size: 20px; }
.modal-body { display: grid; gap: 18px; padding: 22px; }
.grupo-editor { display: grid; gap: 8px; padding: 14px; margin: 10px 0; border: 1px solid var(--line); border-radius: 14px; background: white; }
.exercise-editor { display: grid; grid-template-columns: 1fr 76px 94px 34px; gap: 7px; }
.remove-btn { border: 0; border-radius: 9px; color: var(--red); background: #ffe7e2; }

@media (display-mode: standalone) {
  .app-header { height: 64px; }
  main { padding-bottom: calc(36px + env(safe-area-inset-bottom)); }
}

@media (min-width: 720px) {
  .app-header { height: 82px; }
  main { padding-top: 42px; }
  .treino-header { padding: 30px; }
  .modal { place-items: center; padding: 24px; }
  .modal-content { border-radius: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
