/* ==========================================================================
   ХИМБИОРУС — визуальный стиль «Red Sun»
   Почти чёрный фон, тёплое оранжевое свечение, стеклянные тёмные панели.
   ========================================================================== */

:root {
  --font: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --bg: #08080a;
  --bg-2: #0d0d10;
  --surface: #111114;
  --surface-2: #17171b;
  --surface-3: #1e1e23;
  --glass: rgba(20, 20, 24, 0.72);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #f4f1ec;
  --muted: #a39e96;
  --faint: #6f6b65;

  --accent: #ff6b1a;
  --accent-2: #ff9a4d;
  --accent-ink: #1a0b02;
  --accent-soft: rgba(255, 107, 26, 0.14);
  --accent-glow: rgba(255, 107, 26, 0.45);

  --bio: #3ddc97;
  --chem: #a78bfa;
  --rus: #ff6fae;
  --general: #d4b98f;

  --danger: #ff5a5f;
  --practice: #ff1f2e;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f3ef;
  --bg-2: #efe9e2;
  --surface: #ffffff;
  --surface-2: #fbf8f5;
  --surface-3: #f1ece6;
  --glass: rgba(255, 255, 255, 0.78);
  --line: rgba(40, 24, 10, 0.09);
  --line-2: rgba(40, 24, 10, 0.16);
  --text: #17120d;
  --muted: #6c6358;
  --faint: #9a9086;

  --accent: #f25c05;
  --accent-2: #ff8a3d;
  --accent-ink: #ffffff;
  --accent-soft: rgba(242, 92, 5, 0.1);
  --accent-glow: rgba(242, 92, 5, 0.3);

  --bio: #14a86c;
  --chem: #7c5ce6;
  --rus: #e0457f;
  --general: #a3825a;
  --shadow: 0 24px 50px -28px rgba(60, 30, 5, 0.35);
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 500 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: var(--safe-bottom);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.page-glow {
  position: fixed; inset: -20vh -10vw auto; height: 90vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(255, 107, 26, 0.18), transparent 70%),
    radial-gradient(40% 40% at 15% 10%, rgba(255, 154, 77, 0.07), transparent 70%);
}
:root[data-theme="light"] .page-glow {
  background: radial-gradient(60% 50% at 50% 0%, rgba(255, 138, 61, 0.2), transparent 70%);
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  font-weight: 700; font-size: 13px; letter-spacing: 0.01em; white-space: nowrap;
  transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.3s;
}
.btn:hover { border-color: var(--line-2); background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn-sm { height: 32px; padding: 0 12px; }
.btn-block { width: 100%; }

.btn-primary {
  position: relative; overflow: hidden;
  border-color: transparent; color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 0 1px rgba(255, 170, 110, 0.35) inset, 0 8px 24px -8px var(--accent-glow);
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffab6b, var(--accent)); box-shadow: 0 0 0 1px rgba(255, 190, 140, 0.5) inset, 0 10px 34px -6px var(--accent-glow); }
.btn-primary:hover::after { transition: transform 0.8s var(--ease); transform: translateX(120%); }
.btn-primary.is-active { box-shadow: 0 0 0 2px var(--text) inset, 0 10px 34px -6px var(--accent-glow); }

.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: rgba(255, 90, 95, 0.35); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 90, 95, 0.1); }
.btn .count, .btn em { font-style: normal; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 18px; line-height: 1; transition: background 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--line-2); }
.icon-btn:active { transform: scale(0.94); }

em[data-backlog-count], em[data-sync-peers], .count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font: 800 10px/1 var(--font); font-style: normal;
}

/* ------------------------------------------------------------------ шапка */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) clamp(16px, 3vw, 32px) 10px;
  background: linear-gradient(to bottom, var(--bg) 20%, color-mix(in srgb, var(--bg) 70%, transparent));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; justify-self: start; }
.brand-sun {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 50% 70%, #ffc38a, var(--accent) 55%, #b53a00);
  box-shadow: 0 0 18px var(--accent-glow);
  animation: sun-pulse 5s ease-in-out infinite;
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand-name span { color: var(--accent); }

.topbar-nav { display: flex; align-items: center; gap: 8px; }
.topbar-period { display: grid; text-align: center; min-width: 210px; }
.topbar-period span { font-weight: 700; font-size: 14px; }
.topbar-period small { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }

.topbar-actions { display: flex; align-items: center; gap: 8px; justify-self: end; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--muted); max-width: 280px;
}
.sync-pill:hover { border-color: var(--line-2); color: var(--text); }
.sync-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
[data-state="online"] .sync-dot { background: #37d67a; box-shadow: 0 0 0 4px rgba(55, 214, 122, 0.15); }
[data-state="connecting"] .sync-dot { background: #ffc043; animation: blink 1s ease-in-out infinite; }
[data-state="offline"] .sync-dot { background: var(--danger); }

.menu-anchor { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; width: 270px;
  padding: 6px; border-radius: 16px; border: 1px solid var(--line-2);
  background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  animation: pop 0.22s var(--ease);
}
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border: 0; border-radius: 10px; background: none; text-align: left;
  color: inherit; text-decoration: none; font-size: 13px; font-weight: 600;
}
.menu button b { font-weight: 600; }
.menu button > span, .menu a > span { width: 20px; text-align: center; opacity: 0.85; }
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu .danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

/* ------------------------------------------------------------------ герой */

.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center;
  padding: clamp(40px, 8vw, 88px) 20px 0;
  isolation: isolate;
}

.is-loaded .hero > *:not(.sun) { animation: rise 0.9s var(--ease) backwards; }
.is-loaded .hero > :nth-child(2) { animation-delay: 0.08s; }
.is-loaded .hero > :nth-child(3) { animation-delay: 0.16s; }
.is-loaded .hero > :nth-child(4) { animation-delay: 0.24s; }

.hero-badge {
  display: inline-flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--glass);
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.hero-badge-chip {
  padding: 3px 10px; border-radius: 999px; font-weight: 800; font-size: 11px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
}

.hero-title {
  margin: 22px 0 14px; font-size: clamp(34px, 6vw, 68px); line-height: 1.02;
  font-weight: 700; letter-spacing: -0.045em;
}
.hero-title span {
  background: linear-gradient(180deg, var(--text) 30%, var(--muted));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { max-width: 620px; margin: 0; color: var(--muted); font-size: clamp(14px, 1.6vw, 16px); }

.hero-stats {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1.1fr repeat(3, 1fr) 1fr; gap: 10px;
  width: min(1040px, 100%); margin: 34px 0 0;
}
.stat.load { --c: var(--accent); }
.stat.load .stat-value { font-size: 22px; }
.stat {
  display: grid; gap: 10px; align-content: center; text-align: left;
  padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.stat-main { grid-template-columns: auto 1fr; align-items: center; gap: 12px; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; color: var(--accent); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-label b { color: var(--text); font-weight: 700; }
.stat-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.stat-head b { margin-left: auto; color: var(--text); font-weight: 700; }
.stat-head i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.stat-bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.stat-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--c); transition: width 0.8s var(--ease); }
.stat.bio { --c: var(--bio); }
.stat.chem { --c: var(--chem); }
.stat.rus { --c: var(--rus); }

/* Солнце-затмение за доской */
.sun {
  position: relative; z-index: 1; width: min(1100px, 150vw); aspect-ratio: 2.4 / 1;
  margin-top: -30px; margin-bottom: calc(min(1100px, 150vw) * -0.13);
  pointer-events: none;
}
.sun-core, .sun-rim {
  position: absolute; left: 50%; top: 45%; width: 72%; aspect-ratio: 1; border-radius: 50%;
  transform: translateX(-50%);
}
.sun-core {
  background: radial-gradient(circle at 50% 0%, #ffb070 0%, #ff6b1a 18%, #8a2c00 38%, #1a0a02 60%, transparent 72%);
  filter: blur(2px);
  opacity: 0.95;
  animation: sun-breathe 7s ease-in-out infinite;
}
.sun-rim {
  box-shadow:
    0 -2px 0 0 rgba(255, 222, 190, 0.9),
    0 -10px 40px 4px rgba(255, 120, 40, 0.75),
    0 -40px 120px 30px rgba(255, 90, 0, 0.35);
  background: radial-gradient(circle at 50% 30%, #121214 0%, var(--bg) 70%);
  top: calc(45% + 18px);
  width: 70%;
}
.sun::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 55%, var(--bg) 82%);
}
:root[data-theme="light"] .sun-core { opacity: 0.8; }
:root[data-theme="light"] .sun-rim { background: radial-gradient(circle at 50% 30%, #fff 0%, var(--bg) 70%); }

/* ------------------------------------------------------------------ доска */

main { position: relative; }

.board-shell {
  position: relative; z-index: 3;
  width: calc(100% - 2 * clamp(12px, 3vw, 32px)); max-width: 1560px;
  margin: 0 auto; padding: 14px;
  border-radius: 26px; border: 1px solid var(--line-2);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), var(--bg-2));
  box-shadow: 0 -30px 80px -40px var(--accent-glow), var(--shadow);
}
.board-shell::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 140, 70, 0.45), transparent 22%) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  border: 1px solid transparent;
}

.periods {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 12px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.periods::-webkit-scrollbar { display: none; }
.period-tab {
  flex: none; display: flex; align-items: center; gap: 8px; scroll-snap-align: center;
  height: 36px; padding: 0 14px 0 6px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.period-num {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-3); font-size: 10px; font-weight: 800; color: var(--faint);
}
.period-tab:hover { color: var(--text); border-color: var(--line-2); }
.period-tab.is-active { color: var(--text); background: var(--accent-soft); border-color: rgba(255, 107, 26, 0.45); }
.period-tab.is-active .period-num { background: var(--accent); color: var(--accent-ink); }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 2px 12px; }
.controls-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.chips { display: flex; gap: 4px; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 12px; font-weight: 700;
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip.bio { --c: var(--bio); } .chip.chem { --c: var(--chem); } .chip.rus { --c: var(--rus); }
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--surface-3); color: var(--text); box-shadow: 0 0 0 1px var(--line-2) inset; }

.select select {
  height: 38px; padding: 0 34px 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12px; font-weight: 700; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select select option { background: var(--surface); color: var(--text); }

.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 36px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2); transition: background 0.25s; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.3s var(--ease), background 0.25s; }
.switch input:checked + .switch-track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.search {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 6px 0 14px; min-width: 200px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.search:focus-within { border-color: rgba(255, 107, 26, 0.5); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 13px; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
.search button { border: 0; background: var(--surface-3); width: 26px; height: 26px; border-radius: 50%; font-size: 11px; }

.zoom { display: flex; align-items: center; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.zoom button { height: 30px; min-width: 30px; padding: 0 8px; border: 0; border-radius: 999px; background: none; font-weight: 700; font-size: 14px; }
.zoom button:hover { background: var(--surface-3); }
#zoom-fit { font-size: 11px; color: var(--muted); min-width: 52px; }

.filter-note {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 2px 12px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid rgba(255, 192, 67, 0.25); background: rgba(255, 192, 67, 0.08); color: var(--text); font-size: 12px;
}
.filter-note button { border: 0; background: none; color: var(--accent); font-weight: 800; }

.board-viewport {
  position: relative; overflow-x: auto; overflow-y: hidden;
  border-radius: 18px; background: var(--bg);
  border: 1px solid var(--line);
  touch-action: pan-x pan-y;
  scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}
.board-viewport.is-file-over { box-shadow: 0 0 0 2px var(--accent) inset; }
.board-sizer { position: relative; margin: 0 auto; }
.board { position: absolute; left: 0; top: 0; width: 1480px; transform-origin: 0 0; }

.weeks { display: grid; gap: 8px; padding: 16px; }
.week { display: grid; grid-template-columns: repeat(7, 200px); gap: 8px; }

/* Все 12 периодов идут один под другим в общей ленте */
.period-block { display: grid; gap: 8px; }
.period-divider {
  display: flex; align-items: baseline; gap: 10px;
  padding: 28px 4px 6px; margin-top: 14px; border-top: 1px solid var(--line);
}
.period-block:first-child .period-divider { margin-top: 0; padding-top: 2px; border-top: 0; }
.period-divider-num {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-3); font-size: 10px; font-weight: 800; color: var(--faint);
}
.period-divider-name { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
.period-divider-load { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.period-divider-load b { color: var(--accent); font-weight: 800; }

.day {
  display: flex; flex-direction: column; min-height: 132px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.day-head { display: flex; align-items: baseline; gap: 6px; padding: 10px 10px 6px 12px; }
.day-name { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; color: var(--faint); }
.day-num { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.day-month { font-size: 11px; color: var(--muted); }
.day-add {
  margin-left: auto; align-self: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line); background: none; color: var(--muted); font-size: 15px; line-height: 1;
  opacity: 0; transition: opacity 0.2s, background 0.2s, color 0.2s;
}
/* Нагрузка дня в часах — рядом с датой */
.day-load {
  margin-left: auto; align-self: center; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 800; white-space: nowrap;
}
.day-load.is-heavy { background: var(--accent-soft); color: var(--accent); }
.day-load + .day-add { margin-left: 4px; }
.day:hover .day-add, .day-add:focus-visible { opacity: 1; }
.day-add:hover { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
@media (hover: none) { .day-add { opacity: 0.6; } }

.day.is-today { border-color: rgba(255, 107, 26, 0.55); box-shadow: 0 0 0 1px rgba(255, 107, 26, 0.25), 0 10px 30px -14px var(--accent-glow); }
.day.is-today .day-num { color: var(--accent); }
.day.is-empty .day-num { color: var(--faint); }

.day-list { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 0 6px 8px; min-height: 40px; border-radius: 0 0 14px 14px; transition: background 0.2s; }
.day-list.is-drop-target, .backlog-list.is-drop-target { background: var(--accent-soft); }

/* Оплата: одна узкая полоса через все дни срока, её нельзя двигать или отмечать */
.week-banners { display: grid; grid-template-columns: repeat(7, 200px); gap: 8px; margin-bottom: -2px; }
.pay-banner {
  display: flex; align-items: center; gap: 8px; min-width: 0; height: 26px; padding: 0 10px;
  border-radius: 8px; border: 1px solid color-mix(in srgb, var(--general) 55%, transparent);
  background: color-mix(in srgb, var(--general) 24%, var(--surface));
  color: var(--text); font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden;
  cursor: default; user-select: none;
}
.pay-icon {
  display: grid; place-items: center; flex: none; width: 16px; height: 16px; border-radius: 5px;
  background: var(--general); color: #0b0b0d; font-size: 10px; font-weight: 800;
}
.pay-title { overflow: hidden; text-overflow: ellipsis; }
.pay-range { flex: none; margin-left: auto; color: color-mix(in srgb, var(--text) 70%, transparent); font-weight: 600; }

/* ------------------------------------------------------------------ плашки */

/* Невыполненная плашка залита цветом предмета, выполненная — серая и тусклая.
   Тест или ДЗ к занятию — тот же цвет, но прозрачнее. */
.card {
  --c: var(--general);
  --fill: 30%;
  --edge: 55%;
  position: relative; padding: 8px 7px 9px 12px; border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--c) var(--edge), transparent);
  background: color-mix(in srgb, var(--c) var(--fill), var(--surface));
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 0.25s var(--ease), border-color 0.2s, box-shadow 0.25s, opacity 0.25s, background 0.25s, filter 0.25s;
}
:root[data-theme="light"] .card { --fill: 20%; --edge: 60%; }
.card::before {
  content: ''; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--c);
}
.card:hover { box-shadow: 0 8px 22px -12px var(--c); transform: translateY(-1px); }
.card.bio { --c: var(--bio); }
.card.chem { --c: var(--chem); }
.card.rus { --c: var(--rus); }

.card-top {
  display: flex; align-items: center; gap: 3px; min-height: 20px;
  padding-right: 24px; /* место под галочку — она закреплена в углу и не уезжает */
  overflow: hidden;
}
.pill {
  display: inline-flex; align-items: center; height: 17px; padding: 0 5px; border-radius: 6px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap;
}
.pill.subject { color: #0b0b0d; background: var(--c); }
.pill { flex: none; }
/* Если строке не хватает места, сжимается только тип занятия — с многоточием */
.pill.type {
  flex: 0 1 auto; min-width: 0; display: block; line-height: 17px; overflow: hidden; text-overflow: ellipsis;
  color: color-mix(in srgb, var(--text) 85%, transparent); background: rgba(0, 0, 0, 0.28);
}
:root[data-theme="light"] .pill.type { background: rgba(255, 255, 255, 0.65); }
.pill.icon { min-width: 17px; justify-content: center; padding: 0; background: var(--accent); color: #fff; font-size: 11px; }
.card-time { flex: none; margin-left: 1px; font-size: 10px; font-weight: 800; color: color-mix(in srgb, var(--text) 80%, transparent); }

.card-check {
  position: absolute; top: 7px; right: 6px; width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid color-mix(in srgb, var(--text) 45%, transparent); background: rgba(0, 0, 0, 0.18);
  transition: background 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
:root[data-theme="light"] .card-check { background: rgba(255, 255, 255, 0.7); }
.card-check:hover { border-color: var(--text); }
.card-check:active { transform: scale(0.85); }

.card-title { margin-top: 5px; font-size: 12.5px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.card-sub {
  margin-top: 3px; font-size: 11px; line-height: 1.3; color: color-mix(in srgb, var(--text) 72%, transparent);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-deadline {
  margin-top: 4px; font-size: 9px; font-weight: 700; letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--text) 55%, transparent);
}
.card-deadline.is-late { color: var(--danger); }

.card.is-companion { --fill: 14%; --edge: 38%; border-style: dashed; }
:root[data-theme="light"] .card.is-companion { --fill: 9%; --edge: 45%; }
.card.is-companion .card-title { font-weight: 600; font-size: 12px; }

.card.cat-mock .pill.type, .card.cat-attestation .pill.type { color: #fff; background: var(--accent); }

/* Выполнено: без цвета и приглушённо */
.card.is-done {
  --c: #8a8680;
  --fill: 0%;
  --edge: 18%;
  opacity: 0.4;
  filter: grayscale(1);
  box-shadow: none;
}
.card.is-done:hover { opacity: 0.7; }
.card.is-done .card-title { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 50%, transparent); }
.card.is-done .card-check { background: var(--text); border-color: transparent; }
.card.is-done .card-check::after {
  content: ''; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid var(--bg); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* Тест или ДЗ стоит сразу под своим занятием — полоска слева соединяет их */
.card.link-below::before { bottom: -8px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.card.link-above::before { top: -8px; border-top-left-radius: 0; border-top-right-radius: 0; }
.card.link-below { z-index: 1; }
/* Практика вместе со своим ДЗ/тестом — красная полоска; разъединили — возвращается цвет предмета */
.card.practice-block::before { left: 3px; width: 5px; background: var(--practice); }

.card.is-drag-source { opacity: 0.25; }
.drag-ghost {
  position: fixed !important; left: 0; top: 0; z-index: 200; margin: 0; pointer-events: none;
  transform-origin: 0 0; box-shadow: 0 24px 40px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--c);
  background: var(--surface-3); opacity: 0.96; transition: none;
}
.drop-marker { height: 3px; margin: -1px 4px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* ------------------------------------------------------------------ слои: фото и стилус */

.photos-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.photo {
  position: absolute; pointer-events: auto; touch-action: auto; cursor: move;
  border-radius: 10px; box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.7);
}
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; user-select: none; -webkit-user-drag: none; }
.photo.is-selected { touch-action: none; z-index: 999 !important; }
.photo-frame { position: absolute; inset: -2px; border-radius: 12px; border: 2px solid var(--accent); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.photo.is-selected .photo-frame { opacity: 1; }
.photo-handle {
  position: absolute; width: 22px; height: 22px; border-radius: 50%; pointer-events: auto;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); touch-action: none;
}
.photo-handle[data-corner="nw"] { left: -11px; top: -11px; cursor: nwse-resize; }
.photo-handle[data-corner="ne"] { right: -11px; top: -11px; cursor: nesw-resize; }
.photo-handle[data-corner="sw"] { left: -11px; bottom: -11px; cursor: nesw-resize; }
.photo-handle[data-corner="se"] { right: -11px; bottom: -11px; cursor: nwse-resize; }
.photo.is-selected .photo-frame .photo-handle { pointer-events: auto; }
.photo-tools {
  position: absolute; left: 50%; bottom: calc(100% + 14px); transform: translateX(-50%);
  display: none; gap: 4px; padding: 4px; border-radius: 999px; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--line-2); backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.photo.is-selected .photo-tools { display: flex; }
.photo-tools button { height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: none; font-size: 12px; font-weight: 700; }
.photo-tools button:hover { background: var(--surface-3); }
.photo-tools [data-photo="delete"] { color: var(--danger); }
.photo.is-pinned { pointer-events: none; box-shadow: none; }
.photos-layer.is-editing-pinned .photo.is-pinned { pointer-events: auto; outline: 2px dashed var(--accent); }

.ink-canvas { position: absolute; left: 0; top: 0; z-index: 10; pointer-events: none; }
.ink-overlay { z-index: 11; touch-action: none; }
body.is-drawing .ink-overlay { pointer-events: auto; cursor: crosshair; }
body.is-drawing .photo { pointer-events: none; }
body.is-drawing .board-viewport { box-shadow: 0 0 0 2px var(--accent) inset; }
.board.layers-hidden .photos-layer, .board.layers-hidden ~ .ink-canvas { visibility: hidden; }

.ink-toolbar {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); z-index: 90;
  display: flex; align-items: center; gap: 6px; max-width: calc(100vw - 24px); overflow-x: auto;
  padding: 6px; border-radius: 999px; transform: translateX(-50%);
  background: var(--glass); border: 1px solid var(--line-2);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 107, 26, 0.12);
  animation: toolbar-in 0.35s var(--ease);
  scrollbar-width: none;
}
.ink-toolbar::-webkit-scrollbar { display: none; }
.ink-group { display: flex; align-items: center; gap: 2px; padding: 0 4px; flex: none; }
.ink-group + .ink-group { border-left: 1px solid var(--line); }
.tool {
  display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; border: 0; border-radius: 999px;
  background: none; font-size: 16px; color: var(--muted); transition: background 0.2s, color 0.2s;
}
.tool.text { font-size: 11px; font-weight: 800; }
.tool:hover { color: var(--text); background: var(--surface-3); }
.tool.is-active { color: var(--accent-ink); background: var(--accent); }
.swatch {
  position: relative; width: 26px; height: 26px; margin: 0 2px; border-radius: 50%; border: 2px solid var(--line-2);
  background: var(--c); transition: transform 0.2s var(--ease);
}
.swatch.is-active { transform: scale(1.15); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c); }
.swatch-custom { display: inline-block; overflow: hidden; background: conic-gradient(#ff5a5f, #ffd23f, #3ddc97, #39a0ff, #a78bfa, #ff5a5f); cursor: pointer; }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ink-size { gap: 8px; }
.ink-size input { width: 110px; accent-color: var(--accent); }
.ink-size output { min-width: 18px; font-size: 11px; font-weight: 800; color: var(--muted); }
.size-dot { width: 24px; height: 24px; display: grid; place-items: center; }
.size-dot::after { content: ''; width: var(--dot, 6px); height: var(--dot, 6px); border-radius: 50%; background: var(--text); }

/* ------------------------------------------------------------------ отложенные */

.scrim { position: fixed; inset: 0; z-index: 94; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(2px); animation: fade 0.2s; }
.backlog {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 95; width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 12px; padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  background: var(--bg-2); border-left: 1px solid var(--line-2); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform 0.4s var(--ease);
}
.backlog.is-open { transform: none; }
.backlog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.backlog h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.backlog p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.backlog-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 14px; border: 1px dashed var(--line-2); }
.empty-hint { margin: auto; color: var(--faint); font-size: 12px; text-align: center; padding: 24px; }

/* ------------------------------------------------------------------ окна */

.modal {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0); transition: background 0.2s;
}
.modal.is-open { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dialog {
  width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  display: grid; gap: 14px; padding: 20px; border-radius: 22px;
  background: var(--bg-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px) scale(0.98); transition: opacity 0.2s, transform 0.3s var(--ease);
}
.dialog-wide { width: min(620px, 100%); }
.modal.is-open .dialog { opacity: 1; transform: none; }
.dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.dialog header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.dialog footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.spacer { flex: 1; }
.lead { margin: 0 0 14px; color: var(--muted); }

.field { display: grid; gap: 6px; flex: 1; min-width: 0; }
.field > span { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; color: var(--muted); }
.field input, .field select {
  height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface);
  outline: none; width: 100%;
}
.field select option { background: var(--surface); }
.field input:focus, .field select:focus { border-color: rgba(255, 107, 26, 0.6); box-shadow: 0 0 0 4px var(--accent-soft); }
.field-row { display: flex; gap: 10px; }
.switch-row { padding: 4px 0; }

.sync-status-line { display: flex; align-items: center; gap: 8px; }
.room-grid { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start; }
.room-qr { aspect-ratio: 1; padding: 10px; border-radius: 16px; background: #fff; display: grid; place-items: center; }
.room-qr svg { width: 100%; height: 100%; }
.room-info { display: grid; gap: 8px; min-width: 0; }
.room-label { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; color: var(--muted); }
.room-code {
  justify-self: start; border: 0; background: none; padding: 0;
  font-size: 28px; font-weight: 800; letter-spacing: 0.04em; color: var(--accent);
}
.room-link { display: block; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.devices { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.devices li { padding: 4px 10px; border-radius: 999px; background: var(--surface-3); font-size: 12px; font-weight: 600; }
.devices li.is-self { background: var(--accent-soft); color: var(--accent); }
#sync-pending { color: var(--faint); }
.join { display: flex; gap: 8px; align-items: flex-end; }
.advanced { border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary { cursor: pointer; color: var(--muted); font-weight: 700; font-size: 13px; }
.advanced > * + * { margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); z-index: 300;
  padding: 10px 16px; border-radius: 999px; max-width: calc(100vw - 32px);
  background: var(--glass); border: 1px solid var(--line-2); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  font-size: 13px; font-weight: 700; box-shadow: var(--shadow);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity 0.25s, transform 0.35s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ подвал */

.footer { width: min(1560px, calc(100% - 32px)); margin: 20px auto 40px; color: var(--faint); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 10px; color: var(--muted); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 8px; height: 8px; border-radius: 50%; }
.lg-dot.bio { background: var(--bio); } .lg-dot.chem { background: var(--chem); } .lg-dot.rus { background: var(--rus); }
.lg-sign { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.lg-dash { width: 18px; height: 12px; border-radius: 4px; border: 1px dashed var(--line-2); }

.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ нижняя панель */

.bottom-bar { display: none; }

@media (max-width: 860px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 8px; padding-left: 12px; padding-right: 12px; }
  .brand-name { display: none; }
  .topbar-period { min-width: 0; }
  .topbar-period span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-nav { min-width: 0; justify-content: center; }
  .sync-pill { width: 38px; padding: 0; justify-content: center; }
  .sync-pill .sync-text { display: none; }
  .hide-mobile { display: none; }
  .topbar-actions .menu-anchor { position: static; }
  .menu { position: fixed; top: auto; left: 12px; right: 12px; bottom: calc(76px + var(--safe-bottom)); width: auto; }

  .hero { padding: 24px 16px 0; }
  .hero-title { margin: 16px 0 10px; }
  .hero-sub { font-size: 13px; }
  .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 20px; }
  .stat-main { grid-column: 1 / -1; }
  .stat { padding: 10px; }
  .stat-head { font-size: 11px; flex-wrap: wrap; gap: 4px 6px; }
  .sun { width: 170vw; margin-top: -10px; margin-bottom: -24vw; }

  .board-shell { width: 100%; padding: 10px 8px; border-radius: 22px; }
  .controls-end { margin-left: 0; width: 100%; }
  .controls-end .btn { flex: 1; }
  .search { flex: 1 1 100%; }

  body { padding-bottom: calc(72px + var(--safe-bottom)); }
  .bottom-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + var(--safe-bottom));
    background: var(--glass); border-top: 1px solid var(--line-2);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  }
  .bottom-bar button {
    display: grid; justify-items: center; gap: 2px; padding: 6px 0; border: 0; border-radius: 12px; background: none;
    font-size: 10px; font-weight: 700; color: var(--muted);
  }
  .bottom-bar button span { position: relative; font-size: 18px; line-height: 1.2; color: var(--text); }
  .bottom-bar em { position: absolute; top: -4px; right: -12px; }
  .bottom-bar button.is-active { color: var(--accent); }
  .ink-toolbar { bottom: calc(78px + var(--safe-bottom)); border-radius: 22px; }
  .toast { bottom: calc(140px + var(--safe-bottom)); }
  .room-grid { grid-template-columns: 1fr; }
  .room-qr { width: 200px; justify-self: center; }
  .join { flex-direction: column; align-items: stretch; }
  .field-row { flex-direction: column; }
}

@media (max-width: 520px) {
  .hero-title { font-size: 32px; }
  .sun { margin-top: -10px; }
  .chips { width: 100%; justify-content: space-between; }
  .chip { padding: 0 8px; }
}

/* ------------------------------------------------------------------ анимации */

@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
@keyframes fade { from { opacity: 0; } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes board-in { from { opacity: 0.2; transform: translateY(10px); } }
@keyframes toolbar-in { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes sun-pulse { 50% { box-shadow: 0 0 28px var(--accent-glow); } }
@keyframes sun-breathe {
  0%, 100% { transform: translateX(-50%) scale(1); filter: blur(2px) brightness(1); }
  50% { transform: translateX(-50%) scale(1.02); filter: blur(3px) brightness(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ печать */

@media print {
  .topbar, .hero, .controls, .periods, .bottom-bar, .ink-toolbar, .footer, .filter-note, .toast, .page-glow { display: none !important; }
  body { background: #fff; color: #000; }
  .board-shell { border: 0; box-shadow: none; padding: 0; width: 100%; background: none; }
  .board-shell::before { display: none; }
  .board-viewport { overflow: visible; border: 0; }
  .reveal { opacity: 1; transform: none; }
}
