/* WORKOUT WINTER — общие токены и компоненты */
:root {
  --bg: #060b16;
  --bg-2: #0a1222;
  --surface: #0f1a30;
  --surface-2: #14223d;
  --surface-3: #1a2b4b;
  --line: rgba(150, 190, 240, 0.14);
  --line-strong: rgba(150, 190, 240, 0.28);
  --text: #eaf3ff;
  --muted: #9db0cc;
  --faint: #6f84a3;
  --ice: #7fd8ff;
  --ice-strong: #4fc3ff;
  --ice-soft: rgba(127, 216, 255, 0.12);
  --on-ice: #03121f;
  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, 0.14);
  --warn: #ffc857;
  --warn-soft: rgba(255, 200, 87, 0.14);
  --bad: #ff6b7a;
  --bad-soft: rgba(255, 107, 122, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --font: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--ice); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.15; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
small, .small { font-size: .875rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.tabnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 2px; }

/* Кнопки */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: 600 15px/1 var(--font); padding: 0 18px; min-height: 44px; text-decoration: none !important;
  background: var(--surface-3); color: var(--text); transition: background .15s, transform .05s, border-color .15s, opacity .15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: #22365c; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--ice); color: var(--on-ice); }
.btn-primary:hover { background: #a3e4ff; }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad-soft); color: #ffb3bb; border-color: rgba(255, 107, 122, .35); }
.btn-danger:hover { background: rgba(255, 107, 122, .24); }
.btn-ok { background: var(--ok-soft); color: #9ff0cb; border-color: rgba(61, 220, 151, .35); }
.btn-lg { min-height: 54px; font-size: 17px; padding: 0 26px; border-radius: 14px; }
.btn-sm { min-height: 34px; font-size: 13.5px; padding: 0 12px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 40px; min-height: 40px; }
.btn .spinner { width: 16px; height: 16px; }

/* Формы */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--bg-2); color: var(--text); font: 16px/1.3 var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { border-color: var(--ice); box-shadow: 0 0 0 3px var(--ice-soft); }
.input.is-invalid, .field.is-invalid .input { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.field-error { color: #ffb3bb; font-size: 13.5px; }
.field-hint { color: var(--faint); font-size: 13px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 15px; line-height: 1.4; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ice); flex: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* Карточки, бейджи */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card-tight { padding: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--surface-3); color: var(--muted); white-space: nowrap; line-height: 1.5;
}
.badge-ok { background: var(--ok-soft); color: #8ff0c4; }
.badge-warn { background: var(--warn-soft); color: #ffd98a; }
.badge-bad { background: var(--bad-soft); color: #ffb3bb; }
.badge-ice { background: var(--ice-soft); color: var(--ice); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Индикатор мест */
.meter { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--ice-strong), var(--ice)); border-radius: inherit; transition: width .5s ease; }
.meter.is-warn > span { background: linear-gradient(90deg, #ffb347, var(--warn)); }
.meter.is-full > span { background: linear-gradient(90deg, #ff5d73, var(--bad)); }

/* Диалоги */
dialog.modal {
  border: 1px solid var(--line-strong); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow); overflow: hidden;
}
dialog.modal::backdrop { background: rgba(2, 6, 14, 0.72); backdrop-filter: blur(3px); }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 19px; }
.modal-body { padding: 18px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-close { background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.modal-close:hover { color: var(--text); background: var(--surface-2); }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 560px) {
  dialog.modal { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; }
  dialog.modal[open] { animation: sheet .22s ease-out; }
  @keyframes sheet { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
  .modal-foot .btn { flex: 1 1 auto; }
}

/* Уведомления-тосты */
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 15px; animation: pop .2s ease-out; pointer-events: auto; }
.toast-ok { border-color: rgba(61, 220, 151, .5); }
.toast-bad { border-color: rgba(255, 107, 122, .6); }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 15px; border: 1px solid var(--line-strong); background: var(--surface-2); margin-bottom: 14px; }
.alert-bad { background: var(--bad-soft); border-color: rgba(255, 107, 122, .4); color: #ffd0d5; }
.alert-warn { background: var(--warn-soft); border-color: rgba(255, 200, 87, .4); color: #ffe2a8; }
.alert-ok { background: var(--ok-soft); border-color: rgba(61, 220, 151, .4); color: #c6f7e0; }
.alert-ice { background: var(--ice-soft); border-color: rgba(127, 216, 255, .35); color: #d3f1ff; }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line-strong); border-top-color: var(--ice); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: flex; justify-content: center; padding: 40px 0; }

.qr { background: #fff; border-radius: 14px; padding: 10px; width: 220px; max-width: 100%; margin: 0 auto; }
.qr svg { width: 100%; height: auto; }
.code-pill { font: 800 22px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; padding: 10px 16px; border-radius: 12px; background: var(--bg-2); border: 1px dashed var(--line-strong); display: inline-block; }

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