/* ============================================
   FONTE — tokens
   ============================================ */
:root{
  --bg:            #141010;
  --bg-elevated:   #1c1716;
  --surface:       #211b1a;
  --surface-hi:    #2a2221;
  --line:          #362c2a;
  --text:          #f2ece6;
  --text-dim:      #a89c96;
  --text-faint:    #6f635e;
  --accent:        #e2382c;
  --accent-hi:     #ff5b46;
  --accent-dim:    #7a1f18;
  --gold:          #d8a13d;
  --radius-s:      10px;
  --radius-m:      16px;
  --radius-l:      22px;
  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --font-display:  'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --font-body:     system-ui, -apple-system, Roboto, 'Segoe UI', sans-serif;
  --font-mono:     'SFMono-Regular', Consolas, 'Roboto Mono', monospace;
}

*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font-body);
  overscroll-behavior-y:none;
  -webkit-font-smoothing:antialiased;
}
button, input{ font-family:inherit; color:inherit; }
button{ background:none; border:none; cursor:pointer; }
img{ max-width:100%; display:block; }
h1,h2,h3{ margin:0; }

/* subtle brushed-steel texture on the background */
body::before{
  content:"";
  position:fixed; inset:0;
  background-image:
    repeating-linear-gradient(115deg, rgba(255,255,255,0.012) 0 2px, transparent 2px 6px);
  pointer-events:none;
  z-index:0;
}

#app{
  position:relative;
  min-height:100%;
  padding-bottom:calc(72px + var(--safe-bottom));
}

/* ============================================
   TOP BAR
   ============================================ */
.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  padding:calc(16px + var(--safe-top)) 18px 14px;
  background:linear-gradient(180deg, var(--bg) 60%, rgba(20,16,16,0.94));
  backdrop-filter:blur(6px);
  border-bottom:1px solid var(--line);
}
.topbar__brand{ display:flex; align-items:center; gap:10px; }
.topbar__plate{
  width:26px; height:26px; border-radius:50%;
  background:
    radial-gradient(circle at 34% 30%, var(--accent-hi), var(--accent) 55%, var(--accent-dim) 100%);
  box-shadow:inset 0 0 0 4px var(--bg), inset 0 0 0 5px var(--accent-dim);
  flex:none;
}
.topbar h1{
  font-size:19px; font-weight:800; letter-spacing:0.06em;
  text-transform:uppercase;
  display:flex; align-items:baseline; gap:8px;
}
.topbar__sub{
  font-size:10px; font-weight:600; letter-spacing:0.14em;
  color:var(--text-faint); text-transform:uppercase;
}
.iconbtn{
  width:38px; height:38px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background:var(--surface); color:var(--text-dim);
  border:1px solid var(--line);
}
.iconbtn:active{ background:var(--surface-hi); }

/* ============================================
   VIEWS
   ============================================ */
.view{ display:none; padding:16px 18px 8px; position:relative; z-index:1; }
.view--active{ display:block; }
.viewtitle{
  font-size:13px; font-weight:800; letter-spacing:0.14em;
  text-transform:uppercase; color:var(--text-dim);
  margin-bottom:14px;
}
.viewtitle-row{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.viewtitle-row .viewtitle{ margin:0; }

/* ============================================
   SEARCH BAR + FILTERS
   ============================================ */
.searchbar{
  display:flex; align-items:center; gap:10px;
  background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius-m);
  padding:12px 14px; margin-bottom:12px;
}
.searchbar__icon{ color:var(--text-faint); flex:none; }
.searchbar input{
  background:none; border:none; outline:none;
  width:100%; font-size:15px; color:var(--text);
}
.searchbar input::placeholder{ color:var(--text-faint); }

.filters{
  display:flex; gap:8px; overflow-x:auto; padding-bottom:4px; margin-bottom:8px;
  scrollbar-width:none;
}
.filters::-webkit-scrollbar{ display:none; }
.filter-chip{
  flex:none;
  font-size:12.5px; font-weight:700; letter-spacing:0.01em;
  padding:9px 13px; border-radius:999px;
  background:var(--surface); border:1px solid var(--line); color:var(--text-dim);
  display:flex; align-items:center; gap:5px; white-space:nowrap;
}
.filter-chip .chev{ font-size:9px; color:var(--text-faint); }
.filter-chip--active{ background:var(--accent-dim); border-color:var(--accent); color:#ffd9d4; }
.filter-chip--reset{ background:transparent; color:var(--accent-hi); border-color:transparent; }

.resultcount{
  font-family:var(--font-mono); font-size:11px; letter-spacing:0.06em;
  color:var(--text-faint); margin:2px 2px 12px; text-transform:uppercase;
}

/* Filter dropdown overlay */
.dropdown{
  position:fixed; inset:0; z-index:40; display:none;
}
.dropdown--open{ display:block; }
.dropdown__backdrop{ position:absolute; inset:0; background:rgba(0,0,0,0.5); }
.dropdown__panel{
  position:absolute; left:14px; right:14px; top:112px;
  max-height:60vh; overflow-y:auto;
  background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius-m); padding:8px;
  box-shadow:0 20px 50px rgba(0,0,0,0.5);
}
.dropdown__item{
  width:100%; text-align:left; padding:11px 12px; border-radius:var(--radius-s);
  font-size:14.5px; display:flex; justify-content:space-between; align-items:center;
  text-transform:capitalize;
}
.dropdown__item:active{ background:var(--surface-hi); }
.dropdown__item--selected{ color:var(--accent-hi); font-weight:700; }
.dropdown__count{ font-family:var(--font-mono); font-size:11px; color:var(--text-faint); }

/* ============================================
   EXERCISE GRID / CARDS
   ============================================ */
.grid{
  display:grid; grid-template-columns:repeat(2, 1fr); gap:12px;
}
.card{
  background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius-m); overflow:hidden;
  text-align:left; position:relative;
}
.card__media{
  width:100%; aspect-ratio:1/1; background:var(--bg-elevated);
  overflow:hidden; position:relative;
}
.card__media img{ width:100%; height:100%; object-fit:cover; }
.card__fav{
  position:absolute; top:8px; right:8px; z-index:2;
  width:30px; height:30px; border-radius:50%;
  background:rgba(20,16,16,0.65); backdrop-filter:blur(3px);
  display:flex; align-items:center; justify-content:center;
  color:#fff;
}
.card__fav svg{ width:16px; height:16px; }
.card__fav--active{ color:var(--accent-hi); }
.card__body{ padding:10px 11px 12px; }
.card__name{
  font-size:13.5px; font-weight:700; line-height:1.25;
  text-transform:capitalize; margin-bottom:6px;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.card__meta{ display:flex; flex-wrap:wrap; gap:5px; }
.badge{
  font-family:var(--font-mono); font-size:9.5px; font-weight:600;
  letter-spacing:0.03em; text-transform:uppercase;
  padding:3px 7px; border-radius:6px;
  background:var(--bg-elevated); color:var(--text-dim);
  border:1px solid var(--line);
}
.badge--accent{ color:var(--gold); border-color:rgba(216,161,61,0.3); }

.emptystate{
  color:var(--text-faint); font-size:14px; text-align:center;
  padding:60px 20px; line-height:1.5;
}

/* ============================================
   BOTTOM NAV
   ============================================ */
.bottomnav{
  position:fixed; left:0; right:0; bottom:0; z-index:30;
  display:flex;
  background:var(--bg-elevated); border-top:1px solid var(--line);
  padding-bottom:var(--safe-bottom);
}
.navbtn{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:10px 0 8px; color:var(--text-faint);
}
.navbtn span{ font-size:10.5px; font-weight:700; letter-spacing:0.03em; }
.navbtn--active{ color:var(--accent-hi); }
.navbtn--active svg{ filter:drop-shadow(0 0 6px rgba(226,56,44,0.5)); }

/* ============================================
   BUTTONS
   ============================================ */
.btn{
  font-size:13.5px; font-weight:700; padding:11px 16px;
  border-radius:var(--radius-s); text-align:center;
}
.btn--accent{ background:var(--accent); color:#fff; }
.btn--accent:active{ background:var(--accent-hi); }
.btn--outline{ background:transparent; border:1.5px solid var(--line); color:var(--text); }
.btn--outline:active{ background:var(--surface-hi); }
.btn--full{ width:100%; margin-top:6px; }
.btn--sm{ padding:8px 13px; font-size:12.5px; }
.btn--danger{ color:var(--accent-hi); }

/* ============================================
   ROUTINES
   ============================================ */
.routines-list{ display:flex; flex-direction:column; gap:10px; }
.routine-card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-m);
  padding:14px 16px;
}
.routine-card__top{ display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:8px; }
.routine-card__name{ font-size:15.5px; font-weight:800; }
.routine-card__count{ font-family:var(--font-mono); font-size:11px; color:var(--text-faint); margin-top:2px; }
.routine-card__thumbs{ display:flex; gap:6px; margin-top:8px; }
.routine-card__thumb{
  width:40px; height:40px; border-radius:8px; overflow:hidden; background:var(--bg-elevated); flex:none;
}
.routine-card__thumb img{ width:100%; height:100%; object-fit:cover; }
.routine-card__more{
  width:40px; height:40px; border-radius:8px; background:var(--bg-elevated);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-mono); font-size:11px; color:var(--text-faint);
}
.routine-card__actions{ display:flex; gap:8px; margin-top:12px; }

.routine-picker-list{ max-height:40vh; overflow-y:auto; margin:14px 0; }
.routine-picker-item{
  display:flex; justify-content:space-between; align-items:center;
  padding:13px 4px; border-bottom:1px solid var(--line);
  font-size:14.5px; font-weight:600;
}
.routine-picker-item__check{
  width:22px; height:22px; border-radius:50%; border:1.5px solid var(--line);
  display:flex; align-items:center; justify-content:center; font-size:12px;
}
.routine-picker-item--added .routine-picker-item__check{
  background:var(--accent); border-color:var(--accent); color:#fff;
}

/* ============================================
   DETAIL SHEET
   ============================================ */
.sheet{ position:fixed; inset:0; z-index:50; display:none; }
.sheet[aria-hidden="false"]{ display:block; }
.sheet__backdrop{ position:absolute; inset:0; background:rgba(8,6,6,0.72); }
.sheet__panel{
  position:absolute; left:0; right:0; bottom:0; max-height:92vh;
  background:var(--bg-elevated); border-radius:22px 22px 0 0;
  border-top:1px solid var(--line);
  overflow-y:auto; padding:10px 20px calc(30px + var(--safe-bottom));
  animation:sheetUp 0.28s cubic-bezier(.2,.8,.2,1);
}
.sheet__panel--small{ max-height:70vh; }
@keyframes sheetUp{ from{ transform:translateY(100%);} to{ transform:translateY(0);} }
.sheet__handle{
  width:36px; height:4px; border-radius:99px; background:var(--line);
  margin:6px auto 10px;
}
.sheet__close{
  position:absolute; top:14px; right:16px; width:32px; height:32px;
  background:var(--surface); border-radius:50%; color:var(--text-dim); font-size:15px;
}
.sheet__title{ font-size:16px; font-weight:800; margin:4px 0 4px; }

.detail__media{
  width:100%; aspect-ratio:1/1; border-radius:var(--radius-m);
  overflow:hidden; background:var(--bg); margin-bottom:16px; position:relative;
}
.detail__media img{ width:100%; height:100%; object-fit:contain; background:#0d0a0a; }
.detail__name{
  font-size:21px; font-weight:800; text-transform:capitalize; line-height:1.2; margin-bottom:10px;
}
.detail__badges{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:18px; }
.detail__actions{ display:flex; gap:10px; margin-bottom:22px; }
.detail__actions .btn{ flex:1; display:flex; align-items:center; justify-content:center; gap:6px; }

.detail__section-title{
  font-family:var(--font-mono); font-size:11px; font-weight:700; letter-spacing:0.1em;
  text-transform:uppercase; color:var(--text-faint); margin:20px 0 10px;
}
.detail__muscles{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:6px; }
.steps{ list-style:none; margin:0; padding:0; counter-reset:step; }
.steps li{
  counter-increment:step; position:relative;
  padding:4px 0 16px 34px; font-size:14.5px; line-height:1.55; color:#ddd3cd;
  border-left:2px solid var(--line); margin-left:13px;
}
.steps li:last-child{ border-left-color:transparent; padding-bottom:0; }
.steps li::before{
  content:counter(step);
  position:absolute; left:-13px; top:0; width:26px; height:26px;
  background:var(--accent-dim); border:1px solid var(--accent);
  color:#ffd9d4; border-radius:50%;
  font-family:var(--font-mono); font-size:11px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
}
.detail__attribution{ font-size:11px; color:var(--text-faint); margin-top:18px; }

/* ============================================
   TOAST
   ============================================ */
.toast{
  position:fixed; left:50%; bottom:calc(88px + var(--safe-bottom));
  transform:translateX(-50%) translateY(20px);
  background:var(--surface-hi); border:1px solid var(--line);
  color:var(--text); font-size:13.5px; font-weight:600;
  padding:11px 18px; border-radius:999px; z-index:60;
  opacity:0; pointer-events:none; transition:all 0.25s ease;
  box-shadow:0 10px 30px rgba(0,0,0,0.4);
  white-space:nowrap;
}
.toast--show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ============================================
   RESPONSIVE (small phones / larger)
   ============================================ */
@media (min-width:420px){
  .grid{ grid-template-columns:repeat(3, 1fr); }
}
@media (min-width:700px){
  .grid{ grid-template-columns:repeat(4, 1fr); }
  .view{ max-width:900px; margin:0 auto; padding-left:24px; padding-right:24px; }
  .topbar{ padding-left:24px; padding-right:24px; }
}

/* keyboard focus visibility */
button:focus-visible, input:focus-visible{
  outline:2px solid var(--accent-hi); outline-offset:2px;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce){
  .sheet__panel{ animation:none; }
  .toast{ transition:none; }
}
