/* The one design system for the whole app and the landing.
   Adapted from the course.personalabs theme (stud/course-cabinet/app/site/css/style.css):
epos\stud\course-cabinetpp\site\css\style.css):
   Google Antigravity look. One purple accent plus a 4-stop rainbow gradient used on fills only,
   Google Sans Flex, big radii, soft shadows, floating particle field behind everything. No emoji.

   Two themes. Dark is the default (founder, 2026-09-30); light is `data-theme="light"` on <html>,
   set before first paint by the inline script in index.html from localStorage `le-theme`, and
   switched by the topbar button (app.js). Every colour in the app goes through these tokens:
   a literal white or black in a cabinet module is a bug that shows up in one of the themes. */

:root {
  color-scheme: dark;
  --color-bg: #0e0f13;              /* page ground */
  --color-secondary: #16181e;       /* surfaces: cards, panels, menus, modals */
  --color-input: #1d2027;           /* inputs, segmented buttons, chips at rest */
  --color-primary: #eceef2;         /* the "dark" button: inverse of the ground */
  --color-on-primary: #0e0f13;
  --color-on-accent: #ffffff;       /* text on the gradient and on the solid accent */
  --color-text: #eceef2;
  --color-text-secondary: #aab0bb;
  --color-text-muted: #7d8491;
  --color-border: #2c3039;
  --color-border-light: #22252d;
  --color-hover: rgba(255, 255, 255, 0.06);
  --color-hover-soft: rgba(255, 255, 255, 0.03);
  --topbar-bg: rgba(14, 15, 19, 0.92);
  --gradient-accent: linear-gradient(115deg, #4b7bec 0%, #8e44ad 36%, #ff4444 70%, #ff9e3d 100%);
  --gradient-size: 190% 100%;
  --color-accent: #b98ae6;
  --color-accent-bg: rgba(185, 138, 230, 0.14);
  --color-accent-glow: rgba(185, 138, 230, 0.34);
  --color-warn: #f2a541;
  --color-warn-bg: rgba(242, 165, 65, 0.12);
  --color-ok: #43c47e;
  --color-ok-bg: rgba(67, 196, 126, 0.12);
  --color-danger: #ff6b6b;
  --color-danger-bg: rgba(255, 107, 107, 0.12);
  --color-img-bg: #1d2027;          /* behind pictures while they load */
  --body-silhouette: #22252d;       /* muscle body map */
  --body-silhouette-stroke: #343844;
  --body-muscle: #2b2f38;
  --body-muscle-stroke: #3a3f4b;
  --font-sans: 'Google Sans Flex', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --radius: 16px;
  --max-width: 1120px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-bg: #ffffff;
  --color-secondary: #ffffff;
  --color-input: #ffffff;
  --color-primary: #000000;
  --color-on-primary: #ffffff;
  --color-text: #000000;
  --color-text-secondary: #5f6368;
  --color-text-muted: #80868b;
  --color-border: #e0e0e0;
  --color-border-light: #f0f0f0;
  --color-hover: rgba(0, 0, 0, 0.05);
  --color-hover-soft: rgba(0, 0, 0, 0.025);
  --topbar-bg: rgba(255, 255, 255, 0.95);
  --color-accent: #8e44ad;
  --color-accent-bg: rgba(142, 68, 173, 0.07);
  --color-accent-glow: rgba(142, 68, 173, 0.30);
  --color-warn: #b35f00;
  --color-warn-bg: rgba(234, 134, 0, 0.08);
  --color-ok: #1f9d57;
  --color-ok-bg: rgba(31, 157, 87, 0.08);
  --color-danger: #c62828;
  --color-danger-bg: rgba(209, 52, 56, 0.08);
  --color-img-bg: #f6f7f9;
  --body-silhouette: #eef1f5;
  --body-silhouette-stroke: #d7dbe2;
  --body-muscle: #e2e6ec;
  --body-muscle-stroke: #cfd4dc;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-weight: 450; letter-spacing: -0.02em; margin: 0 0 0.4em; }
h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.1rem; font-weight: 500; }
p { margin: 0 0 1em; }
.muted { color: var(--color-text-secondary); }
.faint { color: var(--color-text-muted); }
.label {
  font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--color-text-muted);
}

/* particle field behind everything */
#particle-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none;
  mask-image: linear-gradient(to right, #000 0, #000 calc(50% - 470px),
    rgba(0,0,0,0.45) calc(50% - 300px), rgba(0,0,0,0.45) calc(50% + 300px),
    #000 calc(50% + 470px), #000 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(50% - 470px),
    rgba(0,0,0,0.45) calc(50% - 300px), rgba(0,0,0,0.45) calc(50% + 300px),
    #000 calc(50% + 470px), #000 100%);
}
@media (max-width: 1279px) { #particle-canvas { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { #particle-canvas { opacity: 0.35; } }
.above { position: relative; z-index: 10; }

/* buttons */
.btn {
  font-family: var(--font-sans); border: none; border-radius: 999px; padding: 0.85rem 1.7rem;
  font-size: 0.98rem; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center;
  gap: 0.55rem; transition: transform 0.2s ease, box-shadow 0.2s ease, background-position 0.45s ease,
  background 0.15s ease; line-height: 1;
}
.btn-primary {
  background: var(--gradient-accent); background-size: var(--gradient-size); background-position: 0% 50%;
  color: var(--color-on-accent); box-shadow: 0 8px 24px var(--color-accent-glow);
}
.btn-primary:hover { background-position: 100% 50%; transform: translateY(-2px); box-shadow: 0 12px 30px var(--color-accent-glow); }
.btn-dark { background: var(--color-primary); color: var(--color-on-primary); }
.btn-dark:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.btn-ghost { background: transparent; color: var(--color-text); border: 1.5px solid var(--color-text); }
.btn-ghost:hover { background: var(--color-hover); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.86rem; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* cards */
.card {
  background: var(--color-secondary); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 26px 24px; transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.card.hover:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.1); border-color: transparent; }
.grid { display: grid; gap: 20px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* pills / chips */
.pill { display: inline-block; font-size: 0.74rem; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--color-border); color: var(--color-text-secondary); }
.pill.ok { border-color: var(--color-accent-glow); background: var(--color-accent-bg); color: var(--color-accent); }
.pill.warn { border-color: var(--color-warn); background: var(--color-warn-bg); color: var(--color-warn); }

/* tables */
table.grid-table { width: 100%; border-collapse: collapse; font-size: 0.92rem;
  background: var(--color-secondary); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border); }
table.grid-table thead th { background: var(--color-hover-soft); font-weight: 500; text-align: left; padding: 12px 16px;
  border-bottom: 1px solid var(--color-border); font-size: 0.78rem; color: var(--color-text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em; }
table.grid-table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--color-border-light); vertical-align: top; }
table.grid-table tbody tr:hover { background: var(--color-hover-soft); }

/* forms */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 0.78rem; color: var(--color-text-secondary); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.04em; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
textarea, select {
  width: 100%; font-family: var(--font-sans); font-size: 0.95rem; padding: 11px 14px;
  border: 1px solid var(--color-border); border-radius: 11px; background: var(--color-input); color: var(--color-text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-bg); }

/* gradient bar (progress / meters) */
.bar { height: 8px; border-radius: 999px; background: var(--color-border-light); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--gradient-accent); background-size: var(--gradient-size); }

/* ============ APP SHELL ============ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: 56px;
  background: var(--topbar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 18px;
  padding: 0 22px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand .mark { width: 26px; height: 26px; }
.theme-btn { padding: 0.5rem; }
.theme-btn .ic { width: 1.1em; height: 1.1em; margin: 0; }
.spacer { flex: 1; }
.who { font-size: 0.9rem; color: var(--color-text-secondary); }

.tabs { display: flex; gap: 4px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px; border-radius: 999px; font-size: 0.92rem; font-weight: 500; white-space: nowrap;
  color: var(--color-text-secondary); cursor: pointer; border: 1px solid transparent; transition: 0.15s;
}
.tab:hover { color: var(--color-text); background: var(--color-hover); }
.tab.active { color: var(--color-on-accent); background: var(--gradient-accent); background-size: var(--gradient-size); }

.shell { max-width: var(--max-width); margin: 0 auto; padding: 88px 24px 80px; }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.subnav .tab { font-size: 0.86rem; padding: 6px 12px; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 18px; }

/* ============ LOGIN MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 2000; background: rgba(20,20,25,0.35);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--color-secondary); border-radius: 22px; padding: 34px 30px; width: 100%; max-width: 400px;
  box-shadow: 0 24px 70px rgba(30,33,60,0.28); border: 1px solid var(--color-border-light);
}
.modal h2 { margin-bottom: 6px; }
.modal .modal-sub { color: var(--color-text-secondary); font-size: 0.95rem; margin-bottom: 20px; }
.modal .btn { width: 100%; justify-content: center; margin-top: 8px; }
.modal .or { text-align: center; color: var(--color-text-muted); font-size: 0.8rem; margin: 14px 0 6px;
  text-transform: uppercase; letter-spacing: 0.08em; }
.modal .err { color: var(--color-danger); font-size: 0.86rem; min-height: 1.2em; margin-top: 8px; }
.modal .x { position: absolute; }

/* ============ LANDING ============ */
.landing { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.landing-top { display: flex; justify-content: flex-end; padding-top: 16px; }
.hero { min-height: 82vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; }
.hero .badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px; border-radius: 999px;
  border: 1px solid var(--color-border); font-size: 0.82rem; color: var(--color-text-secondary); margin-bottom: 26px; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); font-weight: 450; letter-spacing: -0.03em; line-height: 1.02; }
.hero .grad { background: var(--gradient-accent); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; }
.hero .sub { font-size: 1.15rem; color: var(--color-text-secondary); max-width: 620px; margin: 18px auto 30px; }
.hero .cta { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.landing section { padding: 60px 0; border-top: 1px solid var(--color-border-light); }
.cabmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-top: 26px; }
.cabmap .card h3 { display: flex; align-items: center; gap: 10px; }
.cabmap .ic { width: 30px; height: 30px; flex: none; color: var(--color-accent); }
.cabmap .ru { font-weight: 500; }
.tool-note { margin-top: 22px; padding: 18px 22px; border-left: 3px solid var(--color-accent);
  background: var(--color-accent-bg); border-radius: 0 var(--radius) var(--radius) 0; color: var(--color-text-secondary); }

.foot { padding: 40px 0 60px; color: var(--color-text-muted); font-size: 0.85rem; text-align: center; }

/* muscle body map (bodymap.js), themed through the --body-* tokens. Coloring is driven by --heat
   and the is-primary/is-secondary classes paintHeat() sets. */
.bodymap { width: 190px; height: auto; max-width: 44vw; }
.bodymap .silhouette { fill: var(--body-silhouette); stroke: var(--body-silhouette-stroke); stroke-width: 1; }
.bodymap .muscle { fill: var(--body-muscle); stroke: var(--body-muscle-stroke); stroke-width: .7; transition: fill .25s; cursor: pointer; }
.bodymap .muscle.is-secondary { fill: color-mix(in srgb, #ea8600 calc(var(--heat, 0) * 100%), var(--body-muscle)); }
.bodymap .muscle.is-primary { fill: color-mix(in srgb, #e5484d calc(var(--heat, 0) * 100%), var(--body-muscle)); stroke: #d98a8a; }
.bodymap .muscle.is-sore { fill: color-mix(in srgb, #8e44ad calc(var(--heat, 0) * 100%), var(--body-muscle)); }
.bodymap .muscle:hover { stroke: var(--color-text); stroke-width: 1.4; }
.bw { text-align: center; }

/* small helpers */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stat { font-size: 1.9rem; font-weight: 450; letter-spacing: -0.02em; }
.hide { display: none !important; }
.center { text-align: center; }

/* ---- icons (one registry, web/assets/icons.js) ----
   Every glyph inherits currentColor, so it themes with the text or accent around it. Sized in em
   so it tracks the type it sits next to; overrides below tune it per context. */
.ic { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -0.18em; }
.btn .ic, .tab .ic, .pill .ic, .chip .ic { width: 1.05em; height: 1.05em; vertical-align: -0.15em; }
.tab .ic { margin-right: 5px; }
.btn .ic:first-child { margin-right: -0.1em; }
/* section headers: a soft accent glyph before the title, never dark-on-dark */
.section-title h1 .ic, .section-title h2 .ic { width: 0.86em; height: 0.86em; color: var(--color-accent);
  vertical-align: 0; margin-right: 0.35rem; }
.ic-accent { color: var(--color-accent); }
.ic-muted { color: var(--color-text-muted); }
.label .ic { width: 1.2em; height: 1.2em; margin-right: 5px; vertical-align: -0.24em; }
/* icon flush against text inside a plain (non-flex) text button */
.ic-sp { width: 0.95em; height: 0.95em; margin-right: 4px; vertical-align: -0.12em; }

/* friendly empty state: a muted placeholder over one line, in place of a bare "Пусто." */
.le-empty { text-align: center; color: var(--color-text-muted); padding: 26px 16px; }
.le-empty .le-empty-ic { width: 34px; height: 34px; display: block; margin: 0 auto 10px; opacity: 0.5; }
.le-empty p { margin: 0; font-size: 0.9rem; }

/* The `hidden` attribute must win over any display set on a class. Without this, the view-as
   menu's `display: flex` kept it permanently open: the script toggled `hidden`, the CSS
   ignored it, and on a phone the list covered the page with no way to close it. */
[hidden] { display: none !important; }

/* ---- admin account switcher (view-as) and the family dashboard ---- */
.viewas { position: relative; }
.viewas-btn { padding: 0.4rem 0.7rem; gap: 0.4rem; }
.viewas-btn.on { border-color: var(--color-accent); color: var(--color-accent); }
.viewas-btn .ava, .viewas-item .ava { width: 22px; height: 22px; flex: 0 0 22px; }
.viewas-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewas-btn .caret { width: 12px; height: 12px; opacity: 0.6; }
.viewas-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 230px;
  background: var(--color-secondary); border: 1px solid var(--color-border); border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.14); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.viewas-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: none; border-radius: 8px; padding: 8px 10px; font: inherit; color: inherit;
}
.viewas-item:hover { background: var(--color-hover); }
.viewas-item.cur { background: var(--color-accent-bg); }
.viewas-item-name { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.viewas-item-handle { font-size: 0.74rem; color: var(--color-text-muted); }
.viewas-tag { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted);
  border: 1px solid var(--color-border-light); border-radius: 999px; padding: 1px 7px; }
.viewas-check { color: var(--color-accent); font-weight: 600; }
.viewas-banner {
  position: sticky; top: var(--topbar-h, 56px); z-index: 999;
  background: var(--color-accent-bg); border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-secondary); font-size: 0.9rem; padding: 8px 22px; text-align: center;
}
.linklike { background: none; border: none; color: var(--color-accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.fam-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.fam-card { padding: 20px; }
.fam-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.fam-ava .ava { width: 30px; height: 30px; }
.fam-name { font-weight: 500; flex: 1; }
.fam-rows { display: flex; flex-direction: column; gap: 8px; }
.fam-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; font-size: 0.9rem; }
.fam-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); }
.fam-label .ic { width: 1.2em; height: 1.2em; margin-right: 5px; vertical-align: -0.22em; }
.fam-main { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.fam-extra { text-align: right; font-size: 0.82rem; white-space: nowrap; }
.fam-note { margin-top: 18px; font-size: 0.84rem; }
@media (max-width: 520px) { .fam-row { grid-template-columns: 88px 1fr; } .fam-extra { grid-column: 2; text-align: left; } }

/* ============ PHONE ============
   On a narrow screen the topbar used to keep everything on one line: the cabinet tabs, being the
   only shrinkable item, were squeezed to zero width and vanished, and the rest overflowed sideways.
   Here the bar wraps into two rows: brand, account and logout on top; the cabinet tabs below at
   full width, scrollable with a finger. The view-as menu becomes a full-width sheet. */
/* Grid and flex children default to min-width:auto, so one wide table or strip inside a card
   stretched the whole page sideways instead of scrolling inside itself. */
.card, .grid > *, .shell > * { min-width: 0; }

@media (max-width: 760px) {
  :root { --topbar-h: 98px; }
  .topbar { height: auto; flex-wrap: wrap; column-gap: 10px; row-gap: 4px; padding: 8px 12px 6px; }
  .brand { font-size: 0.98rem; }
  .who { display: none; }
  .tabs { order: 10; flex: 1 0 100%; padding-bottom: 2px; }
  .tab { padding: 6px 12px; font-size: 0.88rem; }
  .shell { padding: calc(var(--topbar-h) + 18px) 14px 64px; }
  .viewas-name { max-width: 88px; }
  .viewas-menu { position: fixed; left: 10px; right: 10px; top: 54px; min-width: 0;
    max-height: 70vh; overflow-y: auto; }
  .viewas-item { padding: 12px 10px; }
  .viewas-banner { padding: 8px 12px; font-size: 0.85rem; }
  table.grid-table { display: block; overflow-x: auto; }
  .section-title { flex-wrap: wrap; row-gap: 2px; }
}
/* Brand text, account and logout do not fit one 375px row together; the mark alone carries
   the brand, so the first row stays one row and the tabs stay the second. */
@media (max-width: 440px) {
  .brand span { display: none; }
}
