:root {
  --amuz-red: #e63946;
  --amuz-red-dark: #c1121f;
  --ink: #3a3a3c;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --shadow-sm:
    0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --radius-md: 16px;
  --radius-lg: 20px;
  --font-main: "Plus Jakarta Sans", sans-serif;

  /* Płynny układ: strona i kafelki rosną razem z ekranem (do 2000 px szerokości). */
  --page-max: 2000px;
  --gutter: clamp(16px, 3vw, 56px);
  --gap: clamp(12px, 1vw, 22px);
  /* Na komputerze wiersze dzielą między siebie wysokość okna (panel bez przewijania).
     Poniżej tej wysokości wiersza strona zaczyna się przewijać. */
  --row-min: 100px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  font-family: var(--font-main);
  color: var(--ink);
  background-color: var(--bg);
  min-height: 100%;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ---------- Panel na pełną wysokość okna ---------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Topbar (jak w Planie zajęć) ---------- */
.topbar {
  flex: none;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-title {
  font-size: clamp(17px, 1vw, 20px);
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  height: clamp(34px, 2vw, 42px);
  width: auto;
  display: block;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ---------- Skróty (M365 i usługi uczelni) ---------- */
.shortcuts {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.shortcut:hover {
  border-color: var(--amuz-red);
  color: var(--amuz-red);
  background: var(--card);
}
.shortcut:focus-visible {
  outline: 3px solid var(--amuz-red);
  outline-offset: 2px;
}
.shortcut-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}
/* Węższe ekrany: same ikony, nazwa w podpowiedzi (title). */
@media (max-width: 1499px) {
  .shortcut {
    padding: 8px;
  }
  .shortcut span {
    display: none;
  }
}
.user-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
}
.user-name {
  font-weight: 700;
  font-size: 14px;
}
.user-mail {
  font-size: 12px;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-ghost {
  background: var(--bg);
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover {
  border-color: var(--amuz-red);
  color: var(--amuz-red);
  background: var(--card);
}

/* ---------- Układ ---------- */
.wrap {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: clamp(16px, 1.5vw, 32px) var(--gutter) clamp(10px, 1vw, 20px);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ---------- Bento ---------- */
.bento {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(var(--row-min), 1fr);
  grid-auto-flow: row dense;
  gap: var(--gap);
}

/* Każdy kafelek jest kontenerem — opis pokazuje się tylko,
   gdy kafelek ma na niego miejsce (reguły @container niżej). */
.bento .card {
  container-type: size;
}

.card {
  --c: #3a3a3c;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(18px, 1.4vw, 30px);
  border-radius: var(--radius-lg);
  background: var(--c);
  color: #fff;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 30px -14px var(--c);
}
.card:focus-visible {
  outline: 3px solid var(--amuz-red);
  outline-offset: 3px;
}
.card.xl {
  grid-column: span 2;
  grid-row: span 2;
  padding: clamp(24px, 2vw, 44px);
}
.card.wide {
  grid-column: span 2;
}

/* Duża, blada ikona w tle — rozróżnia kafelki kątem oka */
.card-bg {
  position: absolute;
  right: -6%;
  bottom: -12%;
  width: clamp(120px, 8.5vw, 200px);
  height: clamp(120px, 8.5vw, 200px);
  opacity: 0.16;
  stroke-width: 1.6;
  pointer-events: none;
}
.card.xl .card-bg {
  width: clamp(240px, 17vw, 420px);
  height: clamp(240px, 17vw, 420px);
  right: -5%;
  bottom: -10%;
  stroke-width: 1.3;
}
.card-icon {
  width: clamp(26px, 1.8vw, 38px);
  height: clamp(26px, 1.8vw, 38px);
  flex: 0 0 auto;
}
.card.xl .card-icon {
  width: clamp(38px, 2.6vw, 60px);
  height: clamp(38px, 2.6vw, 60px);
}

.card-badge {
  position: absolute;
  top: clamp(14px, 1.2vw, 26px);
  right: clamp(14px, 1.2vw, 26px);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: clamp(11px, 0.75vw, 14px);
  font-weight: 600;
}
.card.xl .card-badge {
  top: clamp(22px, 1.8vw, 40px);
  right: clamp(22px, 1.8vw, 40px);
}

.card-text {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-name {
  font-size: clamp(16px, 1.15vw, 23px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.card.wide .card-name {
  font-size: clamp(20px, 1.5vw, 30px);
  font-weight: 800;
}
.card.xl .card-name {
  font-size: clamp(30px, 2.6vw, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.card-desc {
  font-size: clamp(13px, 0.85vw, 16px);
  line-height: 1.4;
  opacity: 0.88;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card.xl .card-desc {
  font-size: clamp(14px, 1vw, 20px);
}

/* Opis tylko tam, gdzie kafelek ma na niego miejsce;
   w pozostałych przypadkach zostaje podpowiedź po najechaniu (atrybut title).
   Progi dotyczą wnętrza kafelka (bez paddingu). */
.bento .card:not(.xl):not(.wide) .card-desc {
  display: none;
}
@container (min-height: 120px) and (min-width: 220px) {
  .bento .card:not(.xl):not(.wide) .card-desc {
    display: -webkit-box;
  }
}
@container (max-height: 95px) {
  .bento .card.wide .card-desc {
    display: none;
  }
}

/* Kafelek „wkrótce” — bez koloru, nieaktywny */
.card.soon {
  background: var(--card);
  color: var(--muted);
  border: 2px dashed var(--line);
  cursor: default;
}
.card.soon:hover {
  transform: none;
  box-shadow: none;
}
.card.soon .card-name {
  color: var(--ink-soft);
}
.card.soon .card-badge {
  background: var(--bg);
  color: var(--muted);
}

/* ---------- Footer: podpis + gra aMuz Run z Moniuszką ---------- */
.foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}
.game {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: none;
}
.game strong {
  color: var(--amuz-red);
  font-weight: 700;
}
.game img {
  display: block;
  height: 36px;
  width: auto;
  transform-origin: 50% 90%;
  transition: transform 0.25s ease;
}
.game:hover img,
.game:focus-visible img {
  transform: translateY(-4px) rotate(-8deg);
}
.game:hover span {
  text-decoration: underline;
}
.game:focus-visible {
  outline: 3px solid var(--amuz-red);
  outline-offset: 3px;
  border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
  .game img {
    transition: none;
  }
}

/* ---------- Gate (loading / denied) ---------- */
.gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}
.gate-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 40px 44px;
  max-width: 440px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.gate-card img {
  height: 44px;
}
.gate-card h3 {
  font-size: 20px;
  font-weight: 800;
}
.gate-card p {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--amuz-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.gate-icon-deny {
  color: var(--amuz-red);
}
.hidden {
  display: none !important;
}

/* ---------- Baner nowej wersji ---------- */
.version-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--amuz-red);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.version-banner button {
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: #fff;
  color: var(--amuz-red);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- Tablety i telefony ---------- */
/* Telefon i tablet: zwykła przewijana strona ze stałą wysokością kafelków. */
@media (max-width: 860px) {
  #app {
    height: auto;
  }
  .bento {
    flex: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 132px;
  }
  .wrap {
    padding-bottom: 32px;
  }
  /* Skróty jako osobny, przewijany w bok rząd pod nagłówkiem — z nazwami. */
  .topbar-inner {
    flex-wrap: wrap;
  }
  .shortcuts {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .shortcuts::-webkit-scrollbar {
    display: none;
  }
  .shortcut {
    padding: 7px 12px;
  }
  .shortcut span {
    display: inline;
  }
  .card.xl .card-name {
    font-size: 28px;
  }
  .card.wide .card-name {
    font-size: 19px;
  }
}

@media (max-width: 560px) {
  .bento {
    grid-auto-rows: 118px;
  }
  .topbar-inner {
    padding: 10px 16px;
  }
  .user-box {
    display: none;
  }
  .brand-title {
    font-size: 15px;
    gap: 10px;
  }
  .brand-logo {
    height: 28px;
  }
  .card {
    padding: 14px 16px;
  }
  .card.xl {
    padding: 20px;
  }
  .card-name {
    font-size: 15px;
  }
  .card-badge {
    top: 12px;
    right: 12px;
    font-size: 11px;
    padding: 2px 8px;
  }
  .card.xl .card-badge {
    top: 18px;
    right: 18px;
  }
  .foot {
    flex-direction: column-reverse;
    gap: 10px;
    padding-top: 4px;
  }
}
