:root {
  --bg: #0c0c0a;
  --bg-2: #131310;
  --surface: #1a1a16;
  --surface-2: #232320;
  --line: #302f28;
  --line-bright: #45443a;
  --text: #f3f1e6;
  --muted: #8c8a7c;
  --muted-2: #59584c;
  --accent: #d7ff3f;
  --accent-dim: #a8cc2f;
  --accent-ink: #0c0c0a;
  --danger: #ff5a36;
  --radius: 4px;
  --radius-sm: 9px;
  --font-display: 'Anton', system-ui, sans-serif;
  --font-body: 'Golos Text', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  position: relative;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
}

/* Едва заметное зерно поверх всего — фактура металла/бумаги, а не плоский цвет */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 18px calc(env(safe-area-inset-bottom) + 92px);
}

.hidden { display: none !important; }

::selection { background: var(--accent); color: var(--accent-ink); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 4px; }

/* ---------- Опознавательные элементы ---------- */

.wordmark {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.wordmark-accent { color: var(--accent); }
.wordmark-lg { font-size: 42px; line-height: 1; }

.hazard-bar {
  height: 6px;
  width: 100%;
  background: repeating-linear-gradient(
    -45deg, var(--accent) 0 10px, #0c0c0a 10px 20px
  );
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-header, .masthead, .block, .page-header {
  animation: rise 0.5s cubic-bezier(.2,.7,.3,1) both;
}
.block:nth-of-type(1) { animation-delay: 0.05s; }
.block:nth-of-type(2) { animation-delay: 0.1s; }
.block:nth-of-type(3) { animation-delay: 0.15s; }

.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 6px 2px 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.app-date {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Масштхэд «следующая тренировка» ---------- */

.masthead {
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
  padding: 16px 0 22px;
  margin-bottom: 30px;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.masthead-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 8px;
}

.badge-letter {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 44px;
  line-height: 0.85;
  color: var(--bg);
  -webkit-text-stroke: 2px var(--accent);
  flex-shrink: 0;
}

.masthead-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.05;
  text-transform: uppercase;
  margin-bottom: 10px;
  max-width: 92%;
}

.masthead-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ---------- Кнопки ---------- */

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  border: 1px solid var(--line-bright);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.btn:active { transform: scale(0.97) rotate(-0.3deg); }
.btn-small { padding: 10px 16px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--accent-dim);
  color: var(--accent);
}

.btn-spark { display: inline-block; }

/* ---------- Блоки/секции ---------- */

.block { margin-bottom: 28px; }

.block-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 2px 12px;
}

.picker-row { display: flex; gap: 10px; }

.picker-btn {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 6px 12px;
  cursor: pointer;
  text-align: center;
  font-family: var(--font-body);
}
.picker-btn:active { background: var(--surface-2); border-color: var(--line-bright); }

.picker-badge {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  color: var(--accent);
  display: block;
  line-height: 1;
}
.picker-sub { font-size: 10.5px; color: var(--muted); display: block; margin-top: 6px; line-height: 1.3; }

/* ---------- Вес тела ---------- */

.stat-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
}

.stat-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.stat-value-wrap { display: flex; align-items: baseline; gap: 6px; }
.stat-value { font-family: var(--font-display); font-weight: 400; font-size: 40px; line-height: 0.9; }
.stat-unit { color: var(--muted); font-family: var(--font-mono); font-size: 13px; }
.stat-delta {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--surface-2);
}
.stat-delta.down { color: var(--accent); }
.stat-delta.up { color: var(--danger); }
.stat-delta:empty { display: none; }
.stat-goal {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  text-align: right;
  text-transform: uppercase;
  padding-top: 4px;
}

.stat-chart { width: 100%; height: 64px; margin-bottom: 14px; display: block; }

.stat-form { display: flex; gap: 10px; }
.stat-form input { flex: 1; }

.mono-input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--accent);
  padding: 11px 14px;
  font-size: 16px;
  font-family: var(--font-mono);
}
.mono-input::placeholder { color: var(--muted-2); }
.mono-input:focus { outline: none; border-color: var(--accent-dim); }

.rule-list { list-style: none; }
.rule-list li {
  color: var(--muted);
  font-size: 13.5px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.rule-list li::before {
  content: '×';
  color: var(--danger);
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* ---------- Тренировка ---------- */

.workout-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 22px;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: var(--surface-2); }

.workout-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}
.workout-subtitle {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  text-transform: uppercase;
  line-height: 1.05;
}

.ai-block { margin-bottom: 20px; }

.ai-answer {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 15px 16px;
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.6;
}
.ai-answer.loading { color: var(--muted); border-left-style: dashed; }

.exercise {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.ex-index {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-2);
  padding-top: 2px;
}

.ex-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }

.ex-name { font-weight: 700; font-size: 15.5px; line-height: 1.3; }

.ex-target {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

.ex-last { color: var(--muted); font-size: 13px; margin-top: 6px; font-family: var(--font-mono); }
.ex-last b { color: var(--accent); font-weight: 600; }

.ex-links { display: flex; gap: 16px; margin-top: 10px; }
.ex-links a {
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid var(--line-bright);
}
.ex-links a:active { color: var(--accent); border-color: var(--accent); }

.ex-hint { color: var(--muted); font-size: 12.5px; margin-top: 10px; line-height: 1.5; }

.sets { margin-top: 14px; display: grid; gap: 8px; }

.set-row {
  display: grid;
  grid-template-columns: 62px 1fr 1fr;
  gap: 8px;
  align-items: center;
}
.set-row.no-reps { grid-template-columns: 62px 1fr; }

.set-num { color: var(--muted-2); font-size: 11px; font-family: var(--font-mono); }

.set-row input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
  width: 100%;
  font-family: var(--font-mono);
}
.set-row input:focus { outline: none; border-color: var(--accent-dim); color: var(--accent); }
.set-row input::placeholder { color: var(--muted-2); }

.btn-finish { width: 100%; padding: 17px; font-size: 15px; margin: 8px 0 12px; letter-spacing: 0.02em; text-transform: uppercase; }

/* ---------- Заголовки страниц (история/настройки) ---------- */

.page-header {
  margin: 6px 2px 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.page-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  text-transform: uppercase;
}

/* ---------- История ---------- */

.history-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.hi-badge {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  color: var(--bg);
  -webkit-text-stroke: 1.5px var(--accent);
  line-height: 1;
}
.hi-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hi-title { font-weight: 700; font-size: 14.5px; }
.hi-date { color: var(--muted); font-size: 11.5px; font-family: var(--font-mono); white-space: nowrap; }
.hi-summary { color: var(--muted); font-size: 12.5px; margin-top: 6px; line-height: 1.5; font-family: var(--font-mono); }

.empty-note { color: var(--muted); text-align: center; padding: 50px 20px; font-size: 14px; }

/* ---------- Логин ---------- */

.login-screen {
  min-height: calc(100dvh - 6px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 4px;
}

.login-inner { animation: rise 0.6s cubic-bezier(.2,.7,.3,1) both; }

.login-tagline {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  margin: 10px 0 40px;
}

.login-form { display: flex; flex-direction: column; gap: 4px; }

.field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 16px;
  margin-bottom: 8px;
}
.field-label:first-child { margin-top: 0; }

.field-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 13px 14px;
  font-size: 16px;
  font-family: var(--font-body);
}
.field-input:focus { outline: none; border-color: var(--accent-dim); }

.field-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  font-family: var(--font-mono);
}

.login-form .btn { margin-top: 24px; }

/* ---------- Настройки ---------- */

.settings-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.settings-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 8px;
}
.settings-hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; line-height: 1.55; }
.settings-hint a { color: var(--accent-dim); }
.settings-hint b { color: var(--text); }

.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Таббар ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 998;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(12, 12, 10, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  max-width: 160px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.tab-icon { width: 20px; height: 20px; }
.tab.active { color: var(--accent); }
