/* ——— Локальный вариативный шрифт Onest (кириллица + латиница + математика, без внешних запросов) ——— */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/fonts/onest-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/fonts/onest-math.woff2") format("woff2");
  unicode-range: U+0391-03A9, U+03B1-03C9, U+2070-209F, U+2190-21FF, U+2200-22FF;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/fonts/onest-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font-sans: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Поверхности */
  --bg: #F3F7FD;
  --bg-canvas: #F3F7FD;
  --card: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F8FAFC;
  --bg-header: #EAF2FF;

  /* Текст (строгий контраст WCAG AA >= 4.5:1 на всех светлых подложках) */
  --ink-brand: #173B7B;
  --ink: #1E293B;
  --ink-secondary: #3E526E;
  --muted: #4A5D78;

  /* Основные и семантические акценты */
  --accent: #1564D9;
  --accent-dark: #104FAE;
  --accent-soft: #EFF6FF;
  --accent-border: #BFDBFE;

  --success: #15803D;
  --success-dark: #166534;
  --success-bg: #ECFDF5;
  --success-border: #86EFAC;

  --warn: #92400E;
  --warn-bg: #FFFBEB;
  --warn-border: #FCD34D;

  --danger: #DC2626;
  --danger-dark: #B91C1C;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;

  /* Границы, скругления и тени */
  --border: #D5E0F0;
  --border-strong: #BCCCE4;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow-sm: 0 4px 12px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 10px 28px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 18px 44px rgba(17, 24, 39, 0.14);
  --focus-ring: 0 0 0 3px rgba(21, 100, 217, 0.2);

  /* Фирменная 5-цветная лента движения «Всем пять!» */
  --brand-stripe: linear-gradient(
    90deg,
    #F39800 0% 20%,
    #FFE500 20% 40%,
    #92BF22 40% 60%,
    #04B0D9 60% 80%,
    #E95098 80% 100%
  );
}

*, *::before, *::after {
  box-sizing: border-box;
}

::selection {
  background: #DBEAFE;
  color: var(--ink-brand);
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: #BDCEE6 transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--ink-brand);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.mode-auth {
  background: var(--bg-canvas);
  color: var(--ink-brand);
}

body[data-brand="matolimp"] {
  --ink-brand: #0F172A;
  --brand-stripe: linear-gradient(90deg, #0F172A 0% 24%, #008542 24% 68%, #F59E0B 68% 100%);
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 18px 32px 32px;
  box-shadow: none;
  width: 100%;
  max-width: none;
}

/* ——— Единая шапка рабочих экранов с 5-цветной полосой движения ——— */
.app-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: -18px -32px 16px;
  padding: 12px 32px;
  background: var(--bg-header);
  border-bottom: 4px solid transparent;
  border-image: var(--brand-stripe) 1;
}

.app-header-left {
  justify-self: start;
  min-width: 0;
}

.app-header-center {
  justify-self: center;
  text-align: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 8px;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink-brand);
  line-height: 1.25;
}

.app-header-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink-brand);
  line-height: 1.2;
}

.app-ver {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #4E6382;
  vertical-align: middle;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  line-height: 1.2;
}

.ws-pill.is-off {
  background: #FEF3C7;
  color: var(--warn);
  border-color: var(--warn-border);
}

.ws-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 7px;
}

.app-sub {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

@media (max-width: 820px) {
  .card {
    padding: 14px 20px 26px;
  }
  .app-header {
    margin: -14px -20px 14px;
    padding: 11px 20px;
  }
  .app-header-center {
    font-size: 1rem;
  }
}

@media (max-width: 620px) {
  .card {
    padding: 12px 14px 22px;
  }
  .app-header {
    margin: -12px -14px 12px;
    padding: 10px 14px;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .app-header-left,
  .app-header-center,
  .app-header-right {
    justify-self: start;
  }
}

/* ——— Базовые элементы форм и кнопок ——— */
input, select, button, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin: 5px 0;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

input, select, textarea {
  background: #FFFFFF;
  color: var(--ink-brand);
  caret-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: #5B708F;
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

button {
  background: var(--accent);
  color: #FFFFFF;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.25;
}

:where(button:not(:disabled)):hover {
  background: var(--accent-dark);
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-secondary {
  background: #F1F6FE;
  color: var(--ink-brand);
  border: 1px solid #C8D7EE;
}

.btn-secondary:hover:not(:disabled) {
  background: #E2EEFD;
  border-color: #93B8F0;
  color: var(--accent-dark);
}

.app-header .btn-secondary {
  background: #FFFFFF;
}

.app-header .btn-secondary:hover:not(:disabled) {
  background: #EFF6FF;
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-dark);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-row button,
.btn-row select {
  width: auto;
  min-width: 112px;
  flex: 1;
}

.msg {
  color: var(--danger);
  min-height: 1.2em;
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 8px;
}

.msg.ok {
  color: var(--success);
}

.hidden {
  display: none !important;
}

/* Табличные цифры для счётчиков баллов, номеров задач и таблиц */
table,
.stats-bar b,
.points-today-label,
.final-points-big,
.cmd-count-pill,
.cmd-limit-input {
  font-variant-numeric: tabular-nums;
}

#loader {
  position: fixed;
  inset: 0;
  background: rgba(243, 247, 253, 0.78);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--ink-brand);
  z-index: 20;
}

#loader.on {
  display: flex;
}
