/* Компоновка приложения. */

.app-shell {
  display: grid;
  isolation: isolate;
  /* minmax(0, 1fr) не даёт содержимому раздвинуть колонку и породить
     горизонтальный скролл всей страницы. */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar content";
  min-height: 100vh;
}

/* --- Sidebar -------------------------------------------------------------- */

.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(22, 31, 30, 0.96), rgba(15, 21, 21, 0.93));
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: calc(12px * var(--sidebar-scale)) calc(8px * var(--sidebar-scale));
  box-shadow: inset -1px 0 rgba(239, 223, 190, 0.05), 5px 0 18px #070b0b55;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

@supports not (backdrop-filter: blur(4px)) {
  .sidebar,
  .header,
  .panel,
  .drawer,
  .dialog {
    background: var(--panel-solid);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: calc(var(--s-2) * var(--sidebar-scale));
  padding: 0 calc(var(--s-2) * var(--sidebar-scale)) calc(var(--s-2) * var(--sidebar-scale));
}

.brand__mark {
  width: calc(24px * var(--sidebar-scale));
  height: calc(24px * var(--sidebar-scale));
  flex: none;
}

.brand__name {
  font-size: calc(var(--fs-lg) * var(--sidebar-scale));
  font-weight: 600;
}

.brand__note {
  font-size: calc(9px * var(--font-scale) * var(--sidebar-scale));
  color: var(--muted);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: calc(2px * var(--sidebar-scale));
}

.nav-group__title {
  font-size: calc(11px * var(--font-scale) * var(--sidebar-scale));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7d8785;
  padding: calc(var(--s-3) * var(--sidebar-scale)) calc(var(--s-2) * var(--sidebar-scale)) calc(var(--s-1) * var(--sidebar-scale));
}

.nav-link {
  display: flex;
  align-items: center;
  gap: calc(var(--s-2) * var(--sidebar-scale));
  padding: calc(4px * var(--sidebar-scale)) calc(7px * var(--sidebar-scale));
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: calc(var(--fs-sm) * var(--sidebar-scale));
  border: 1px solid transparent;
  min-height: calc(29px * var(--sidebar-scale));
}

.nav-link:hover {
  color: var(--text);
  background: rgba(225, 194, 133, 0.07);
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  color: var(--text);
  background: linear-gradient(110deg, rgba(201, 167, 99, 0.5), rgba(122, 103, 64, 0.27));
  border-color: rgba(226, 197, 139, 0.55);
  box-shadow: var(--shadow-control), var(--glow-active);
}

.nav-link__glyph {
  width: calc(16px * var(--sidebar-scale));
  text-align: center;
  color: var(--accent);
  flex: none;
}

.nav-link__count {
  margin-left: auto;
  font-size: calc(11px * var(--font-scale) * var(--sidebar-scale));
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: calc(1px * var(--sidebar-scale)) calc(7px * var(--sidebar-scale));
}

/* --- Header --------------------------------------------------------------- */

.header {
  grid-area: header;
  min-width: 0;
  overflow: visible;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border-soft);
  background: var(--sheen), rgba(22, 30, 30, 0.63);
  box-shadow: inset 0 -1px #dbcaa715, 0 3px 12px #070b0b55;
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header__views {
  display: flex;
  gap: var(--s-1);
  background: var(--surface-inset);
  box-shadow: var(--shadow-inset);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 2px;
  overflow-x: auto;
  flex: 0 1 auto;
  min-width: 0;
}

.header__spacer {
  flex: 1;
}

.view-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: var(--s-1) var(--s-3);
  border-radius: 999px;
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
  min-height: 30px;
}

.view-tab[aria-pressed="true"] {
  background: linear-gradient(180deg, #4f5f5b, #324443);
  color: var(--text);
  box-shadow: var(--shadow-control), inset 0 0 0 1px #ebd7af44;
}

.demo-mark {
  font-size: calc(11px * var(--font-scale));
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* --- Контент -------------------------------------------------------------- */

.content {
  grid-area: content;
  padding: var(--s-5);
  min-width: 0;
  max-width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}

.page-head__sub {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-top: var(--s-1);
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-w);
  gap: var(--s-5);
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}

.stack--tight {
  gap: var(--s-2);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.row--end {
  justify-content: flex-end;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-4);
}

.split-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-4);
}

/* --- Мобильное меню -------------------------------------------------------- */

.mobile-nav {
  display: none;
}

@media (max-width: 1180px) {
  :root {
    --rail-w: 268px;
  }
  .content {
    padding: var(--s-4);
  }
}

@media (max-width: 1024px) {
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "header"
      "content";
    padding-bottom: 68px;
  }
  .sidebar {
    display: none;
  }
  .header {
    padding: 0 var(--s-3);
    gap: var(--s-2);
    /* Шапка прокручивается по горизонтали, элементы не наезжают друг на друга. */
    overflow-x: auto;
  }
  .header > * {
    flex: 0 0 auto;
  }
  .header__spacer {
    display: none;
  }
  /* «Записать» доступно в нижнем меню. */
  .header-action--capture {
    display: none;
  }
  /* Метка демонстрации видна без прокрутки. */
  .demo-mark {
    order: -1;
  }
  .header__views {
    max-width: none;
  }
  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--sheen), rgba(21, 31, 30, 0.82);
    backdrop-filter: blur(16px);
    box-shadow: inset 0 1px #eddbb822, 0 -5px 16px #090f0f66;
    border-top: 1px solid var(--border-soft);
    padding: var(--s-1) var(--s-2) calc(var(--s-1) + env(safe-area-inset-bottom));
  }
  .mobile-nav a,
  .mobile-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    font-size: calc(11px * var(--font-scale));
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
  }
  .mobile-nav a[aria-current="page"] {
    color: var(--accent);
    text-decoration: none;
  }
  .content {
    padding: var(--s-3);
  }
  .page-head {
    margin-bottom: var(--s-4);
  }
}

/* Свечение марки и навигационные ориентиры. */
.brand__mark {
  display: grid;
  place-items: center;
  color: #f2e5ca;
  border: 1px solid #829c96;
  border-radius: 50%;
  box-shadow: 0 0 16px #cfae6d55, inset 0 0 10px #d4b57666;
}
.brand__mark .ui-icon {
  width: calc(21px * var(--sidebar-scale));
  height: calc(21px * var(--sidebar-scale));
}
.nav-group__title {
  font-size: calc(9px * var(--font-scale) * var(--sidebar-scale));
  letter-spacing: 0.12em;
  color: #9faaa7;
}
.nav-link__glyph {
  display: inline-flex;
  align-items: center;
}
.nav-link__glyph .ui-icon {
  width: calc(15px * var(--sidebar-scale));
  height: calc(15px * var(--sidebar-scale));
}
.sidebar-summary {
  border-top: 1px solid var(--border-soft);
  padding: calc(10px * var(--sidebar-scale)) calc(5px * var(--sidebar-scale)) 0;
}
.sidebar-summary .entity-row__meta {
  font-size: calc(var(--fs-xs) * var(--sidebar-scale));
}
.sidebar-summary .nav-group__title {
  padding: 0;
}
.header__views {
  border-radius: 7px;
}
.view-tab {
  border-radius: 5px;
  min-height: 24px;
}
.header {
  gap: 6px;
}
.demo-mark {
  font-size: calc(9px * var(--font-scale));
  padding: 3px 7px;
}
.page-head {
  margin-bottom: 9px;
}
.page-head__sub {
  font-size: calc(11px * var(--font-scale));
}
.page-head h1::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  margin-right: 7px;
  border-radius: 4px;
  background: linear-gradient(#e7ce9d, #e0c285);
  box-shadow: 0 0 12px #ddbb7688;
}
.content {
  position: relative;
}
.sidebar {
  z-index: 21;
}
.star-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}
.star {
  fill: #ddcdae;
  opacity: 0.25;
}
.star--bright {
  fill: #f2e4c9;
  opacity: 0.65;
}
.star-field__links {
  fill: none;
  stroke: #c6b289;
  stroke-width: 0.5;
  opacity: 0.12;
}
.today-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(230px, 1fr) minmax(240px, 1fr);
  gap: 10px;
  align-items: start;
}
@media (min-width: 1600px) {
  .today-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr) minmax(240px, 1fr);
  }
}
@media (min-width: 861px) and (max-width: 1200px) {
  .today-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(230px, 1fr);
  }
  .today-grid > .stack:last-child {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
@media (max-width: 860px) {
  .today-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(230px, 1fr);
  }
  .today-grid > .stack:last-child {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
@media (max-width: 600px) {
  .today-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .today-grid > .stack:last-child {
    display: flex;
  }
  .header .demo-mark {
    max-width: 94px;
    white-space: normal;
    line-height: 1.3;
  }
  .page-head__sub {
    font-size: calc(12px * var(--font-scale));
  }
}

@media (pointer: coarse) {
  :root { --header-h: 52px; }
}

/* Большие спокойные формы за стеклом: туманности, край планеты и орбитальные дуги.
   Фон не перехватывает ввод; отдельная непрозрачность текста не применяется. */
.ambient-backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 60% 40%, #30494738, transparent 70%),
    linear-gradient(145deg, #131c1c33, #080b0b55);
}
.ambient-backdrop__nebula {
  position: absolute;
  inset: -8%;
  background:
    radial-gradient(ellipse at 34% 38%, #947c4b4f, transparent 32%),
    radial-gradient(ellipse at 79% 28%, #c6a96e63, transparent 36%),
    radial-gradient(ellipse at 62% 78%, #5047944f, transparent 34%),
    radial-gradient(ellipse at 97% 90%, #957b4640, transparent 30%);
}
.ambient-backdrop__planet {
  position: absolute;
  top: -290px;
  right: -145px;
  width: 760px;
  height: 760px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 62%, #101b1a 38%, #35494853 65%, #e7cf9e44 75%, #546a6522 82%);
  border: 1px solid #eeddba33;
  box-shadow: -9px 12px 45px #d4b77e24, inset 3px -9px 24px #ebd6ad26;
  opacity: 0.65;
}
.ambient-backdrop__orbit {
  position: absolute;
  width: 1200px;
  height: 440px;
  border: 1px solid #d9c59e26;
  border-radius: 50%;
  transform: rotate(-28deg);
  box-shadow: 0 0 28px #cdab660a, inset 0 1px #f0e1c40d;
}
.ambient-backdrop__orbit--near {
  top: 30%;
  left: 14%;
}
.ambient-backdrop__orbit--far {
  top: 38%;
  left: 18%;
  width: 1500px;
  height: 580px;
  border-color: #cab79216;
}
.ambient-backdrop__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(#e9d3a806 1px, transparent 1px),
    linear-gradient(90deg, #e9d3a806 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 68% 60%, black, transparent 70%);
}
@media (max-width: 680px) {
  .ambient-backdrop__planet {
    width: 480px;
    height: 480px;
    right: -240px;
    top: -130px;
  }
}

/* Стеклянная панель быстрых действий; акцентная кнопка записи отделена
   от переключателей. Подписи показываются при hover и клавиатурном фокусе. */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  flex: none;
  border: 1px solid #dccaa530;
  border-radius: 12px;
  background: linear-gradient(155deg, #93a6a11c, #121b1b80);
  box-shadow: inset 0 1px #f1ece115, 0 3px 10px #080d0d44;
}
.header-action {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #c0ccc9;
  cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast),
    color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}
.header-action .ui-icon {
  width: 17px;
  height: 17px;
  stroke-width: 1.65;
}
.header-action:hover, .header-action:focus-visible {
  background: #d9c59e1f;
  color: #f8f5ef;
  border-color: #eddcb944;
  box-shadow: inset 0 1px #ede7db20;
}
.header-action--capture {
  color: #faf8f4;
  border-color: #e9d3a780;
  background: linear-gradient(145deg, #d9bc81, #bb9d62 42%, #9f8653);
  box-shadow: inset 0 1px #f6f3ec8c, inset 0 -1px #344e4d66,
    0 2px 5px #101b1b55, 0 0 12px #dfbf7f26;
}
.header-action--capture:hover, .header-action--capture:focus-visible {
  background: linear-gradient(145deg, #e6cc99, #cdaf74 42%, #b29760);
  border-color: #f1ece1;
  box-shadow: inset 0 1px #fff9, 0 0 14px #e3c79066;
}
.header-actions__divider {
  width: 1px;
  height: 16px;
  margin: 0 2px;
  background: linear-gradient(transparent, #d2c3a64d, transparent);
}
.header-action--quiet[aria-pressed="true"] {
  color: #d7c5ff;
  border-color: #ba9eff66;
  background: linear-gradient(145deg, #9776d345, #48357455);
  box-shadow: inset 0 1px #e6d8ff24, 0 0 12px #9870ff24;
}
.header-action--scenario[aria-expanded="true"] {
  color: #eddbb8;
  border-color: #e7cf9e66;
  background: #d1b57d26;
}
.header-action[aria-pressed="true"]::before,
.header-action[aria-expanded="true"]::before {
  content: "";
  position: absolute;
  right: 3px;
  top: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 5px currentColor;
}
.header-action::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 11px);
  right: 0;
  z-index: 25;
  white-space: nowrap;
  padding: 6px 9px;
  border: 1px solid #d8c49c55;
  border-radius: 7px;
  background: #1f2c2bf5;
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity var(--dur-fast), transform var(--dur-fast), visibility var(--dur-fast);
}
.header-action:hover::after, .header-action:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.header-action:active {
  transform: translateY(1px);
}
@media (pointer: coarse) {
  .header-action { width: 44px; height: 44px; }
  .header-actions { padding: 2px; gap: 2px; }
  .header-action::after { display: none; }
}
@media (max-width: 860px) {
  .header-actions { margin-right: 2px; }
  .header-action--capture { display: none; }
  .header-action::after { display: none; }
}
