:root {
  color-scheme: light dark;
  --paper: #f6f6f0; --white: #fdfdf9; --ink: #171c12; --muted: #5e6655; --line: #e0e2d6;
  --accent: #d4fa57; --accent-ink: #171c12; --accent-text: #4b6517; --soft: #eef3db; --danger: #9b261e;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--paper); color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #11140d; --white: #1a1e15; --ink: #eef1e4; --muted: #a8b09b; --line: #2f3527; --accent-text: #c3e85a; --soft: #2a331a; --danger: #ff9a8f; }
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { color: inherit; font: inherit; }
input, select { font-size: 16px; } /* menor que 16px faz o iPhone dar zoom */
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .4; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #6a9117; outline-offset: 2px; }
h1:focus { outline: none; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: 5px; }
.card { border: 1px solid var(--line); border-radius: 16px; background: var(--white); }

.topbar { background: var(--white); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-inner, .shell { width: min(1184px, 100%); margin-inline: auto; padding-inline: 32px; }
.topbar-inner { min-height: 68px; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 31px; font-weight: 850; letter-spacing: -.085em; line-height: .9; }
.brand-mark { width: 36px; height: 36px; padding: 3px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); }
.brand-dot { color: var(--accent-text); }
.navigation { display: flex; gap: 6px; margin-left: auto; }
.navigation a { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; color: var(--muted); border-radius: 10px; font-size: 14px; font-weight: 650; }
.navigation .icon { width: 19px; height: 19px; }
.account-link { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; }
[aria-current="page"] { background: var(--soft); color: var(--ink) !important; }
.sync-banner { margin: 0; padding: 8px 16px; background: #ffe7a3; color: #3d2f00; font-size: 13px; text-align: center; }

.shell { padding-block: 40px 56px; }
.resting .shell { padding-bottom: 170px; }
.intro h1 { font-size: clamp(32px, 6vw, 60px); line-height: 1; letter-spacing: -.07em; font-weight: 850; }
.intro h1 span { color: #719625; }
.intro p { margin-top: 10px; color: var(--muted); line-height: 1.5; }

.toolbar { display: grid; gap: 10px; margin: 20px 0; }
.search, .text-field input, .text-field select, .note-input, .mini input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.search { max-width: 420px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-button { min-height: 42px; flex: none; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); font-size: 14px; font-weight: 650; }
.filter-button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.workspace { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); align-items: start; gap: 22px; }
.catalog-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.catalog-header h2 { font-size: 16px; }
.catalog-header span { color: var(--muted); font-size: 12px; }
.catalog-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.catalog-item { width: 100%; display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: center; gap: 10px; text-align: left; min-height: 64px; padding: 7px; background: var(--white); border: 1px solid var(--line); border-radius: 11px; }
.catalog-item[aria-pressed="true"] { background: var(--soft); border-color: #9fbf3f; }
.catalog-item img { width: 58px; height: 43px; border-radius: 7px; object-fit: cover; background: #292f26; }
.catalog-item strong, .catalog-item small { display: block; }
.catalog-item strong { font-size: 13.5px; line-height: 1.2; }
.catalog-item small { margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.catalog-empty { color: var(--muted); font-size: 13px; padding: 12px; }

.exercise { padding: 20px; min-width: 0; }
.exercise-header { display: flex; justify-content: space-between; align-items: end; gap: 10px; margin-bottom: 12px; }
.exercise-meta { color: var(--accent-text); font-weight: 750; font-size: 12px; margin-bottom: 4px; }
.exercise-header h2 { font-size: clamp(23px, 4vw, 36px); line-height: 1.08; letter-spacing: -.055em; scroll-margin-top: 16px; }
.icon-button { display: inline-grid; flex: none; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: transparent; }
#favorite[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#favorite[aria-pressed="true"] .icon { fill: currentColor; }

.media { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; background: #252823; border-radius: 12px; }
.media video { display: block; width: 100%; height: 100%; object-fit: contain; }
.large-play { position: absolute; display: grid; place-items: center; top: 44%; left: 50%; width: 58px; height: 58px; padding: 0; transform: translate(-50%, -50%); color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 50%; box-shadow: 0 0 0 7px #15190f33; }
.large-play .icon { width: 28px; height: 28px; }
.media-controls { position: absolute; display: flex; align-items: center; inset: auto 0 0; gap: 6px; padding: 0 5px; background: #171a13d9; color: #fff; }
.media-button { display: inline-grid; flex: none; place-items: center; width: 44px; height: 44px; padding: 0; color: inherit; border: 0; background: transparent; }
.speed { font-size: 13px; font-weight: 700; }
.video-progress { flex: 1; min-width: 0; height: 44px; margin: 0; accent-color: var(--accent); }
.media-error { position: absolute; inset: 30% 10px auto; border-radius: 10px; background: #171a13f2; color: #fff; padding: 6px; font-size: 13px; text-align: center; }
.media-error button { min-height: 44px; color: var(--accent); border: 0; background: none; text-decoration: underline; }

.record { margin-top: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.record h3, .technique h3, .panel h2, .empty h2, .editor h2 { font-size: 18px; letter-spacing: -.03em; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 13px 0 10px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.stepper button, .stepper input { min-width: 0; min-height: 46px; padding: 0; background: transparent; border: 0; text-align: center; }
.stepper input { width: 100%; font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }
.note-input { margin-bottom: 10px; }
.primary-button, .ghost-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 10px; font-weight: 750; font-size: 14px; }
.primary-button { background: var(--accent); color: var(--accent-ink); border: 1px solid #c6e849; }
.ghost-button { background: transparent; border: 1px solid var(--line); }
.danger { color: var(--danger); }
.wide { width: 100%; }
.spaced { margin-top: 20px; }
.form-message { margin: 8px 0; font-size: 13px; color: var(--danger); }
.form-message.success { color: var(--accent-text); font-weight: 700; }
.technique { margin-top: 20px; }
.technique ul { margin: 10px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.technique li::marker { color: var(--accent-text); }

.stack { display: grid; gap: 12px; margin-top: 20px; }
.panel { display: grid; gap: 10px; justify-items: start; padding: 18px; margin-top: 14px; min-width: 0; }
.stack .panel { margin-top: 0; }
.panel .muted { margin: 0; }
.panel .text-field, .panel > #chart { justify-self: stretch; }
.empty { padding: 36px 20px; text-align: center; }
.empty > .icon { width: 34px; height: 34px; color: var(--accent-text); margin-bottom: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.text-field { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.routine-exercises { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.editor { display: grid; gap: 14px; padding: 18px; margin-top: 20px; }
.editor-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.editor-items li { display: grid; grid-template-columns: 1fr 1fr 44px 44px; gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: 11px; }
.editor-items strong { grid-column: 1 / -1; font-size: 14px; }
.mini { display: grid; gap: 4px; font-size: 11px; color: var(--muted); min-width: 0; }

.session-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-top: 18px; padding: 13px; border-radius: 14px; background: var(--soft); }
.session-bar strong, .session-bar span { display: block; }
.session-bar span { font-size: 12px; color: var(--muted); }
.session-bar ol { grid-column: 1 / -1; display: flex; gap: 7px; overflow-x: auto; list-style: none; margin: 0; padding: 3px; }
.step { white-space: nowrap; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); font-size: 12.5px; }
.step.done { opacity: .6; }
.step[aria-current="step"] { border: 2px solid var(--accent-text); font-weight: 750; }

.day { display: grid; gap: 8px; }
.day-title { font-size: 14px; margin-top: 8px; color: var(--muted); }
.day-title::first-letter { text-transform: uppercase; }
.history-entry { display: grid; grid-template-columns: 62px minmax(0, 1fr) 44px; align-items: center; gap: 12px; padding: 11px; }
.history-entry img { width: 62px; height: 47px; border-radius: 7px; object-fit: cover; }
.history-entry h3 { font-size: 15px; }
.history-entry p { color: var(--muted); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.history-entry .note { font-style: italic; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.stat { padding: 15px; }
.stat strong { display: block; font-size: 26px; letter-spacing: -.04em; overflow-wrap: anywhere; }
.stat span { font-size: 12px; color: var(--muted); }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; width: min(100%, 420px); text-align: center; }
.calendar b { font-size: 11px; color: var(--muted); }
.calendar span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; }
.calendar .trained { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 800; }
.calendar .today { outline: 2px solid var(--accent-text); }
.calendar .future { opacity: .3; }
.line-chart { display: block; width: 100%; max-height: 260px; margin-top: 8px; }
.line-chart polyline { fill: none; stroke: var(--accent-text); stroke-width: 2.5; stroke-linejoin: round; }
.line-chart circle { fill: var(--accent); stroke: var(--accent-text); stroke-width: 1.5; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
#logout { margin-top: 18px; }

.rest { position: fixed; z-index: 20; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(460px, calc(100% - 20px)); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 13px 15px; border-radius: 16px; background: #171c12; color: #fff; box-shadow: 0 8px 30px #0008; }
.rest span { display: block; font-size: 12px; color: #c9cfbc; }
.rest strong { font-size: 32px; font-variant-numeric: tabular-nums; color: var(--accent); }
.rest-close { grid-column: 2; grid-row: 1; align-self: center; min-height: 44px; padding: 0 14px; border: 1px solid #ffffff40; border-radius: 9px; background: transparent; color: #fff; }
.rest-presets { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rest-presets button { min-height: 40px; border: 1px solid #ffffff30; border-radius: 8px; background: transparent; color: #fff; font-size: 13px; }
.rest-presets button[aria-pressed="true"] { background: #fff; color: #171c12; }
.rest.done { background: var(--accent); color: var(--accent-ink); }
.rest.done span, .rest.done strong, .rest.done button { color: var(--accent-ink); }
.rest.done .rest-presets button[aria-pressed="true"] { background: #fff; }

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px; }
.auth-card { width: min(390px, 100%); }
.auth-card h1 { margin-top: 30px; font-size: 34px; letter-spacing: -.05em; }
.auth-card form { display: grid; gap: 13px; margin-top: 22px; }
.auth-card .form-message { margin: 0; }
.link-button { width: 100%; min-height: 48px; margin-top: 8px; border: 0; background: none; color: var(--accent-text); font-weight: 700; font-size: 14px; }

@media (hover: hover) {
  .navigation a:hover, .ghost-button:hover, .stepper button:hover, .icon-button:hover { background-color: var(--soft); }
}
@media (max-width: 760px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar-inner { min-height: 60px; justify-content: space-between; }
  .navigation { position: fixed; z-index: 10; inset: auto 0 0; margin: 0; gap: 3px; padding: 5px 6px calc(5px + env(safe-area-inset-bottom)); background: var(--white); border-top: 1px solid var(--line); }
  .navigation a { flex: 1; flex-direction: column; gap: 2px; min-height: 52px; padding: 0 2px; font-size: 11px; }
  .rest { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .resting .shell { padding-bottom: 180px; }
}
@media (max-width: 690px) {
  .topbar-inner, .shell { padding-inline: 15px; }
  .shell { padding-top: 22px; }
  .intro p { font-size: 14px; }
  .toolbar { margin: 14px 0 12px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .catalog-list { display: flex; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
  .catalog-list li { flex: 0 0 172px; scroll-snap-align: start; }
  .catalog-list .catalog-empty { flex-basis: 100%; }
  .catalog-item { grid-template-columns: 46px minmax(0, 1fr); height: 100%; }
  .catalog-item img { width: 46px; height: 36px; }
  .catalog-item strong { font-size: 12px; }
  .exercise { padding: 11px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* no celular, cada campo numérico ocupa a linha inteira: botões grandes para tocar com folga */
@media (max-width: 690px), (min-width: 761px) and (max-width: 1000px) {
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .field { display: grid; grid-template-columns: 94px minmax(0, 1fr); align-items: center; gap: 8px; }
  .field label { margin: 0; }
  .stepper { grid-template-columns: 56px minmax(0, 1fr) 56px; }
}
