/* Верхняя панель: марка, переключатель работы, тема, профиль; ниже — вкладки.
   На телефоне вкладки уходят в нижнюю панель. */

.app { display: flex; flex-direction: column; min-height: 100dvh; }

.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4; }
.toprow, .tabs { display: flex; align-items: center; gap: 8px; max-width: 1100px; margin: 0 auto; padding: 0 var(--gut); }
.toprow { height: 56px; }
.tabs { height: 46px; border-top: 1px solid var(--line2); }

.brand { display: flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -.02em; margin-right: 6px; }
.brand .ic { color: var(--accent); }

.groupbtn {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px 7px 12px; border-radius: 9px;
  font-weight: 600; font-size: 14.5px; border: 1px solid var(--line); min-width: 0;
}
.groupbtn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.groupbtn .dot { flex: 0 0 auto; }
.groupbtn .ic { color: var(--dim); }
.groupbtn:hover { background: var(--press); }
.groupbtn[aria-expanded='true'] { background: var(--press); }
.groupbtn[aria-expanded='true'] .chev { transform: rotate(180deg); }
.groupbtn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transition: background .45s; }

.ibtn {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: var(--dim);
  border: 1px solid transparent;
}
.ibtn:hover { background: var(--press); color: var(--ink); }
.ibtn[aria-expanded='true'] { background: var(--press); color: var(--ink); border-color: var(--line); }
.ibtn.avatar { background: var(--accent); color: #fff; border-radius: 50%; width: 32px; height: 32px; font-weight: 700; font-size: 13px; }
/* буква без межстрочного запаса: иначе строка выше глифа, и он сидит заметно выше центра */
.ibtn.avatar span { display: block; line-height: 1; }
.ibtn.avatar:hover { filter: brightness(1.1); }
/* переключение темы: иконка проворачивается */
[data-act='theme'] .ic { transition: transform .45s var(--ease); }
[data-act='theme']:hover .ic { transform: rotate(-25deg); }
:root[data-theme='dark'] [data-act='theme'] .ic { transform: rotate(180deg); }
:root[data-theme='dark'] [data-act='theme']:hover .ic { transform: rotate(205deg); }

.tab {
  position: relative; display: flex; align-items: center; gap: 7px; height: 100%; padding: 0 4px; margin-right: 14px;
  font-size: 14.5px; color: var(--dim);
}
.tab:hover { color: var(--ink); }
.tab::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0;
  background: var(--accent); transform: scaleX(0); transition: transform .25s var(--ease);
}
.tab[aria-current='true'] { color: var(--ink); font-weight: 600; }
.tab[aria-current='true']::after { transform: scaleX(1); }

.addbtn {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px 8px 10px; border-radius: 9px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 14px;
}
.addbtn:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--ink) 30%, transparent); transform: translateY(-1px); }

/* ─── заголовок экрана ─── */
.pane { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; }
.head { padding: 26px var(--gut) 18px; display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.head h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 38px; line-height: .98; letter-spacing: -.035em; }
.eyebrow { font-size: 13px; color: var(--dim); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; padding-bottom: 4px; }
.stat {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); font-size: 13px; color: var(--dim);
}
.fresh .stat { animation: rise .32s var(--ease) both; }
.stat b { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -.02em; }
.stat[data-tone='waiting'] { border-color: color-mix(in srgb, var(--st-waiting) 40%, transparent); color: var(--st-waiting); }
.stat[data-tone='waiting'] b { color: var(--st-waiting); }
.stat[data-tone='active'] { border-color: color-mix(in srgb, var(--st-active) 40%, transparent); color: var(--st-active); }
.stat[data-tone='active'] b { color: var(--st-active); }
.stat .ic { width: 14px; height: 14px; }

/* ─── поиск ─── */
.search {
  display: flex; align-items: center; gap: 8px; flex: 1; max-width: 340px; margin-left: 6px;
  padding: 0 10px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg);
  color: var(--dim); transition: border-color .15s, box-shadow .15s, max-width .25s var(--ease);
}
.sbtn { display: none; }
.search:hover { border-color: var(--dim); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); max-width: 440px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 14px; color: var(--ink); appearance: none; -webkit-appearance: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search input::placeholder { color: var(--dim); }
.search .clear { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.search .clear:hover { background: var(--press); color: var(--ink); }
mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.row p .badge { padding: 2px 8px 2px 6px; font-size: 12px; }
.row p .badge .ic { width: 12px; height: 12px; }

/* ─── десктоп: вкладки в шапке, нижней панели нет ─── */
main { padding-bottom: 48px; }
nav { display: none; }
@media (min-width: 720px) { .head h1 { font-size: 44px; } }

/* ─── телефон ─────────────────────────────────────────────
   Шапка: логотип без слова, группа с обрезкой, справа — лупа и аватар.
   Тема прячется в меню профиля. Поиск раскрывается второй строкой под
   панелью (класс .searching ставит app.js) и сворачивается, когда строка
   пуста и поле потеряло фокус. Вкладки уходят в нижнюю панель. */
@media (max-width: 719px) {
  .toprow { height: auto; min-height: 56px; flex-wrap: wrap; gap: 6px; padding-block: 10px; }
  .brand { margin-right: 0; }
  .brand span { display: none; }
  .groupbtn { flex: 0 1 auto; padding: 7px 8px 7px 10px; }
  .toprow > .grow { flex: 1; }
  [data-act='theme'].ibtn { display: none; }
  .sbtn { display: grid; }
  .top.searching .sbtn { background: var(--press); color: var(--ink); }
  .search { display: none; flex: 1 0 100%; order: 10; max-width: none; margin: 4px 0 0; height: 40px; }
  .top.searching .search { display: flex; }
  .search:focus-within { max-width: none; }
  .tabs { display: none; }

  .head { padding: 18px var(--gut) 12px; gap: 12px; }
  .head h1 { font-size: 34px; }
  .stats { margin-left: 0; width: 100%; padding-bottom: 0; }
  .stat { padding: 5px 10px 5px 8px; font-size: 12.5px; }

  /* нижняя панель: две вкладки по краям, «новая задача» — квадрат посередине */
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
    padding: 6px var(--gut) calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--panel) 90%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 54px; border-radius: 12px; font-size: 11.5px; font-weight: 500; color: var(--dim); text-align: center;
  }
  nav button:active { background: var(--press); }
  nav button[aria-current='true'] { color: var(--accent); font-weight: 600; }
  nav .ic { width: 22px; height: 22px; }
  nav .add {
    width: 54px; height: 54px; border-radius: 16px; margin: 0;
    background: var(--ink); color: var(--bg); box-shadow: var(--pop);
  }
  nav .add .ic { width: 24px; height: 24px; }
  nav .add:active { transform: scale(.94); background: var(--ink); }
}

/* где живёт выбранная группа: устройство или сервер */
.groupbtn .kin { display: inline-flex; align-items: center; gap: 3px; vertical-align: -1px; overflow: visible; color: var(--dim); margin-left: 6px; font-size: 12.5px; }
.groupbtn .kin .ic { width: 13px; height: 13px; }
