/* ===== Motyw: domyślnie jasny (biały), akcent Librus (magenta/pink) ===== */
:root {
  /* JASNY (domyślny) */
  --bg: #f5f6f8;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e7e9ee;
  --border: #e5e7eb;
  --border-2: #d7dae0;

  --text: #14151a;
  --text-dim: #3a3d46;
  --text-muted: #6b7080;
  --text-faint: #9aa0ad;

  --accent: #e0218a;
  --accent-2: #c01a76;
  --accent-3: #e0218a;
  --accent-hover: #c01a76;
  --accent-soft: rgba(224, 33, 138, 0.10);
  --grad: linear-gradient(135deg, #ff5aa8 0%, #e0218a 60%, #a8136a 100%);

  --green: #18a558;
  --amber: #c2870a;
  --red: #e23b3b;
  --blue: #3b6fe0;
  --purple: #8b53e0;

  --bar-bg: rgba(255, 255, 255, 0.85);
  --card-shadow: 0 10px 40px rgba(20, 21, 26, 0.08);
  --theme-color: #ffffff;

  --radius: 14px;
  --radius-sm: 10px;
}

/* CIEMNY (Linear-vibe) */
html[data-theme="dark"] {
  --bg: #0a0a0c;
  --bg-2: #0f0f12;
  --surface: #141418;
  --surface-2: #1a1a20;
  --surface-3: #20202a;
  --border: #232329;
  --border-2: #2e2e36;

  --text: #f5f6f8;
  --text-dim: #c5c7cf;
  --text-muted: #8a8d99;
  --text-faint: #5c5f6b;

  --accent-2: #ff5aa8;
  --accent-3: #ff8ec6;
  --accent-hover: #f23d9d;
  --accent-soft: rgba(224, 33, 138, 0.14);

  --green: #3ecf8e;
  --amber: #f5b545;
  --red: #ff5f57;
  --blue: #5b8cff;
  --purple: #b07bff;

  --bar-bg: rgba(15, 15, 18, 0.92);
  --card-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  --theme-color: #0a0a0c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ===== Logowanie ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 500px at 50% -10%, rgba(224, 33, 138, 0.12), transparent 70%), var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--card-shadow);
}
.login-logo {
  width: 60px; height: 60px; display: block; border-radius: 16px;
  align-self: center; margin-bottom: 10px;
  box-shadow: 0 8px 24px rgba(224, 33, 138, 0.4);
}
.login-card h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 6px; }
.error { color: var(--red); font-size: 0.85rem; min-height: 1.1em; margin: 4px 0 0; }
input {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button.primary, #login-btn {
  background: var(--grad);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 650;
  margin-top: 4px;
  transition: transform 0.1s, filter 0.15s;
}
#login-btn:active { transform: translateY(1px); }
#login-btn:disabled { opacity: 0.6; }

/* ===== Layout aplikacji ===== */
.app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: 76px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--bar-bg);
  backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.topbar-l { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.topbar-actions { flex-shrink: 0; }
.topbar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
@media (max-width: 400px) { .icon-btn { width: 34px; height: 34px; } .topbar-actions { gap: 6px; } }
.brand-dot {
  width: 36px; height: 36px; border-radius: 10px; display: block;
  box-shadow: 0 4px 14px rgba(224, 33, 138, 0.35);
}
.topbar-title { font-weight: 700; font-size: 1.05rem; line-height: 1.15; letter-spacing: -0.01em; }
.topbar-sub { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim); width: 38px; height: 38px; border-radius: 10px;
  font-size: 1.05rem; display: grid; place-items: center;
}
.theme-toggle-float { position: fixed; top: 16px; right: 16px; z-index: 5; }

/* ===== Tutorial / onboarding ===== */
.tutorial { position: fixed; inset: 0; z-index: 1000; }
.tut-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.bottom-nav.tut-active { z-index: 1002; }
.nav-btn.tut-spotlight { color: var(--accent-2); }
.nav-btn.tut-spotlight::after {
  content: ""; position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 42px; height: 42px; border-radius: 12px;
  box-shadow: 0 0 0 2px var(--accent), 0 0 18px var(--accent);
  animation: tutpulse 1.3s ease-in-out infinite; pointer-events: none;
}
@keyframes tutpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.tut-card {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 1003; width: calc(100% - 32px); max-width: 380px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 18px; padding: 22px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.tut-card.anchored {
  left: 14px; right: 14px; top: auto; bottom: 94px; width: auto; max-width: none; transform: none;
}
.tut-card.focus-anchored {
  left: 14px; right: 14px; width: auto; max-width: none; transform: none;
}
/* Spotlight: podświetlona sekcja JASNA, reszta przyciemniona dziurawym box-shadow.
   W trybie focus chowamy pełnoekranową nakładkę — dim robi sam box-shadow elementu. */
#tutorial.focus-mode .tut-backdrop { display: none; }
/* W trybie focus podnosimy całą warstwę tutoriala (kartę) NAD spotlight elementu. */
#tutorial.focus-mode { z-index: 1002; }
.tut-focus {
  position: relative; z-index: 1001;
  border-radius: 16px;
  box-shadow:
    0 0 0 18px var(--bg),               /* jasny margines wokół (kolor tła) */
    0 0 0 21px var(--accent),           /* obwódka akcent */
    0 0 0 9999px rgba(0, 0, 0, 0.55);   /* przyciemnienie reszty */
}
.tut-card.anchored::after {
  content: ""; position: absolute; bottom: -9px; left: var(--arrow-x, 50%);
  transform: translateX(-50%); width: 0; height: 0;
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 9px solid var(--surface);
}
.tut-step { font-size: 0.72rem; color: var(--accent-2); font-weight: 700; letter-spacing: 0.05em; }
.tut-card h3 { margin: 6px 0 8px; font-size: 1.15rem; letter-spacing: -0.01em; }
.tut-card p { margin: 0; color: var(--text-dim); font-size: 0.92rem; line-height: 1.5; }
.tut-hint { margin-top: 12px; padding: 9px 12px; background: var(--accent-soft); border: 1px solid rgba(224, 33, 138, 0.3); border-radius: 9px; color: var(--accent-2); font-size: 0.85rem; font-weight: 650; text-align: center; }
.tut-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; }
.tut-skip { background: none; border: none; color: var(--text-muted); font-size: 0.88rem; font-weight: 600; padding: 8px; }
.tut-next { background: var(--grad); color: #fff; border: none; padding: 10px 22px; border-radius: 10px; font-size: 0.92rem; font-weight: 650; }

/* Ikony Lucide */
.lucide { width: 18px; height: 18px; vertical-align: middle; stroke-width: 2; }
.nav-arrow .lucide { width: 20px; height: 20px; }
.lucky-badge .lucide { width: 15px; height: 15px; }
.icon-btn .lucide { width: 18px; height: 18px; }
.view { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* ===== Karty ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.card-h h2 { margin: 0; font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; }
.card-h .muted { font-size: 0.8rem; color: var(--text-muted); }
.section-label { font-size: 0.78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.muted { color: var(--text-muted); }
.center-msg { text-align: center; color: var(--text-muted); padding: 40px 0; }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--border-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Splash / ekran ładowania ===== */
.splash {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(1000px 500px at 50% 30%, rgba(224, 33, 138, 0.12), transparent 70%), var(--bg);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-logo { width: 76px; height: 76px; border-radius: 20px; box-shadow: 0 14px 40px rgba(224, 33, 138, 0.45); animation: splashLogo 1.4s ease-in-out infinite; }
.splash-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.splash-bar { width: 150px; height: 5px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: var(--grad); border-radius: 4px; animation: aiBar 1.1s ease-in-out infinite; }
@keyframes splashLogo { 0%, 100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.06) translateY(-3px); } }

/* Loader zakładki */
.tab-loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 60px 0; }
.tab-loader-logo { width: 52px; height: 52px; border-radius: 14px; animation: splashLogo 1.2s ease-in-out infinite; }
.loader-bar { width: 120px; height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 40%; background: var(--grad); border-radius: 4px; animation: aiBar 1s ease-in-out infinite; }

/* Baner: wkrótce mobilna */
.mobile-soon { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text-muted); font-size: 0.82rem; padding: 8px 12px; margin-top: 4px; }
.mobile-soon .lucide { width: 16px; height: 16px; color: var(--accent-2); }
.app-footer { text-align: center; font-size: 0.74rem; color: var(--text-faint); line-height: 1.5; padding: 4px 0 8px; }
.app-footer a { color: var(--accent-2); text-decoration: none; font-weight: 600; }
.app-footer .muted { color: var(--text-faint); }

/* ===== Lekcje / plan ===== */
.lesson { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.lesson:first-child { border-top: none; }
.lesson-time { font-variant-numeric: tabular-nums; font-size: 0.82rem; color: var(--text-muted); min-width: 46px; padding-top: 1px; }
.lesson-body { flex: 1; }
.lesson-name { font-weight: 550; font-size: 0.95rem; }
.lesson-sub { font-size: 0.78rem; color: var(--text-muted); }
.tag { display: inline-block; font-size: 0.66rem; font-weight: 700; padding: 2px 6px; border-radius: 5px; vertical-align: middle; margin-left: 6px; letter-spacing: 0.03em; }
.tag-cancel { background: rgba(255, 95, 87, 0.18); color: #ff8b85; }
.tag-sub { background: rgba(245, 181, 69, 0.18); color: var(--amber); }
.tag-now { background: var(--accent); color: #fff; }
.tag-next { background: var(--surface-3); color: var(--text-muted); }
.lesson-now { background: var(--accent-soft); border-radius: 10px; margin: 4px -8px; padding: 9px 8px; border-top: none; }
.lesson-now + .lesson { border-top: none; }

/* ===== Oceny ===== */
.subject-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; }
.subject-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.subject-name { font-weight: 600; font-size: 0.95rem; }
.subject-avg { font-size: 0.85rem; font-weight: 700; }
.grades-row { display: flex; flex-wrap: wrap; gap: 7px; }
.grade {
  min-width: 32px; height: 32px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--surface-2);
  border: 1px solid var(--border-2); font-weight: 750; font-size: 0.9rem;
}
.grade.g-hi { color: var(--green); border-color: rgba(62, 207, 142, 0.4); }
.grade.g-mid { color: var(--amber); border-color: rgba(245, 181, 69, 0.4); }
.grade.g-lo { color: var(--red); border-color: rgba(255, 95, 87, 0.4); }

/* ===== Frekwencja ===== */
.freq-hero { display: flex; align-items: center; gap: 18px; }
.freq-ring {
  --p: 0;
  width: 108px; height: 108px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center;
  position: relative;
}
.freq-ring::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--surface); }
.freq-ring b { position: relative; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.freq-stats { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; }
.freq-stats .row { display: flex; justify-content: space-between; gap: 18px; }
.freq-stats .row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px; text-align: center; }
.stat-box b { display: block; font-size: 1.3rem; font-weight: 800; }
.stat-box span { font-size: 0.72rem; color: var(--text-muted); }

/* Kalkulator */
.calc-result { background: var(--accent-soft); border: 1px solid rgba(224,33,138,0.3); border-radius: var(--radius-sm); padding: 13px 14px; font-size: 0.92rem; line-height: 1.4; }
.calc-result b { color: var(--accent-2); font-size: 1.05rem; }
.slider-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 12px; }
input[type="range"] { flex: 1; accent-color: var(--accent); }
.calc-target { font-weight: 800; font-size: 1.1rem; min-width: 52px; text-align: right; }
.calc-foot { font-size: 0.74rem; margin: 10px 0 0; }
.calc-warn { margin-top: 8px; color: var(--amber); font-size: 0.85rem; font-weight: 600; }

/* Presety kalkulatora */
.calc-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.preset { flex: 1; min-width: 70px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); border-radius: 9px; padding: 8px 6px; font-size: 0.8rem; font-weight: 650; }
.preset.hot { border-color: rgba(224, 33, 138, 0.4); color: var(--accent-2); }
.preset.active { background: var(--accent); color: #fff; border-color: transparent; }

/* Znaczek AI */
.ai-badge { display: inline-flex; align-items: center; gap: 3px; background: var(--grad); color: #fff; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 20px; margin-left: 8px; vertical-align: middle; }
.ai-badge .lucide { width: 11px; height: 11px; }

/* Przewidywana ocena przy średniej */
.pred { font-size: 0.78rem; font-weight: 600; opacity: 0.85; }

/* Kalkulator ocen (per przedmiot) */
.gc-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--accent-2); font-size: 0.8rem; font-weight: 650; padding: 8px 0 2px; }
.gc-toggle .lucide { width: 15px; height: 15px; }
.gc-toggle.open .lucide { transform: rotate(0); }
.grade-calc { margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--border-2); animation: fadeSlide 0.25s ease; }
.gc-head { display: flex; align-items: center; margin-bottom: 10px; }
.gc-head b { font-size: 0.9rem; }
.gc-controls label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.gc-controls select { flex: 1; }
.gc-out { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.gc-line { font-size: 0.88rem; }
.gc-line b { color: var(--accent-2); }
.gc-sub { font-size: 0.78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-top: 4px; }
.gc-scn { font-size: 0.88rem; background: var(--surface-2); border-radius: 8px; padding: 7px 10px; }
.gc-ok { display: flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; font-size: 0.88rem; }
.gc-ok .lucide, .gc-improve .lucide { width: 16px; height: 16px; flex-shrink: 0; }
.gc-warn { color: var(--amber); font-size: 0.86rem; font-weight: 600; }
.gc-improve { display: flex; gap: 6px; align-items: flex-start; background: var(--accent-soft); border-radius: 9px; padding: 9px 11px; font-size: 0.85rem; line-height: 1.4; }
.gc-improve .lucide { color: var(--accent-2); }

/* Frekwencja per przedmiot */
.att-subj-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-2); color: var(--accent-2); border-radius: var(--radius); padding: 14px; font-weight: 650; font-size: 0.9rem; }
.att-subj-btn > .lucide { width: 17px; height: 17px; }
.att-subj-wrap { display: flex; flex-direction: column; gap: 8px; }
.att-subj-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.att-subj-top { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.att-subj-top > .lucide { margin-left: auto; width: 18px; height: 18px; color: var(--text-faint); transition: transform 0.2s ease; }
.att-subj-top.open > .lucide { transform: rotate(180deg); }
.att-mini-ring { --p: 0; --c: var(--accent); width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); display: grid; place-items: center; position: relative; }
.att-mini-ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.att-mini-ring b { position: relative; font-size: 0.78rem; font-weight: 800; }
.att-subj-name { font-weight: 600; font-size: 0.92rem; }
.att-subj-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.att-calc { padding: 2px 14px 14px; animation: fadeSlide 0.25s ease; }

/* ===== Animacje ===== */
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.9); opacity: 0; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }

/* Wejścia bloków przy renderze */
.card, .subject-card, .tt-day, .stat-grid { animation: fadeSlide 0.26s ease both; }
.lucky-badge { animation: pop 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }
.event, .notice, .type-row { animation: fadeIn 0.3s ease both; }

/* Dotyk / interakcja */
.nav-btn:active { transform: scale(0.9); }
.preset:active, .segment button:active, .tt-chip:active, .nav-arrow:active,
#login-btn:active, .primary:active, .add-task-btn:active, .gc-toggle:active { transform: scale(0.96); }
.grade { transition: transform 0.12s ease; }
.grade:active { transform: scale(1.18); }
.chat-send:active { transform: scale(0.92); }
.subject-card, .msg-teacher, .tt-day, .cal-cell { transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease; }
.cal-cell:active { transform: scale(0.94); }
@media (hover: hover) {
  .subject-card:hover { transform: translateY(-1px); }
  .nav-btn:hover { color: var(--text-muted); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.type-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 0.88rem; }
.type-row:first-child { border-top: none; }
.type-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.type-row .cnt { margin-left: auto; font-weight: 700; }

/* ===== Kalendarz ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head b { font-size: 1.05rem; text-transform: capitalize; }
.nav-arrow { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px; border-radius: 9px; font-size: 1.1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.cal-dow { text-align: center; font-size: 0.68rem; color: var(--text-faint); font-weight: 600; padding-bottom: 2px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 8px; background: var(--surface-2);
  border: 1px solid transparent; padding: 4px; display: flex; flex-direction: column;
  font-size: 0.76rem; overflow: hidden; cursor: pointer;
}
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.sel { background: var(--accent-soft); border-color: var(--accent); }
.cal-cell .dnum { color: var(--text-dim); font-weight: 600; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: auto; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: 0.74rem; color: var(--text-muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.event {
  display: flex; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border);
}
.event:first-child { border-top: none; }
.event-bar { width: 3px; border-radius: 3px; flex-shrink: 0; }
.event-body { flex: 1; min-width: 0; }
.event-title { font-weight: 600; font-size: 0.9rem; }
.event-meta { font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }
.event-detail { font-size: 0.82rem; color: var(--text-dim); margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.chip { display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.event-done { text-decoration: line-through; opacity: 0.55; }
.ev-del { background: none; border: none; color: var(--text-faint); padding: 4px; align-self: center; cursor: pointer; flex-shrink: 0; }
.ev-del .lucide { width: 16px; height: 16px; }
.ev-del:hover { color: var(--red); }
.prio-high { color: var(--red); font-weight: 700; }
.cal-hint { font-size: 0.74rem; margin: 10px 0 0; text-align: center; }
.add-task-btn { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); color: var(--accent-2); border: 1px solid rgba(224, 33, 138, 0.25); border-radius: 9px; padding: 6px 11px; font-size: 0.82rem; font-weight: 650; }
.add-task-btn .lucide { width: 15px; height: 15px; }

/* ===== Modal (zadania) ===== */
.modal { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.modal-card {
  position: relative; z-index: 1; width: 100%; max-width: 480px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 20px 20px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto; animation: sheetUp 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@media (min-width: 520px) { .modal { align-items: center; } .modal-card { border-radius: 18px; } }
.modal-card h3 { margin: 0 0 14px; font-size: 1.15rem; }
.modal-card > input, .modal-card > textarea { width: 100%; margin-bottom: 10px; }
.modal-row { display: flex; gap: 10px; margin-bottom: 10px; }
.modal-row label { flex: 1; display: flex; flex-direction: column; gap: 5px; font-size: 0.76rem; color: var(--text-muted); font-weight: 600; }
.modal-row input, .modal-row select { width: 100%; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .primary { flex: 1; }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); padding: 12px 18px; border-radius: 10px; font-weight: 600; }
select { background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text); padding: 11px 12px; border-radius: var(--radius-sm); font-size: 0.95rem; outline: none; }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ===== Obliczanie Średniej AI ===== */
.ai-calc-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(135deg, var(--surface), var(--surface-2)); border: 1px solid var(--accent); color: var(--accent-2); border-radius: var(--radius); padding: 14px; font-weight: 700; font-size: 0.95rem; }
.ai-calc-btn > .lucide { width: 18px; height: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 1.15rem; }
.modal-close { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.modal-close .lucide { width: 18px; height: 18px; }
.cm-label { display: block; font-size: 0.78rem; color: var(--text-muted); font-weight: 600; margin: 14px 0 6px; }
.cm-label select { width: 100%; margin-top: 5px; }
.grade-pills { display: flex; gap: 8px; }
.grade-pills button { flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); border-radius: 10px; padding: 12px 0; font-size: 1.1rem; font-weight: 800; transition: transform 0.12s ease; }
.grade-pills button.active { background: var(--grad); color: #fff; border-color: transparent; }
.grade-pills button:active { transform: scale(0.93); }
.cm-go { width: 100%; margin-top: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.cm-go .lucide { width: 18px; height: 18px; }
#cm-result { margin-top: 16px; }
.cm-res-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; animation: pop 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
.cm-foot { font-size: 0.73rem; margin: 4px 0 0; }

/* Animacja „AI liczy" */
.ai-thinking { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 10px; }
.ai-orb { width: 64px; height: 64px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; color: #fff; animation: orbPulse 1.1s ease-in-out infinite; }
.ai-orb .lucide { width: 30px; height: 30px; animation: spinSlow 2.4s linear infinite; }
.ai-thinking-txt { font-size: 0.88rem; color: var(--text-dim); text-align: center; }
.ai-bar { width: 100%; max-width: 220px; height: 5px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.ai-bar span { display: block; height: 100%; width: 40%; background: var(--grad); border-radius: 4px; animation: aiBar 1.1s ease-in-out infinite; }
@keyframes orbPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(224, 33, 138, 0.45); } 50% { transform: scale(1.08); box-shadow: 0 0 0 16px rgba(224, 33, 138, 0); } }

/* O aplikacji / kontakt */
.info-body { display: flex; flex-direction: column; gap: 12px; }
.info-logo { display: flex; align-items: center; gap: 12px; }
.info-logo img { width: 46px; height: 46px; border-radius: 13px; }
.info-logo b { font-size: 1.08rem; }
.info-body p { margin: 0; color: var(--text-dim); font-size: 0.92rem; line-height: 1.55; }
.info-row { display: flex; align-items: center; gap: 9px; font-size: 0.9rem; color: var(--text-dim); }
.info-row .lucide { width: 17px; height: 17px; color: var(--accent-2); flex-shrink: 0; }
.info-row a { color: var(--accent-2); font-weight: 600; }
.info-disclaimer { font-size: 0.76rem !important; color: var(--text-faint) !important; }

/* Dodatkowe mikro-animacje */
.nav-btn.active .lucide { animation: pop 0.3s ease; }
.icon-btn { transition: transform 0.12s ease, background 0.15s ease; }
.icon-btn:active { transform: scale(0.9); }
.subject-avg, .freq-ring b { transition: color 0.2s ease; }
@keyframes spinSlow { to { transform: rotate(360deg); } }
@keyframes aiBar { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ===== Ogloszenia ===== */
.notice { padding: 12px 0; border-top: 1px solid var(--border); }
.notice:first-child { border-top: none; }
.notice-subj { font-weight: 600; font-size: 0.92rem; }
.notice-meta { font-size: 0.74rem; color: var(--text-muted); margin: 2px 0 6px; }
.notice-content { font-size: 0.86rem; color: var(--text-dim); white-space: pre-wrap; line-height: 1.45; }
.notice.collapsed .notice-content { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== Numerek / badge ===== */
.lucky-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent-2);
  border: 1px solid rgba(224,33,138,0.3);
  padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 700;
}

/* ===== Dolna nawigacja ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 640px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--bar-bg);
  backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--border);
  padding: 6px 3px calc(6px + env(safe-area-inset-bottom));
}
.nav-btn {
  position: relative;
  background: none; border: none; color: var(--text-faint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; font-size: 0.63rem; font-weight: 600;
  transition: color 0.15s;
}
.nav-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn.active { color: var(--accent-2); }
/* ===== Plan lekcji (karty dni + tryby) ===== */
.tt-controls { position: sticky; top: 64px; z-index: 10; display: flex; flex-direction: column; gap: 11px; }
.tt-navrow { display: flex; align-items: center; justify-content: space-between; }
.tt-label { font-size: 0.95rem; }
.tt-quick { display: flex; gap: 8px; }
.tt-chip {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 10px; padding: 9px 10px; font-size: 0.82rem; font-weight: 600;
}
.tt-chip .lucide { width: 16px; height: 16px; }
.tt-datepick { position: relative; overflow: hidden; cursor: pointer; }
.tt-datepick input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.tt-dots-wrap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.tt-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.tt-dot { height: 6px; border-radius: 4px; background: var(--surface-3); }
.tt-dot.full { background: var(--accent); }
.tt-dot-today { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.tt-day {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 15px;
}
.tt-day.today { border-left: 4px solid var(--accent); }
.tt-day.empty { padding: 11px 15px; opacity: 0.6; }
.tt-day-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tt-day.empty .tt-day-h { margin-bottom: 0; }
.tt-day-name { font-weight: 800; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.tt-day-date { font-size: 0.78rem; color: var(--text-muted); }
.tt-empty { margin-left: auto; font-size: 0.8rem; }
.tt-slot { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.tt-slot:first-of-type { border-top: none; }
.tt-slot.is-cancel { opacity: 0.55; }
.tt-slot.is-cancel .tt-slot-subj { text-decoration: line-through; }
.tt-slot-time {
  display: flex; flex-direction: column; align-items: flex-end;
  font-variant-numeric: tabular-nums; font-size: 0.86rem; font-weight: 700;
  min-width: 44px; line-height: 1.25;
}
.tt-slot-time span { font-weight: 500; font-size: 0.76rem; color: var(--text-muted); }
.tt-slot-body { flex: 1; min-width: 0; padding-top: 1px; }
.tt-slot-subj { font-weight: 600; font-size: 0.92rem; }
.tt-slot-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; opacity: 0.85; }

.greeting { font-size: 1.3rem; font-weight: 750; letter-spacing: -0.02em; }
.greeting-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

/* ===== Czat klasowy ===== */
.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - 64px - 92px); }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; border-bottom: 1px solid var(--border); }
.chat-online { font-size: 0.74rem; color: var(--green); font-weight: 600; white-space: nowrap; }
.chat-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 2px; overscroll-behavior-y: contain; }
.chat-msg { max-width: 82%; align-self: flex-start; display: flex; flex-direction: column; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-author { font-size: 0.7rem; color: var(--text-muted); margin: 0 0 2px 8px; font-weight: 600; }
.chat-bubble {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 16px; border-bottom-left-radius: 5px;
  font-size: 0.9rem; line-height: 1.35; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.mine .chat-bubble { background: var(--accent); color: #fff; border-color: transparent; border-radius: 16px; border-bottom-right-radius: 5px; }
.chat-time { font-size: 0.64rem; color: var(--text-faint); margin: 2px 8px 0; }
.chat-input { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; }
.chat-send {
  background: var(--grad); color: #fff; border: none; width: 46px; border-radius: var(--radius-sm);
  display: grid; place-items: center; flex-shrink: 0;
}
.chat-send .lucide { width: 20px; height: 20px; }
.chat-notice {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--accent-soft); border: 1px solid rgba(224, 33, 138, 0.25);
  color: var(--text-dim); border-radius: 10px; padding: 9px 11px; margin-top: 10px;
  font-size: 0.78rem; line-height: 1.35;
}
.chat-notice .lucide { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent-2); margin-top: 1px; }

/* ===== Wiadomości / katalog nauczycieli (tylko podgląd) ===== */
.msg-info { display: flex; align-items: flex-start; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 0.8rem; line-height: 1.4; color: var(--text-dim); }
.msg-info .lucide { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent-2); margin-top: 1px; }
.msg-teacher.static { cursor: default; }
.msg-teacher.static:hover { border-color: var(--border); }
.msg-search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; padding: 0 12px; }
.msg-search .lucide { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.msg-search input { flex: 1; border: none; background: none; padding: 12px 0; }
.msg-search input:focus { box-shadow: none; }
.msg-list { display: flex; flex-direction: column; gap: 8px; }
.msg-teacher { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; cursor: pointer; transition: border-color 0.15s; }
.msg-teacher:hover { border-color: var(--accent); }
.msg-teacher > .lucide { width: 18px; height: 18px; color: var(--text-faint); flex-shrink: 0; }
.msg-ava { width: 40px; height: 40px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.msg-ava.big { width: 48px; height: 48px; font-size: 1rem; }
.msg-tinfo { flex: 1; min-width: 0; }
.msg-tname { font-weight: 600; font-size: 0.92rem; }
.msg-subjs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; font-size: 0.74rem; }
.msg-subj { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 2px 8px; color: var(--text-dim); }
.msg-back { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--text-muted); font-weight: 600; font-size: 0.88rem; padding: 4px 0; }
.msg-back .lucide { width: 16px; height: 16px; }
.msg-to { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
#cmp-subj, #cmp-body { width: 100%; margin-bottom: 10px; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.primary .lucide { width: 18px; height: 18px; }
.msg-note { display: flex; gap: 8px; font-size: 0.78rem; color: var(--text-muted); margin-top: 12px; line-height: 1.4; }
.msg-note .lucide { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
#cmp-result { margin-top: 8px; font-size: 0.84rem; }
textarea {
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 1rem; outline: none;
  resize: vertical; font-family: inherit; line-height: 1.4;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.day-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lucky-badge { flex-shrink: 0; }

/* Przełącznik półroczy */
.segment { display: flex; gap: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.segment button { flex: 1; background: none; border: none; color: var(--text-muted); padding: 9px 6px; border-radius: 9px; font-size: 0.82rem; font-weight: 600; transition: background 0.15s, color 0.15s; }
.segment button.active { background: var(--surface); color: var(--accent-2); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12); }
