/* Powłoka: górny pasek, menu boczne, obszar treści. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

a { color: var(--primary-ink); }

.navbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--navbar-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 0.85rem;
  isolation: isolate;
  overflow: visible;
  background: var(--nav-glass-veil);
  border-bottom: 1px solid var(--nav-glass-lead);
  backdrop-filter: saturate(140%) blur(12px);
}
.navbar__glass {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.navbar__pane { fill: var(--nav-glass-slate); }
.navbar__pane--sky { fill: var(--nav-glass-sky); }
.navbar__pane--deep { fill: var(--nav-glass-deep); }
.navbar__pane--moss { fill: var(--nav-glass-moss); }
.navbar__pane--amber { fill: var(--nav-glass-amber); }
.navbar__pane--rose { fill: var(--nav-glass-rose); }
.navbar__leads {
  fill: none;
  stroke: var(--nav-glass-lead);
  stroke-width: 1.2;
  stroke-linejoin: round;
}
.navbar__sheen {
  fill: color-mix(in srgb, #fff 14%, transparent);
}
.navbar > :not(.navbar__glass) { position: relative; z-index: 1; }
.navbar__spacer { flex: 1; }
.navbar__user { color: var(--ink-muted); font-size: 0.88rem; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.brand i { color: var(--primary-ink); }
.brand__accent { color: var(--primary); font-weight: 500; }

.theme-switch { position: relative; display: inline-flex; align-items: center; z-index: 2; }
.theme-switch[open] { z-index: 20; }
.theme-switch > summary {
  list-style: none;
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--nav-btn-border);
  cursor: pointer;
  color: var(--ink);
  background: transparent;
}
.theme-switch > summary::-webkit-details-marker { display: none; }
.theme-switch > summary:hover { color: var(--primary-ink); }
.theme-switch > summary:focus-visible,
.theme-menu button:focus-visible {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: var(--focus-offset);
}
.theme-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  min-width: 170px;
  padding: var(--space-1);
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  z-index: 1100;
}
.theme-menu button {
  width: 100%;
  display: flex; align-items: center; gap: 0.55rem;
  border: 0; background: transparent;
  color: var(--ink);
  font: inherit; font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.35rem;
  cursor: pointer; text-align: left;
}
.theme-menu button:hover { background: var(--sidebtn-hover); }
.theme-menu button[aria-pressed="true"] {
  background: var(--sidebtn-active);
  color: var(--primary-ink);
  font-weight: 600;
}

.sidebar {
  position: fixed;
  top: var(--navbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--navbar-h));
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--sidebar-pad);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  backdrop-filter: saturate(115%) blur(6px);
  transition: width 200ms ease;
  overflow: visible;
}
.sidebar__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: visible;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.sidebar__footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--sidebar-border);
  padding-top: var(--space-1);
}
.sidebar-group { position: relative; }

.sidebtn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 42px;
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.sidebtn__icon {
  flex: 0 0 1.25rem;
  width: 1.25rem;
  font-size: 1.15rem;
  text-align: center;
  color: var(--ink-muted);
}
.sidebtn:hover { background: var(--sidebtn-hover); }
/* obramowanie do środka — pasek boczny przycina wszystko, co wychodzi poza jego szerokość */
.sidebtn:focus-visible {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: calc(var(--focus-offset) * -1);
}
.sidebtn:hover .sidebtn__icon,
.sidebtn--active,
.sidebtn--active .sidebtn__icon {
  color: var(--primary-ink);
}
.sidebtn--active {
  background: var(--sidebtn-active);
  font-weight: 600;
}
.sidebtn__label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-chevron {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--ink-muted);
  transition: transform 200ms ease;
}
.sidebtn[aria-expanded="true"] .sidebar-chevron { transform: rotate(180deg); }

.sidebar-submenu {
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.15rem 0 0.35rem 0.35rem;
  margin-left: 0.85rem;
  border-left: 1px solid var(--sidebar-border);
}
.sidebar-submenu.show { display: flex; }
.sidebar-submenu .sidebtn {
  min-height: 36px;
  font-size: 0.85rem;
  font-weight: 450;
  padding-left: 0.75rem;
}
.sidebar-submenu .sidebtn__icon { font-size: 1rem; }

html[data-sidebar-expanded="0"] .sidebar .sidebtn {
  justify-content: center;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}
html[data-sidebar-expanded="0"] .sidebar .sidebtn__label,
html[data-sidebar-expanded="0"] .sidebar .sidebar-chevron {
  display: none;
}
/* obszar przewijania przycina wszystko, co wychodzi poza szerokość paska — przy zwiniętym
   pasku musi przestać, inaczej lista grupy otwiera się niewidoczna pod krawędzią */
html[data-sidebar-expanded="0"] .sidebar__scroll { overflow: visible; }

html[data-sidebar-expanded="0"] .sidebar .sidebar-submenu {
  display: none;
}
html[data-sidebar-expanded="0"] .sidebar .sidebar-submenu.show {
  display: flex;
  position: absolute;
  /* + wewnętrzny margines paska, inaczej lista wychodzi na jego krawędź zamiast obok niej */
  left: calc(100% + var(--sidebar-pad) + 0.45rem);
  top: 0;
  z-index: 1200;
  min-width: 220px;
  margin: 0;
  padding: 0.35rem;
  border: 1px solid var(--glass-border-strong);
  border-left: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
html[data-sidebar-expanded="0"] .sidebar .sidebar-submenu .sidebtn {
  justify-content: flex-start;
  padding: 0.45rem 0.65rem;
}
html[data-sidebar-expanded="0"] .sidebar .sidebar-submenu .sidebtn__label {
  display: block;
}

.canvas {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-height: 100vh;
  padding: calc(var(--navbar-h) + 1.75rem) 2rem 5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: margin-left 200ms ease, width 200ms ease;
}
.canvas > * {
  width: 100%;
  max-width: 1480px;
}

.toasts {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.65rem;
  width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toasts--inline {
  position: static;
  pointer-events: auto;
  width: min(22rem, 100%);
}
.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.35;
  pointer-events: auto;
  animation: toast-in 180ms ease-out;
}
.toast__icon { color: var(--primary-ink); font-size: 1.15rem; margin-top: 0.05rem; }
.toast__text { margin: 0; }
.toast__close {
  width: 1.6rem; height: 1.6rem;
  display: inline-grid; place-items: center;
  border: 0; background: transparent;
  color: var(--ink-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.1rem;
}
.toast__close:hover { color: var(--ink); background: var(--sidebtn-hover); }
.toast--success { border-left: 3px solid var(--success); }
.toast--success .toast__icon { color: var(--success); }
.toast--warn { border-left: 3px solid var(--warn); }
.toast--warn .toast__icon { color: var(--warn); }
.toast--danger { border-left: 3px solid var(--danger); }
.toast--danger .toast__icon { color: var(--danger); }
.toast--info { border-left: 3px solid var(--primary); }
.toast--out { animation: toast-out 160ms ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(0.75rem); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(0.75rem); }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .canvas {
    margin-left: 0;
    width: 100%;
    padding: calc(var(--navbar-h) + 1rem) 1rem 3rem;
  }
  .brand__accent { display: none; }
}
