/* Боковое меню — оверлей поверх графа, без отдельного полного слоя */
:root {
  --nav-role: #0d9b8a;
  --nav-role-deep: #087a6d;
  --nav-grade: #3aada0;
  --nav-kind: #7ec9bc;
  --nav-surface: #f3faf8;
  --nav-ink: #1a2428;
  --nav-muted: #3a5c56;
  --nav-border: rgba(13, 155, 138, 0.16);
  /* плотнее легенды — меню не должно просвечивать граф */
  --nav-panel-bg: rgba(255, 255, 255, 0.96);
  --nav-font: "Manrope", sans-serif;
  --nav-display: "Sora", sans-serif;
}

html[data-theme="dark"] {
  --nav-role: #2dd4bf;
  --nav-role-deep: #5eead4;
  --nav-grade: #2bbbad;
  --nav-kind: #5eead4;
  --nav-surface: #1a2c2a;
  --nav-ink: #e6f2ef;
  --nav-muted: #a8c5bf;
  --nav-border: rgba(45, 212, 191, 0.22);
  --nav-panel-bg: rgba(18, 28, 30, 0.96);
}

.app-nav-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1002;
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--nav-border);
  border-radius: 0.85rem;
  background: var(--nav-panel-bg);
  color: var(--nav-role-deep);
  cursor: pointer;
  box-shadow: none;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.app-nav-toggle:hover {
  background: var(--nav-surface);
  border-color: rgba(13, 155, 138, 0.28);
}

.app-nav-toggle.is-open,
.app-nav-toggle.is-open:hover {
  border-color: transparent;
  background: var(--nav-panel-bg);
  color: var(--nav-role);
  box-shadow: none;
}

.app-nav-toggle:focus-visible {
  outline: 2px solid var(--nav-kind);
  outline-offset: 2px;
}

.app-nav-toggle-icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  width: min(18.5rem, 86vw);
  padding: 4.75rem 1.25rem 1rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--nav-panel-bg);
  border-right: 1px solid var(--nav-border);
  left: -105%;
  transition: left 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.app-nav-panel.is-open {
  left: 0;
  pointer-events: auto;
}

.app-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.app-nav-link {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid transparent;
  font-family: var(--nav-font);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--nav-muted);
  text-decoration: none;
  background: transparent;
}

.app-nav-link:focus-visible {
  outline: 2px solid var(--nav-kind);
  outline-offset: 2px;
}

button.app-nav-link {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.app-nav-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.app-nav-chevron {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}

.app-nav-dropdown-toggle.is-open .app-nav-chevron {
  transform: rotate(180deg);
}

.app-nav-dropdown-panel {
  margin: 0.2rem 0 0.35rem;
  padding: 0.35rem;
  border-radius: 0.75rem;
  background: var(--nav-surface);
  border: 1px solid var(--nav-border);
}

.app-nav-dropdown-panel.is-graphs {
  container-type: inline-size;
  container-name: graphs-panel;
}

button.app-nav-link.is-soon {
  opacity: 0.55;
  cursor: default;
}

.app-nav-requests {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.app-nav-requests-empty {
  padding: 0.7rem 0.75rem;
  font-family: var(--nav-font);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  color: rgba(58, 92, 86, 0.75);
}

.app-nav-request-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  text-align: left;
  font-family: var(--nav-font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--nav-muted);
  cursor: pointer;
}

.app-nav-request-item.is-active {
  color: var(--nav-ink);
  background: rgba(13, 155, 138, 0.1);
}

.app-nav-graphs-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  /* 3 ряда кубиков: 3×сторона + 2×gap, сторона = (ширина − gap) / 2 */
  max-height: calc(3 * ((100cqw - 0.45rem) / 2) + 2 * 0.45rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.app-nav-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 11rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-nav-history-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  background: transparent;
  color: var(--nav-muted, #5a6b68);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.app-nav-history-item:hover {
  color: var(--nav-ink, #1a2428);
  background: rgba(13, 155, 138, 0.1);
}

.app-nav-history-empty {
  padding: 0.45rem 0.55rem;
  color: var(--nav-muted, #5a6b68);
  font-size: 0.82rem;
  line-height: 1.35;
}

.app-nav-graph-cell {
  position: relative;
  min-width: 0;
}

.app-nav-graph-tile-del {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  z-index: 2;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  background: rgba(180, 35, 24, 0.12);
  color: #b42318;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.app-nav-graph-tile-edit {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  z-index: 2;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  background: rgba(13, 155, 138, 0.12);
  color: var(--nav-role, #0d9b8a);
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.app-nav-graph-tile-fork {
  position: absolute;
  top: 0.2rem;
  left: 1.55rem;
  z-index: 2;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  background: rgba(13, 155, 138, 0.12);
  color: var(--nav-role, #0d9b8a);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.app-nav-graph-cell:hover .app-nav-graph-tile-del,
.app-nav-graph-cell:focus-within .app-nav-graph-tile-del,
.app-nav-graph-cell:hover .app-nav-graph-tile-edit,
.app-nav-graph-cell:focus-within .app-nav-graph-tile-edit,
.app-nav-graph-cell:hover .app-nav-graph-tile-fork,
.app-nav-graph-cell:focus-within .app-nav-graph-tile-fork {
  opacity: 1;
}

.app-nav-graph-tile-del:hover {
  background: rgba(180, 35, 24, 0.22);
}

.app-nav-graph-tile-edit:hover,
.app-nav-graph-tile-fork:hover {
  background: rgba(13, 155, 138, 0.22);
}

html[data-theme="dark"] .app-nav-graph-tile-del {
  background: rgba(249, 112, 102, 0.16);
  color: #f97066;
}

html[data-theme="dark"] .app-nav-graph-tile-edit,
html[data-theme="dark"] .app-nav-graph-tile-fork {
  background: rgba(45, 212, 191, 0.16);
  color: #5eead4;
}

.app-nav-graph-tile {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  aspect-ratio: 1;
  margin: 0;
  padding: 0.55rem 0.45rem;
  border: 1px solid rgba(13, 155, 138, 0.14);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.55);
  color: var(--nav-ink);
  font-family: var(--nav-font);
  text-decoration: none;
  cursor: pointer;
  cursor: pointer;
  text-align: center;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.app-nav-graph-tile:hover {
  background: rgba(13, 155, 138, 0.08);
  border-color: rgba(13, 155, 138, 0.28);
}

.app-nav-graph-tile.is-active {
  background: rgba(13, 155, 138, 0.14);
  border-color: rgba(13, 155, 138, 0.35);
}

.app-nav-graph-tile.is-create {
  color: var(--nav-role-deep);
  border-style: dashed;
  border-color: rgba(13, 155, 138, 0.35);
  background: transparent;
}

.app-nav-graph-tile.is-create:hover {
  background: rgba(13, 155, 138, 0.08);
}

.app-nav-graph-plus {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.app-nav-graph-tile-label {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}

html[data-theme="dark"] .app-nav-graph-tile {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(45, 212, 191, 0.22);
}

html[data-theme="dark"] .app-nav-graph-tile.is-active {
  background: rgba(45, 212, 191, 0.14);
  border-color: rgba(45, 212, 191, 0.4);
}

html[data-theme="dark"] .app-nav-graph-tile.is-create {
  background: transparent;
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--nav-role);
}

.app-nav-legal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.app-nav-legal-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  background: transparent;
  color: var(--nav-muted, #5a6b68);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.app-nav-legal-item:hover {
  color: var(--nav-ink, #1a2428);
  background: rgba(13, 155, 138, 0.1);
}

html[data-theme="dark"] .app-nav-legal-item:hover {
  color: var(--nav-ink, #e6f2ef);
  background: rgba(45, 212, 191, 0.12);
}

.app-nav-graph-tile.is-soon-tile {
  opacity: 0.72;
  cursor: default;
}

.app-nav-graph-tile.is-soon-tile:hover {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(13, 155, 138, 0.14);
}

html[data-theme="dark"] .app-nav-graph-tile.is-soon-tile:hover {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(45, 212, 191, 0.22);
}

.app-nav-footer {
  flex: 0 0 auto;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-left: -1.25rem;
  margin-right: -1.25rem;
  padding: 0.75rem 1.25rem 0.35rem;
}

.app-nav-dock {
  --dock-gap: 0.35rem;
  width: 100%;
  container-type: inline-size;
}

.app-nav-dock-grid {
  display: flex;
  flex-wrap: wrap-reverse;
  align-content: flex-start;
  gap: var(--dock-gap);
  width: 100%;
  /* до 4 рядов; высота только под занятые кубики */
  max-height: calc(
    4 * ((100cqw - 3 * var(--dock-gap)) / 4) + 3 * var(--dock-gap)
  );
  overflow: hidden;
}

.app-nav-dock-tile {
  box-sizing: border-box;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc((100% - 3 * var(--dock-gap)) / 4);
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(13, 155, 138, 0.14);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.55);
  color: var(--nav-role-deep);
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.app-nav-dock-tile:hover:not(:disabled) {
  background: rgba(13, 155, 138, 0.1);
  border-color: rgba(13, 155, 138, 0.3);
}

.app-nav-dock-tile:disabled {
  opacity: 0.55;
  cursor: default;
}

.app-nav-dock-tile.is-active {
  background: rgba(13, 155, 138, 0.14);
  border-color: rgba(13, 155, 138, 0.35);
}

html[data-theme="dark"] .app-nav-dock-tile {
  background: var(--nav-surface);
  border-color: rgba(45, 212, 191, 0.22);
  color: var(--nav-role);
}

html[data-theme="dark"] .app-nav-dock-tile:hover:not(:disabled) {
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.35);
}

html[data-theme="dark"] .app-nav-dock-tile.is-active {
  background: rgba(45, 212, 191, 0.16);
  border-color: rgba(45, 212, 191, 0.42);
}

.app-nav-dock-tile.is-theme .is-sun {
  display: none;
}

.app-nav-dock-tile.is-theme .is-moon {
  display: block;
}

html[data-theme="dark"] .app-nav-dock-tile.is-theme .is-sun {
  display: block;
}

html[data-theme="dark"] .app-nav-dock-tile.is-theme .is-moon {
  display: none;
}

.app-nav-dock-icon {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav-dock-tile.is-lang {
  font: 700 0.7rem/1 Manrope, sans-serif;
  letter-spacing: 0.06em;
  color: var(--nav-role-deep, #087a6d);
}

html[data-theme="dark"] .app-nav-dock-tile.is-lang {
  color: var(--nav-role, #2dd4bf);
}

.app-nav-dock-badge {
  position: absolute;
  /* inside the tile — dock grid uses overflow:hidden and would clip overhang */
  top: 0.12rem;
  right: 0.12rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #c2410c;
  color: #fff;
  font: 700 0.62rem/1.05rem Manrope, sans-serif;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}

.app-nav-dock-tile.has-unread {
  border-color: rgba(13, 155, 138, 0.45);
}

html[data-theme="dark"] .app-nav-dock-tile.has-unread {
  border-color: rgba(45, 212, 191, 0.45);
}

.notif-panel {
  position: fixed;
  inset: 0;
  z-index: 2400;
  display: grid;
  place-items: end start;
  padding: 1rem;
  background: rgba(8, 16, 20, 0.28);
}

.notif-panel[hidden] {
  display: none !important;
}

.notif-panel-card {
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(70vh, 32rem);
  display: flex;
  flex-direction: column;
  margin: 0 0 4.5rem 0.5rem;
  border-radius: 1rem;
  border: 1px solid rgba(13, 155, 138, 0.2);
  background: var(--panel-bg, #fff);
  box-shadow: 0 18px 48px rgba(8, 16, 20, 0.18);
  overflow: hidden;
}

html[data-theme="dark"] .notif-panel-card {
  background: #162422;
  border-color: rgba(45, 212, 191, 0.22);
}

.notif-panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(13, 155, 138, 0.14);
}

.notif-panel-head h2 {
  margin: 0;
  flex: 1;
  font: 700 0.95rem/1.2 Sora, Manrope, sans-serif;
  color: var(--ink, #1a2428);
}

html[data-theme="dark"] .notif-panel-head h2 {
  color: #e6f2ef;
}

.notif-panel-action {
  margin: 0;
  padding: 0.35rem 0.55rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--role, #0d9b8a);
  font: 600 0.75rem/1 Manrope, sans-serif;
  cursor: pointer;
}

.notif-panel-close {
  width: 1.8rem;
  height: 1.8rem;
  margin: 0;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--muted, #3a5c56);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.notif-panel-list {
  overflow: auto;
  padding: 0.35rem;
}

.notif-empty {
  margin: 1.25rem 0.75rem;
  color: var(--muted, #3a5c56);
  font: 500 0.88rem/1.4 Manrope, sans-serif;
  text-align: center;
}

.notif-item {
  display: grid;
  gap: 0.2rem;
  width: 100%;
  margin: 0 0 0.3rem;
  padding: 0.7rem 0.75rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.notif-item:hover {
  background: rgba(13, 155, 138, 0.1);
}

.notif-item.is-unread {
  background: rgba(13, 155, 138, 0.08);
}

.notif-item-title {
  font: 700 0.86rem/1.25 Manrope, sans-serif;
  color: var(--ink, #1a2428);
}

html[data-theme="dark"] .notif-item-title {
  color: #e6f2ef;
}

.notif-item-body {
  font: 500 0.8rem/1.35 Manrope, sans-serif;
  color: var(--muted, #3a5c56);
}

.notif-item-meta {
  font: 500 0.72rem/1.2 Manrope, sans-serif;
  color: var(--muted, #3a5c56);
  opacity: 0.85;
}

.app-nav-user-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
}

.app-nav-user-avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  color: var(--nav-role-deep);
}

.app-nav-footer-icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav-footer-email {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-family: var(--nav-font);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--nav-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-nav-icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--nav-muted);
  cursor: pointer;
}

.app-nav-icon-btn:hover {
  color: var(--nav-role-deep);
  background: rgba(13, 155, 138, 0.1);
}

.app-nav-icon-btn:focus-visible {
  outline: 2px solid var(--nav-kind);
  outline-offset: 2px;
}

.app-nav-verify-link {
  align-self: stretch;
  margin: 0;
  padding: 0.35rem 0.15rem 0.15rem;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: var(--nav-font);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--nav-role-deep);
  cursor: pointer;
}

.app-nav-auth-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
}

.app-nav-auth-row .app-nav-auth-btn {
  flex: 1 1 auto;
  width: auto;
  text-align: center;
  padding: 0.85rem 0.5rem;
  background: transparent;
  color: var(--nav-muted);
  border-color: transparent;
}
