/* AI SHIFT panel v2 — PHP+PostgreSQL. Design: Midero (róż) + ciemny sidebar + gamifikacja. */
:root {
  --bg: #faf7f8;
  --card: #ffffff;
  --ink: #23151d;
  --muted: #83707b;
  --pink: #d11a6b;
  --pink2: #fb1466;
  --blue: #2563eb;
  --green: #16a34a;
  --purple: #7c3aed;
  --orange: #f97316;
  --amber: #d97706;
  --red: #dc2626;
  --line: #efe2e8;
  --side: #1d1016;
  --side2: #331222;
  --gold: #eab308;
  --radius: 16px;
  --shadow: 0 2px 14px rgba(209, 26, 107, .07);
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --head: "Space Grotesk", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.55; }
h1, h2, h3, h4 { font-family: var(--head); letter-spacing: -.015em; margin: 0 0 .5em; }
h1 { font-size: 1.65rem; } h2 { font-size: 1.22rem; } h3 { font-size: 1.02rem; }
a { color: var(--pink); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* ================= layout: sidebar + main ================= */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(175deg, var(--side) 0%, var(--side2) 100%); color: #f5e9ef;
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { font-family: var(--head); font-weight: 700; font-size: 1.25rem; color: #fff; padding: 4px 10px 16px; }
.sidebar .logo b { color: var(--pink2); }
.sidebar .logo .sub { display: block; font-size: .68rem; font-weight: 400; color: #bfa3b2; letter-spacing: .12em; text-transform: uppercase; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #e9d4e0; padding: 9px 12px;
  border-radius: 10px; font-size: .92rem; font-weight: 500; }
.sidebar nav a .ic { width: 22px; text-align: center; font-size: 1.05rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidebar nav a.active { background: var(--pink); color: #fff; box-shadow: 0 4px 14px rgba(209,26,107,.4); }
.sidebar .nav-sep { margin: 10px 12px 4px; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #9c7f90; }
.sidebar .me { display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-top: 1px solid rgba(255,255,255,.1); margin-top: 8px; }
.sidebar .me .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--pink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; }
.sidebar .me small { color: #bfa3b2; display: block; }
.sidebar .me button { margin-left: auto; background: none; border: none; color: #bfa3b2; cursor: pointer; font-size: 1rem; padding: 4px; }
.sidebar .me button:hover { color: #fff; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px;
  background: rgba(250,247,248,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: 12px 26px; }
.topbar .crumb { font-family: var(--head); font-weight: 700; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 26px 110px; }

/* pasek XP w topbarze */
.xp-pill { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 14px 5px 6px; box-shadow: var(--shadow); cursor: pointer; }
.xp-pill:hover { border-color: var(--pink); }
.lvl-ring { width: 34px; height: 34px; position: relative; flex: none; }
.lvl-ring svg { transform: rotate(-90deg); }
.lvl-ring .n { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: .78rem; color: var(--pink); }
.xp-pill .t { line-height: 1.15; }
.xp-pill .t b { font-size: .84rem; display: block; }
.xp-pill .t small { color: var(--muted); font-size: .72rem; font-family: var(--mono); }
.bell { position: relative; cursor: pointer; font-size: 1.25rem; padding: 5px 9px; border-radius: 10px; }
.bell:hover { background: #f7e3ec; }
.bell .dot { position: absolute; top: 0; right: 0; min-width: 17px; height: 17px; border-radius: 9px;
  background: var(--pink2); color: #fff; font-size: .68rem; font-weight: 700; display: flex;
  align-items: center; justify-content: center; padding: 0 4px; }

/* ================= karty, kafle ================= */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { margin-left: auto; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 10px; text-align: center; }
.kpi .v { font-family: var(--head); font-size: 2rem; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.kpi.pink .v { color: var(--pink); } .kpi.blue .v { color: var(--blue); }
.kpi.green .v { color: var(--green); } .kpi.purple .v { color: var(--purple); }
.kpi.orange .v { color: var(--orange); } .kpi.gold .v { color: var(--gold); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .74rem;
  font-weight: 600; font-family: var(--mono); background: #f7e3ec; color: var(--pink); }
.badge.gray { background: #f2ecef; color: var(--muted); }
.badge.green { background: #dcfce7; color: var(--green); }
.badge.amber { background: #fef3c7; color: var(--amber); }
.badge.red { background: #fee2e2; color: var(--red); }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.purple { background: #ede9fe; color: var(--purple); }
.badge.orange { background: #ffedd5; color: var(--orange); }

button, .btn { font-family: var(--body); font-size: .92rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--pink); background: var(--pink); color: #fff; border-radius: 11px;
  padding: 9px 18px; transition: filter .15s, transform .1s; }
button:hover, .btn:hover { filter: brightness(1.08); }
button:active { transform: scale(.98); }
button.ghost { background: transparent; color: var(--pink); }
button.ghost:hover { background: #f7e3ec; }
button.subtle { background: #f2ecef; border-color: #f2ecef; color: var(--ink); font-weight: 500; }
button:disabled { opacity: .45; cursor: default; }
textarea, input[type=text], select { width: 100%; font-family: var(--body); font-size: .95rem;
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 13px; background: #fff; color: var(--ink); }
textarea:focus, input:focus, select:focus { outline: 2px solid #f3c1d8; border-color: var(--pink); }
textarea { min-height: 140px; resize: vertical; }
label { font-weight: 600; font-size: .88rem; display: block; margin: 10px 0 4px; }
.pbar { height: 9px; border-radius: 5px; background: #f3e6ec; overflow: hidden; flex: 1; min-width: 80px; }
.pbar > div { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--pink), var(--pink2)); transition: width .5s; }
.pbar.green > div { background: linear-gradient(90deg, #22c55e, var(--green)); }
.pbar.gold > div { background: linear-gradient(90deg, #fbbf24, var(--gold)); }

/* ================= login ================= */
.login-hero { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 500px at 80% -10%, #fbe3ee 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 110%, #ffe9d6 0%, transparent 55%), var(--bg); }
.login { max-width: 960px; padding: 40px 24px; text-align: center; }
.login h1 { font-size: 2.2rem; }
.login .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 30px; }
.usercard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 14px; cursor: pointer; transition: transform .13s, box-shadow .13s; text-align: center; }
.usercard:hover { transform: translateY(-4px); box-shadow: 0 10px 26px rgba(209, 26, 107, .16); }
.usercard .avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--pink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.2rem; margin: 0 auto 10px; }
.usercard.trener .avatar { background: var(--orange); }
.usercard.admin .avatar { background: var(--ink); }

/* ================= kurs / materiały ================= */
.module { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden; }
.module > .mhead { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; }
.module > .mhead:hover { background: #fdf7fa; }
.module .mcode { font-family: var(--mono); font-weight: 700; color: var(--pink); font-size: .85rem; min-width: 36px; }
.module .mbody { border-top: 1px solid var(--line); padding: 8px 18px 14px; }
.mat { display: flex; align-items: center; gap: 11px; padding: 10px 6px; border-bottom: 1px dashed var(--line); }
.mat:last-child { border-bottom: 0; }
.mat .ic { font-size: 1.15rem; width: 28px; text-align: center; }
.mat .t { flex: 1; }
.mat .t .desc { color: var(--muted); font-size: .84rem; }
.mat.done .t > div:first-child { text-decoration: line-through; color: var(--muted); }
.checkbtn { width: 27px; height: 27px; border-radius: 9px; border: 2px solid var(--line); background: #fff;
  color: transparent; font-size: .9rem; padding: 0; display: flex; align-items: center; justify-content: center; }
.checkbtn.on { background: var(--green); border-color: var(--green); color: #fff; }

/* ================= podręcznik ================= */
.hb { display: grid; grid-template-columns: 290px 1fr; gap: 20px; align-items: start; }
.hb .toc { position: sticky; top: 74px; max-height: calc(100vh - 100px); overflow: auto; }
.toc a.sec { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 8px; color: var(--ink); font-size: .88rem; }
.toc a.sec:hover { background: #f7e3ec; text-decoration: none; }
.dotst { width: 9px; height: 9px; border-radius: 50%; background: #e2ccd7; flex: none; }
.dotst.przeczytana { background: var(--green); }
.dotst.do_ponownego { background: var(--amber); }
.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px; margin-bottom: 14px; }
.section h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section .content table { border-collapse: collapse; width: 100%; font-size: .88rem; margin: 10px 0; }
.section .content th, .section .content td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.section .content th { background: #fdf3f7; font-family: var(--head); }
.banner { border: 1px solid #fcd34d; background: #fffbeb; border-radius: var(--radius); padding: 15px 19px; margin-bottom: 16px; }
.diff ins { background: #dcfce7; text-decoration: none; }
.diff del { background: #fee2e2; }
.diffbox { border: 1px dashed var(--amber); background: #fffdf5; border-radius: 12px; padding: 13px 17px; margin-top: 10px; }

/* ================= dojo ================= */
.belt { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 700; font-family: var(--mono);
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.belt.b1 { border-color: #cbd5e1; }
.belt.b2 { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.belt.b3 { background: var(--ink); color: #fff; border-color: var(--ink); }
.case { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 17px 19px; margin-bottom: 12px; }
.case .scenario { background: #fdf7f9; border-left: 3px solid var(--pink); padding: 11px 15px; border-radius: 0 10px 10px 0; margin: 10px 0; }
.case .scenario.story { background: #fdf9ee; border-left-color: var(--gold); }
.rubric li { font-size: .87rem; margin-bottom: 3px; }
.fb { border-radius: 12px; border: 1px solid var(--line); padding: 13px 17px; margin-top: 12px; background: #fdfbfc; }
.fb .crit { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.fb .crit:last-child { border-bottom: 0; }
.score { font-family: var(--mono); font-weight: 700; }
.score.ok { color: var(--green); } .score.bad { color: var(--red); }

/* ================= historia (fabuła) ================= */
.story-hero { background: linear-gradient(120deg, #331222 0%, #6d1d44 60%, #d11a6b 130%); color: #fff;
  border-radius: var(--radius); padding: 26px 28px; margin-bottom: 20px; box-shadow: 0 10px 30px rgba(120,20,70,.35); }
.story-hero h1 { color: #fff; margin-bottom: 4px; }
.story-hero .tagline { color: #f3cfe0; font-family: var(--mono); font-size: .85rem; }
.story-hero p { color: #fbe4ef; max-width: 72ch; }
.chapter { display: grid; grid-template-columns: 56px 1fr; gap: 14px; margin-bottom: 14px; }
.chapter .no { width: 46px; height: 46px; border-radius: 50%; background: #fff; border: 2px solid var(--pink);
  color: var(--pink); font-family: var(--head); font-weight: 700; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.chapter.done .no { background: var(--pink); color: #fff; }
.chapter .cline { position: relative; }
.chapter .cline::before { content: ""; position: absolute; left: -36px; top: 52px; bottom: -14px; width: 2px; background: #f0d6e2; }
.chapter:last-child .cline::before { display: none; }
.chapter .card { margin-bottom: 0; }
.mission { background: #fdf3f7; border: 1px dashed var(--pink); border-radius: 12px; padding: 12px 16px; margin-top: 10px; font-size: .92rem; }
.asset { display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 12px; margin: 6px 8px 0 0; font-size: .85rem; color: var(--ink); }
.asset:hover { border-color: var(--pink); text-decoration: none; box-shadow: var(--shadow); }

/* ================= osiągnięcia ================= */
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 13px; }
.badge-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  padding: 16px; text-align: center; transition: transform .12s; }
.badge-card:hover { transform: translateY(-2px); }
.badge-card .bic { font-size: 2.3rem; }
.badge-card.locked { opacity: .42; filter: grayscale(.9); }
.badge-card b { display: block; margin: 6px 0 2px; }
.badge-card .small { min-height: 40px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px dashed var(--line); }
.lb-row:last-child { border-bottom: 0; }
.lb-row .pos { font-family: var(--mono); font-weight: 700; width: 28px; color: var(--muted); }
.lb-row.me { background: #fdf3f7; border-radius: 10px; }
.lb-row .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--pink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; }

/* ================= trener ================= */
table.matrix { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.matrix th, table.matrix td { border: 1px solid var(--line); padding: 7px 9px; text-align: center; }
table.matrix th { background: #fdf3f7; font-family: var(--head); font-size: .8rem; }
table.matrix td.name { text-align: left; font-weight: 600; }
.alert { display: flex; gap: 10px; align-items: baseline; padding: 9px 13px; border-radius: 11px; margin-bottom: 6px; font-size: .9rem; }
.alert.warn { background: #fef3c7; }
.alert.info { background: #dbeafe; }
.qitem { border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; margin-bottom: 10px; background: #fff; }
.qitem .ans { background: #fdf7f9; padding: 8px 12px; border-radius: 9px; font-size: .88rem; white-space: pre-wrap; max-height: 150px; overflow: auto; }
.qq { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 19px; margin-bottom: 12px; }
.qq .opt { display: flex; gap: 9px; align-items: baseline; padding: 7px 10px; border-radius: 9px; cursor: pointer; }
.qq .opt:hover { background: #fdf7f9; }
.qq .opt input { accent-color: var(--pink); }
.qq.correct { border-color: var(--green); }
.qq.wrong { border-color: var(--red); }
.notif { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif.unread { background: #fdf3f7; }
.notif .ic { font-size: 1.3rem; }
.notif .ts { color: var(--muted); font-size: .78rem; font-family: var(--mono); }
.empty { text-align: center; color: var(--muted); padding: 44px 10px; }

/* ================= chat AI Mentora ================= */
.chat-fab { position: fixed; right: 26px; bottom: 26px; z-index: 90; width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink2)); color: #fff; font-size: 1.6rem; border: none;
  box-shadow: 0 10px 30px rgba(209,26,107,.45); display: flex; align-items: center; justify-content: center; }
.chat-fab:hover { transform: scale(1.06); }
.chat-drawer { position: fixed; right: 24px; bottom: 100px; z-index: 95; width: 400px; max-width: calc(100vw - 40px);
  height: 560px; max-height: calc(100vh - 140px); background: #fff; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 24px 60px rgba(40,10,26,.3); display: none; flex-direction: column; overflow: hidden; }
.chat-drawer.open { display: flex; }
.chat-head { background: linear-gradient(120deg, var(--side2), var(--pink)); color: #fff; padding: 13px 17px; }
.chat-head b { font-family: var(--head); }
.chat-head .small { color: #f5cfe1; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #fdfafb; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: .9rem; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--pink); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant em { color: var(--muted); font-size: .8rem; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
.chat-input input { flex: 1; }
.chat-foot { padding: 0 12px 10px; background: #fff; }
.typing { align-self: flex-start; color: var(--muted); font-size: .85rem; padding: 4px 10px; }
.typing .d { display: inline-block; animation: blink 1.2s infinite; }
.typing .d:nth-child(2) { animation-delay: .2s; } .typing .d:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .2 } 40% { opacity: 1 } }

/* ================= toast / konfetti ================= */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 11px 24px; border-radius: 999px; font-size: .9rem; z-index: 99; box-shadow: 0 6px 24px rgba(0,0,0,.28); }
.badge-toast { position: fixed; top: 74px; right: 26px; z-index: 99; background: #fff; border: 2px solid var(--gold);
  border-radius: 16px; padding: 14px 20px; box-shadow: 0 14px 40px rgba(180,140,20,.35);
  display: flex; gap: 12px; align-items: center; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.badge-toast .bic { font-size: 2.2rem; }
@keyframes pop { from { transform: translateY(-16px) scale(.85); opacity: 0 } to { transform: none; opacity: 1 } }
.confetti { position: fixed; z-index: 98; width: 9px; height: 14px; top: -20px; pointer-events: none;
  animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .1 } }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; transition: left .2s; z-index: 80; width: 240px; }
  .sidebar.open { left: 0; }
  .hb { grid-template-columns: 1fr; } .hb .toc { position: static; max-height: none; }
  .burger { display: inline-flex !important; }
}
.burger { display: none; background: none; border: none; color: var(--ink); font-size: 1.3rem; cursor: pointer; }

/* ================= treść lekcji ================= */
.lesson { line-height: 1.65; }
.lesson h4 { margin: 14px 0 6px; color: var(--pink); font-family: var(--head); }
.lesson table { border-collapse: collapse; width: 100%; font-size: .88rem; margin: 10px 0; }
.lesson th, .lesson td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.lesson th { background: #fdf3f7; }
.lesson ul, .lesson ol { padding-left: 22px; }
