/* Components: reusable pieces of the UI. Every color, size and radius comes from tokens.css. */

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; gap: var(--space-3); align-items: center; justify-content: center;
  min-height: var(--tap-min); padding: 0 var(--space-5); border: 0; border-radius: var(--radius-lg);
  background: var(--color-chip); color: var(--color-text); font-weight: 600; text-decoration: none; white-space: nowrap;
}

.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }

.btn-primary:active { background: var(--color-accent-strong); }

.btn-big { width: 100%; min-height: var(--tap-big); margin-top: var(--space-4); font-size: var(--font-size-lg); }

.btn-small { min-height: 36px; font-size: 14px; }

.btn-ghost { width: 100%; margin-top: var(--space-3); background: none; color: var(--color-text-muted); }

.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); }

.icon-btn { flex: none; width: var(--tap-min); height: var(--tap-min); border: 0; background: none; color: var(--color-text); font-size: 26px; }

/* ---------- title bar ---------- */
.title-bar {
  position: sticky; top: 0; z-index: 5; display: flex; gap: var(--space-4); align-items: center;
  height: calc(50px + var(--safe-top)); padding: calc(var(--safe-top) + var(--space-1)) var(--space-5) 0 var(--space-5);
  background: var(--color-bg);
}

.title-bar h2 { flex: 1; margin: 0; font-size: var(--font-size-xl); }

.title-input { flex: 1; min-width: 0; min-height: 40px; padding: var(--space-2) 0; border: 0; background: none; font-size: 20px; font-weight: 700; }

.title-input:focus { border-bottom: 2px solid var(--color-accent); border-radius: 0; box-shadow: none; }

.clock { color: var(--color-text-muted); font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- lists ---------- */
.history-item { margin: var(--space-4) var(--space-gutter); padding: var(--space-4) var(--space-5); border-radius: var(--radius-xl); background: var(--color-surface); cursor: pointer; }

.history-item:active { opacity: 0.7; }

.history-item .item-top { display: flex; gap: var(--space-4); justify-content: space-between; }

.history-item b { font-size: var(--font-size-md); }

.history-item small { color: var(--color-text-muted); }

.history-item p { overflow: hidden; margin: var(--space-2) 0 0; color: var(--color-text-muted); font-size: var(--font-size-sm); text-overflow: ellipsis; white-space: nowrap; }

.repeat-item { display: flex; gap: var(--space-4); align-items: center; padding: var(--space-4) 0; border-top: 1px solid var(--color-border); }

.repeat-item small { display: block; overflow: hidden; color: var(--color-text-muted); text-overflow: ellipsis; white-space: nowrap; }

.pick-list { margin: 0; padding: 0 var(--space-gutter); list-style: none; }

.pick-list li { display: flex; align-items: center; min-height: 58px; margin: var(--space-3) 0; padding: var(--space-3) var(--space-5); border-radius: var(--radius-lg); background: var(--color-surface); cursor: pointer; }

.pick-list li:active { opacity: 0.7; }

.pick-list h4 { margin: var(--space-5) var(--space-1) var(--space-1); color: var(--color-text-muted); font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: 0.04em; }

.pick-list .create-item { justify-content: center; color: var(--color-accent); font-weight: 600; }

.item-name { flex: 1; min-width: 0; }

.item-name div { overflow: hidden; font-size: var(--font-size-md); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

.item-name small { color: var(--color-text-muted); font-size: var(--font-size-sm); }

.chevron { color: var(--color-text-muted); font-size: 20px; }

/* ---------- chips, segmented control, tags, badges ---------- */
.chips { display: flex; gap: var(--space-3); padding: var(--space-2) var(--space-5) var(--space-3); overflow-x: auto; scrollbar-width: none; }

.chips button { flex: none; min-height: 38px; padding: 0 14px; border: 1px solid var(--color-border); border-radius: var(--radius-pill); background: var(--color-surface); font-size: 14px; }

.chips button.is-active { border-color: var(--color-accent); background: var(--color-accent); color: var(--color-on-accent); font-weight: 600; }

.seg { display: flex; overflow: hidden; margin: var(--space-2) 0 var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }

.seg button { flex: 1; min-height: var(--tap-min); border: 0; background: none; font-size: 15px; }

.seg button.is-active { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 700; }

.tag { padding: var(--space-1) 7px; border-radius: var(--radius-sm); background: var(--color-chip); color: var(--color-text-muted); font-size: var(--font-size-xs); font-weight: 700; text-transform: uppercase; }

.tag-admin,
.tag-custom { background: var(--color-accent-soft); color: var(--color-accent); }

.tag-off { background: var(--color-danger-bg); color: var(--color-danger); }

.badge { display: inline-flex; gap: 3px; align-items: center; padding: 3px 7px; border-radius: var(--radius-sm); background: var(--color-pr-bg); color: var(--color-pr); font-size: var(--font-size-xs); font-weight: 800; letter-spacing: 0.02em; }

/* ---------- exercise slot + set rows ---------- */
.slot { overflow: hidden; margin: var(--space-gutter); border-radius: var(--radius-xl); background: var(--color-surface); }

.slot-head { display: flex; gap: var(--space-1); align-items: center; padding: var(--space-3) var(--space-2) var(--space-2) var(--space-5); }

.slot-head .item-name { cursor: pointer; }

.slot-head .item-name b { display: block; overflow: hidden; color: var(--color-accent); font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }

.slot-head .item-name small { font-size: 12px; }

.slot-head button { flex: none; width: 40px; height: var(--tap-min); border: 0; background: none; color: var(--color-text-muted); font-size: var(--font-size-lg); }

.slot-head button:disabled { opacity: 0.25; }

.set-grid { display: grid; grid-template-columns: 44px 1fr 1fr 1fr 52px; gap: var(--space-3); align-items: center; padding: 3px var(--space-4); }

.set-head { padding-top: var(--space-1); color: var(--color-text-muted); font-size: var(--font-size-xs); font-weight: 700; text-align: center; text-transform: uppercase; }

.set-row.is-done { background: var(--color-success-bg); }

.set-number { height: 40px; border: 0; border-radius: var(--radius-md); background: var(--color-chip); font-size: 15px; font-weight: 700; }

.set-number.is-warmup { background: var(--color-pr-bg); color: var(--color-pr); }

.set-prev { overflow: hidden; color: var(--color-text-muted); font-size: var(--font-size-sm); text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.set-row input { min-height: 46px; padding: var(--space-2); font-size: var(--font-size-num); font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }

.set-row input::placeholder { color: var(--color-text-muted); font-weight: 500; opacity: 0.55; }

.set-row.is-done input { border-color: transparent; background: transparent; }

.set-check { height: 46px; border: 0; border-radius: var(--radius-lg); background: var(--color-chip); color: var(--color-text-muted); font-size: var(--font-size-xl); }

.set-row.is-done .set-check { background: var(--color-success); color: var(--color-on-accent); }

.pr-list { display: flex; flex-wrap: wrap; grid-column: 2 / -1; gap: var(--space-2); margin: calc(var(--space-1) * -1) 0 var(--space-1); }

.slot-foot { display: flex; gap: var(--space-4); padding: var(--space-3) var(--space-4) var(--space-gutter); }

.slot-foot .btn { flex: 1; min-height: 42px; font-size: 15px; }

.volume-pr { padding: 0 var(--space-5) var(--space-3); }

/* ---------- records, charts, tables ---------- */
.records { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-top: var(--space-4); }

.records div { padding: var(--space-4) var(--space-gutter); border-radius: var(--radius-md); background: var(--color-surface-sunken); }

.records small { display: block; color: var(--color-text-muted); font-size: 12px; }

.records b { display: block; font-size: 20px; }

.records em { display: block; color: var(--color-text-muted); font-size: 12px; font-style: normal; }

.chart-box { position: relative; height: 210px; }

.table-card { overflow: hidden; padding: 0; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }

.data-table th { padding: 9px var(--space-gutter); border-bottom: 1px solid var(--color-border); color: var(--color-text-muted); font-size: 12px; font-weight: 600; text-align: right; }

.data-table td { padding: 9px var(--space-gutter); border-bottom: 1px solid var(--color-border); text-align: right; white-space: nowrap; }

.data-table th:first-child,
.data-table td:first-child { text-align: left; }

.data-table tr:last-child td { border-bottom: 0; }

.detail-set { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--color-border); font-variant-numeric: tabular-nums; }

.detail-set.is-warmup { color: var(--color-text-muted); }

/* ---------- rest timer ---------- */
.rest-bar {
  position: fixed; right: var(--space-4); bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-4)); left: var(--space-4); z-index: 12;
  display: flex; gap: var(--space-3); align-items: center; overflow: hidden; padding: var(--space-3);
  border-radius: 16px; background: var(--color-overlay); box-shadow: var(--shadow-float); color: var(--color-on-overlay);
}

.rest-bar button { min-width: 56px; height: 46px; border: 0; border-radius: var(--radius-lg); background: var(--color-on-overlay-soft); color: var(--color-on-overlay); font-size: var(--font-size-md); font-weight: 700; }

.rest-time { flex: 1; text-align: center; }

.rest-time small { display: block; font-size: var(--font-size-xs); opacity: 0.7; }

.rest-time b { font-size: 24px; font-variant-numeric: tabular-nums; }

.rest-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--color-accent); transition: width 1s linear; }

.rest-bar.is-over { background: var(--color-accent); }

/* ---------- bottom navigation ---------- */
.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 10; display: flex; height: calc(var(--nav-height) + var(--safe-bottom)); padding-bottom: var(--safe-bottom); border-top: 1px solid var(--color-border); background: var(--color-surface); }

.bottom-nav button { display: flex; flex: 1; flex-direction: column; gap: var(--space-1); align-items: center; justify-content: center; border: 0; background: none; color: var(--color-text-muted); font-size: var(--font-size-xs); }

.bottom-nav i { font-size: var(--font-size-xl); font-style: normal; line-height: 1; }

.bottom-nav button.is-active { color: var(--color-accent); font-weight: 700; }

/* ---------- sheets (full-screen and bottom) ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; overflow-y: auto; padding-bottom: calc(var(--space-6) + var(--safe-bottom)); background: var(--color-bg); animation: sheet-up 0.18s ease-out; }

.sheet-bottom { top: auto; max-height: 80vh; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; box-shadow: var(--shadow-sheet); }

@keyframes sheet-up {
  from { opacity: 0.4; transform: translateY(30px); }
}

.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; gap: var(--space-3); align-items: center; padding: calc(var(--safe-top) + var(--space-2)) var(--space-4) var(--space-2) var(--space-1); background: var(--color-bg); }

.sheet-bottom .sheet-head { padding-top: var(--space-3); }

.sheet-head h3 { flex: 1; overflow: hidden; margin: 0; font-size: var(--font-size-lg); text-overflow: ellipsis; white-space: nowrap; }

/* ---------- admin + password ---------- */
.meter { overflow: hidden; height: 5px; margin: var(--space-3) 0 var(--space-1); border-radius: 3px; background: var(--color-border); }

.meter i { display: block; width: 0; height: 100%; transition: width 0.2s; }

.admin-list { margin: var(--space-3) 0 0; padding: 0; list-style: none; }

.admin-list li { padding: var(--space-4) 0; border-top: 1px solid var(--color-border); }

.admin-list .item-top { display: flex; gap: var(--space-3); align-items: center; }

.admin-list .item-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.admin-list .actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }

.admin-list .actions .btn { flex: 1; min-height: 38px; font-size: 14px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 70px); left: 50%; z-index: 40; max-width: 90%; padding: var(--space-gutter) 16px; border-radius: var(--radius-lg); background: var(--color-overlay); color: var(--color-on-overlay); font-size: 15px; transform: translateX(-50%); }
