/* Оболочка приложения: три раскладки по ширине окна, как в прототипах.
   телефон < 768: стеклянный таб-бар, FAB, листы снизу;
   планшет 768-1279: rail 72 px, карточка поверх списка;
   десктоп >= 1280: sidebar 248 px (сворачивается в rail), правая панель 380-720 px. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 13px; line-height: 1.35; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); }
: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; }

.app { position: relative; display: flex; height: 100dvh; overflow: hidden; background: var(--bg); }

/* ---------- sidebar / rail */
.side { width: var(--side-w); flex: none; display: flex; flex-direction: column; gap: 1px; padding: 12px 10px 10px; overflow-y: auto; scrollbar-width: none; }
.side::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 12px; }
.logo-mark { width: 30px; height: 30px; flex: none; object-fit: contain; }
.bname { font-weight: 650; font-size: 14px; }
.bsub { font-size: 11px; color: var(--fg3); }
.nav { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 8px 0 10px; border-radius: 9px; color: var(--fg2); text-align: left; text-decoration: none; }
.nav:hover { background: var(--sep2); }
.nav.on { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px var(--shadow); }
.nav .ic { color: var(--fg3); display: flex; }
.nav.on .ic { color: var(--accent); }
.nav .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav .rl { display: none; }
.cnt { font-size: 11px; color: var(--fg3); font-variant-numeric: tabular-nums; display: flex; gap: 6px; }
.cnt .r { color: var(--red); font-weight: 600; }
.cnt .a { color: var(--accent); font-weight: 600; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 650; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.sec { display: flex; align-items: center; gap: 4px; padding: 14px 6px 4px 10px; font-size: 11px; font-weight: 600; color: var(--fg3); text-transform: uppercase; letter-spacing: .06em; }
.sec .nm { flex: 1; }
.tree-empty { padding: 4px 10px; color: var(--fg3); font-size: 12px; }
.ib { width: 26px; height: 26px; border-radius: 7px; color: var(--fg3); display: flex; align-items: center; justify-content: center; flex: none; }
.ib:hover { background: var(--sep); color: var(--fg); }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; text-align: left; width: 100%; }
.me:hover { background: var(--sep2); }
.me .bt { min-width: 0; flex: 1; }
.me .mail { font-size: 11px; color: var(--fg3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av { border-radius: 50%; color: #fff; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; font-size: 11px; letter-spacing: .02em; background: var(--accent-fill); }
.collapse { margin: 6px auto 0; }
.cat-ic { display: inline-block; width: 22px; height: 20px; background: var(--cat-front) center bottom / contain no-repeat; }

/* rail: планшет всегда, десктоп после «Свернуть меню» */
.side-collapsed .app .side { width: var(--rail-w); align-items: center; padding: 12px 0 10px; }
.side-collapsed .app .brand { padding: 2px 0 12px; justify-content: center; }
.side-collapsed .app .brand .bt, .side-collapsed .app .nav .nm, .side-collapsed .app .nav .cnt, .side-collapsed .app .sec, .side-collapsed .app .tree, .side-collapsed .app .me .bt { display: none; }
.side-collapsed .app .nav { width: 48px; min-height: 44px; justify-content: center; padding: 0; flex-direction: column; gap: 2px; }
.side-collapsed .app .nav .rl { display: block; font-size: 9.5px; font-weight: 600; }
.side-collapsed .app .nav .badge { position: absolute; top: 3px; right: 5px; min-width: 16px; height: 16px; font-size: 9.5px; }
.side-collapsed .app .me { width: auto; padding: 6px; }
.nav.spaces-rail { display: none; }
.side-collapsed .app .nav.spaces-rail { display: flex; }

/* ---------- рабочая область */
.main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; margin: 8px; margin-left: 0; background: var(--surface); border-radius: 16px; box-shadow: 0 0 0 1px var(--sep2); overflow: hidden; }
.app.paneled:not(.overlay) .main { margin-right: 0; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.body { padding: 16px 22px 40px; }
.hdr-d { min-height: 56px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 8px 14px 8px 22px; border-bottom: 1px solid var(--sep); flex: none; }
.hdr-d .tt { display: flex; flex-direction: column; min-width: 0; margin-right: 4px; }
.h1 { font-size: 17px; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.hsub { font-size: 11.5px; color: var(--fg3); white-space: nowrap; }
.hsp { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 6px 0 10px; border-radius: 9px; background: var(--surface2); color: var(--fg3); width: 200px; font-size: 12.5px; text-align: left; }
.search:hover { color: var(--fg2); }
.kbd { font-size: 10.5px; border: 1px solid var(--sep); border-radius: 5px; padding: 1px 5px; color: var(--fg3); background: var(--surface); white-space: nowrap; }
.search .kbd { margin-left: auto; }
.btn { height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.btn.pri { background: var(--accent-fill); color: var(--on-accent); }
.btn.pri:hover { filter: brightness(1.07); }
.btn.gh { color: var(--fg2); box-shadow: inset 0 0 0 1px var(--sep); }
.btn.gh:hover { background: var(--hover); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.dng { color: var(--red); }
.btn.dng-fill { background: var(--red); color: #fff; }
.btn:disabled { opacity: .4; pointer-events: none; }

/* шапка телефона */
.hdr-m, .compact, .tabbar, .fab, .ground { display: none; }

/* ---------- правая панель (карточка задачи, помощник) */
.panel { position: relative; z-index: 30; width: var(--panel-w, 480px); min-width: 380px; max-width: 720px; flex: none; margin: 8px; display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: 0 0 0 1px var(--sep2), 0 8px 30px var(--shadow); overflow: hidden; }
.panel .phead { display: flex; align-items: center; gap: 6px; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--sep2); }
.panel .phead .pt { font-weight: 650; font-size: 14px; flex: 1; min-width: 0; }
.panel .pbody { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 24px; }
.panel .resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2; }
.pscrim { position: absolute; inset: 0; background: var(--scrim); z-index: 39; display: none; }
.app.expanded .pscrim { display: block; }
.app.expanded .panel { position: absolute; left: var(--side-w); right: 0; top: 0; bottom: 0; width: auto; max-width: none; z-index: 40; }
.side-collapsed .app.expanded .panel { left: var(--rail-w); }

/* ---------- состояния экранов */
.state { margin: 70px auto; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 0 16px; }
.state .big { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: var(--fg3); }
.state h3 { margin: 0; font-size: 17px; }
.state p { margin: 0; color: var(--fg2); font-size: 13px; line-height: 1.5; }
.sk { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.sk i { display: block; height: 34px; border-radius: 9px; background: linear-gradient(90deg, var(--surface2) 25%, var(--sep2) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- планшет: rail всегда, панель поверх списка */
@media (min-width: 768px) and (max-width: 1279.98px) {
  .app .side { width: var(--rail-w); align-items: center; padding: 12px 0 10px; }
  .app .brand { padding: 2px 0 12px; justify-content: center; }
  .app .brand .bt, .app .nav .nm, .app .nav .cnt, .app .sec, .app .tree, .app .me .bt, .app .collapse { display: none; }
  .app .nav { width: 48px; min-height: 44px; justify-content: center; padding: 0; flex-direction: column; gap: 2px; }
  .app .nav .rl { display: block; font-size: 9.5px; font-weight: 600; }
  .app .nav .badge { position: absolute; top: 3px; right: 5px; min-width: 16px; height: 16px; font-size: 9.5px; }
  .app .me { width: auto; padding: 6px; }
  .app .nav.spaces-rail { display: flex; }
  .app.paneled .main { margin-right: 8px; }
  .pscrim { display: block; }
  .panel { position: absolute; right: 0; top: 0; bottom: 0; margin: 0; width: min(420px, 100%); min-width: 0; border-radius: 16px 0 0 16px; z-index: 40; box-shadow: 0 20px 60px var(--shadow); }
  .panel .resize { display: none; }
  .search { width: 40px; padding: 0; justify-content: center; }
  .search .lbl, .search .kbd { display: none; }
  .btn { height: 38px; }
}
@media (min-width: 1680px) { .panel { --panel-w: 560px; } }

/* ---------- телефон */
@media (max-width: 767.98px) {
  body { font-size: 15px; line-height: 1.4; background: var(--screen); }
  .app { background: var(--screen); }
  .side, .hdr-d { display: none; }
  .ground { display: block; position: absolute; inset: 0; z-index: 0; pointer-events: none; background:
    radial-gradient(40% 30% at 0% 0%, var(--blob1), transparent 70%),
    radial-gradient(45% 30% at 100% 25%, var(--blob2), transparent 70%),
    radial-gradient(50% 30% at 30% 100%, var(--blob3), transparent 70%), var(--screen); }
  .main { margin: 0; border-radius: 0; background: transparent; box-shadow: none; z-index: 1; }
  .scroll { padding: env(safe-area-inset-top, 0px) 0 calc(130px + env(safe-area-inset-bottom, 0px)); scrollbar-width: none; }
  .scroll::-webkit-scrollbar { display: none; }
  .body { padding: 0 16px 16px; }
  .hdr-m { display: flex; flex-direction: column; gap: 4px; padding: 14px 20px 10px; }
  .hdr-m .row1 { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
  .hdr-m .hdr-btns { display: flex; gap: 8px; margin-left: auto; }
  .hdr-m h2 { font-size: 34px; line-height: 1.1; margin: 0; font-weight: 700; letter-spacing: -.025em; }
  .hdr-m .sub { color: var(--fg2); font-size: 15px; }
  .circle-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--fg); }
  .circle-btn .av { width: 34px; height: 34px; font-size: 12px; }
  .compact { display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(26px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); align-items: center; justify-content: center; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; --gbg: var(--gbar); --gblur: var(--b2); }
  .compact.on { opacity: 1; pointer-events: auto; }
  .tabbar { display: flex; position: fixed; left: 14px; right: 70px; bottom: max(18px, env(safe-area-inset-bottom, 0px)); height: 46px; border-radius: 23px; align-items: center; justify-content: space-around; padding: 0 6px; z-index: 25; --gbg: var(--gclear); --gblur: 3px; --gsat: 140%; }
  .tab { position: relative; z-index: 1; flex: 1; height: 38px; border-radius: 19px; display: flex; align-items: center; justify-content: center; color: var(--fg2); transition: transform .15s, filter .15s; }
  .tab.on { color: var(--accent); }
  .tab svg { width: 25px; height: 25px; filter: drop-shadow(0 0 3px var(--screen)) drop-shadow(0 0 1px var(--screen)); }
  .tab .badge { position: absolute; top: -2px; left: calc(50% + 4px); min-width: 17px; height: 17px; font-size: 11px; }
  .tab-cat { display: block; width: 30px; height: 27px; background: var(--cat-front) center bottom / contain no-repeat; }
  .tab-logo { display: block; width: 26px; height: 26px; background: url("../img/brand/groi-mark.svg") center / contain no-repeat; }
  .tab:not(.on) .tab-cat, .tab:not(.on) .tab-logo { opacity: .85; }
  .tab-drop { position: absolute; left: 0; top: 4px; height: 38px; border-radius: 19px; z-index: 0; pointer-events: none; background: linear-gradient(180deg, var(--g-hi), rgba(255,255,255,0) 70%), var(--g-drop); box-shadow: inset 0 1px 0 var(--g-hi-line), inset 0 0 0 .5px var(--g-rim); transition: transform .42s cubic-bezier(.3,1.35,.5,1), width .3s; }
  .fab { display: grid; place-items: center; position: fixed; right: 14px; bottom: max(18px, env(safe-area-inset-bottom, 0px)); width: 46px; height: 46px; border-radius: 50%; z-index: 25; color: var(--accent); --gbg: var(--gclear); --gblur: 3px; --gsat: 140%; transition: transform .15s, filter .15s; }
  .fab svg { width: 25px; height: 25px; filter: drop-shadow(0 0 3px var(--screen)) drop-shadow(0 0 1px var(--screen)); }
  .fab:active, .tab:active, .circle-btn:active { transform: scale(.94); filter: var(--g-press); }
  /* панель на телефоне — полноэкранный лист */
  .panel { position: fixed; inset: 0; margin: 0; width: auto; min-width: 0; max-width: none; border-radius: 0; z-index: 41; background: var(--screen); }
  .panel .resize { display: none; }
  .state { margin: 50px auto; }
  .state h3 { font-size: 20px; }
  .state p { font-size: 15px; }
  .btn { height: 44px; border-radius: 22px; padding: 0 22px; font-size: 15px; }
}

/* ---------- стекло: один рецепт, без стекла внутри стекла */
.glass {
  background: linear-gradient(180deg, var(--g-hi), rgba(255,255,255,0) 55%), var(--gbg, var(--g2));
  -webkit-backdrop-filter: blur(var(--gblur, var(--b2))) saturate(var(--gsat));
  backdrop-filter: blur(var(--gblur, var(--b2))) saturate(var(--gsat));
  box-shadow: inset 0 1px 0 var(--g-hi-line), inset 0 0 0 .5px var(--g-rim), 0 0 0 .5px var(--g-outline), 0 8px 28px var(--glass-shadow);
}
.glass .glass { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--g-matte); box-shadow: inset 0 0 0 .5px var(--g-rim); }
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--surface); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- сегменты (виды, тема) */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface2); }
.seg button { height: 28px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--fg2); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px var(--shadow); }
@media (max-width: 767.98px) {
  .seg { display: flex; border-radius: 14px; padding: 3px; }
  .seg button { flex: 1; height: 34px; border-radius: 11px; font-size: 13px; }
}
.tab-cat-big { display: block; width: 96px; height: 86px; background: var(--cat-front) center bottom / contain no-repeat; }

/* ---------- витрина /kit */
.kit { display: grid; gap: 28px; max-width: 760px; }
.kit section { display: grid; gap: 10px; }
.kit h3 { margin: 0; font-size: 15px; }
.kit p { margin: 0; color: var(--fg2); }
.kit-row { display: flex; flex-wrap: wrap; gap: 8px; }
.kit-note { font-size: 12px; color: var(--green) !important; }
.kit-state { border: 1px dashed var(--sep); border-radius: 14px; }
