/* assets/style.css — UX ULTRA PRO ++++ (stable desktop+mobile) */
:root{
  --bg:#f6f8fb;
  --primary:#2b90d9;
  --primary2:#2170b8;
  --text:#0f1724;
  --muted:#6b7280;
  --card:#ffffff;
  --border:#e7e7e7;
  --maxw:1100px;
  --radius:14px;
}

*{ box-sizing:border-box; }

html,body{ height:100%; }

body{
  margin:0;
  font-family:Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
}

img,video{ max-width:100%; height:auto; }
a{ color:inherit; text-decoration:none; }

.container{ width:min(var(--maxw), 92%); margin:0 auto; }
.page-content{ min-height:calc(100vh - 240px); }

/* ===== HEADER ===== */
.site-header{
  background:linear-gradient(90deg, var(--primary), var(--primary2));
  color:#fff;
  position:sticky;
  top:0;
  z-index:5000;
}

.site-header.is-lesson{
  z-index:1000;
}

.header-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 0;
  position:relative;
}

.brand a{
  display:flex;
  align-items:center;
  gap:12px;
  color:#fff;
}

.logo{
  width:42px;
  height:42px;
  object-fit:contain;
  border-radius:12px;
}

.brand-text h1{
  margin:0;
  font-size:1.15rem;
  font-weight:900;
}

.brand-text small{
  display:block;
  opacity:.92;
  font-weight:700;
}

.back-btn{
  width:42px;
  height:42px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,.25);
  background:rgba(255,255,255,.10);
  color:#fff;
  font-weight:900;
}

/* nav */
.main-nav{
  display:flex;
  align-items:center;
  gap:14px;
}

.main-nav a{
  color:#fff;
  font-weight:800;
  padding:8px 10px;
  border-radius:12px;
}

.main-nav a:hover{
  background:rgba(255,255,255,.10);
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:9px 12px;
  border-radius:12px;
  font-weight:900;
  border:1px solid rgba(255,255,255,.20);
}

.btn-outline{ background:rgba(255,255,255,.10); }
.btn-ghost{ background:rgba(255,255,255,.06); }

/* mobile toggle */
.nav-toggle{
  display:none;
  width:44px;
  height:44px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.25);
  background:rgba(255,255,255,.10);
  color:#fff;
  cursor:pointer;
  font-size:18px;
  font-weight:900;
}

/* quickbar */
.quickbar{
  padding:10px 0 12px;
}

.quickbar-inner{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}

.pills{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.20);
  background:rgba(255,255,255,.08);
  color:#fff;
  font-weight:900;
}

.pill:hover{
  background:rgba(255,255,255,.14);
}

.searchbox{
  display:flex;
  align-items:center;
  gap:8px;
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.22);
  border-radius:999px;
  padding:6px 8px;
}

.searchbox input{
  width:min(420px, 60vw);
  border:none;
  outline:none;
  background:transparent;
  color:#fff;
  font-weight:800;
}

.searchbox input::placeholder{
  color:rgba(255,255,255,.85);
}

.searchbox button{
  width:38px;
  height:38px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.25);
  background:rgba(255,255,255,.10);
  color:#fff;
  cursor:pointer;
  font-weight:900;
}

/* ===== CMDK ===== */
.cmdk-backdrop{
  position:fixed;
  inset:0;
  display:none;
  background:rgba(0,0,0,.35);
  z-index:9000;
}

.cmdk-backdrop.open{ display:block; }

.cmdk{
  width:min(820px, 92vw);
  margin:10vh auto 0;
  background:#fff;
  border-radius:16px;
  box-shadow:0 30px 80px rgba(0,0,0,.25);
  overflow:hidden;
  border:1px solid rgba(0,0,0,.08);
}

.cmdk-head{
  padding:12px;
  border-bottom:1px solid #eef2f7;
  background:#f8fafc;
}

.cmdk-head input{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid #e5e7eb;
  font-weight:900;
  outline:none;
}

.cmdk-list{
  max-height:52vh;
  overflow:auto;
}

.cmdk-item{
  padding:12px 14px;
  border-bottom:1px solid #f1f5f9;
  cursor:pointer;
}

.cmdk-item:hover{ background:#f8fafc; }

.cmdk-item .l{
  font-weight:900;
  color:#0f1724;
}

.cmdk-item .s{
  color:#64748b;
  font-weight:800;
  font-size:.92rem;
  margin-top:2px;
}

.cmdk-empty{
  padding:14px;
  color:#64748b;
  font-weight:900;
}

/* ===== FOOTER ===== */
.main-footer{
  background:#0b1220;
  color:#e5e7eb;
  margin-top:40px;
  padding:42px 0 18px;
}

.footer-grid{
  display:grid;
  grid-template-columns:repeat(4, minmax(0,1fr));
  gap:22px;
}

.main-footer h4{
  margin:0 0 12px;
  font-weight:900;
  color:#fff;
}

.footer-desc{
  color:#cbd5e1;
  font-weight:750;
  line-height:1.6;
  max-width:320px;
}

.footer-links{
  display:grid;
  gap:10px;
}

.footer-links a{
  color:#e5e7eb;
  font-weight:850;
}

.footer-links a:hover{
  color:#93c5fd;
}

.footer-bottom{
  margin-top:22px;
  padding-top:14px;
  border-top:1px solid rgba(255,255,255,.12);
  color:#a3a3a3;
  text-align:center;
  font-weight:800;
}

/* ===== RESPONSIVE ===== */
@media (max-width:980px){
  .footer-grid{ grid-template-columns:repeat(2, minmax(0,1fr)); }
}

@media (max-width:860px){
  .nav-toggle{
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }

  .main-nav{
    display:none;
    position:absolute;
    top:64px;
    right:0;
    width:min(92vw, 360px);
    background:#fff;
    border-radius:16px;
    padding:10px;
    box-shadow:0 25px 60px rgba(0,0,0,.25);
    border:1px solid rgba(0,0,0,.08);
    flex-direction:column;
    align-items:stretch;
    gap:6px;
    z-index:7000;
  }

  .main-nav.nav-open{ display:flex; }

  .main-nav a{
    color:#0f1724;
    background:#fff;
    padding:12px 12px;
    border-radius:12px;
  }

  .main-nav a:hover{ background:#f3f4f6; }

  .btn,
  .btn-outline,
  .btn-ghost{
    border:1px solid #e5e7eb;
    background:#f8fafc;
    color:#0f1724;
  }

  .quickbar-inner{ gap:10px; }
  .searchbox input{ width:min(260px, 66vw); }

  .site-header *{ -webkit-tap-highlight-color:transparent; }
}

@media (max-width:560px){
  .footer-grid{ grid-template-columns:1fr; }
}

/* ===== Utility ===== */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:0 8px 30px rgba(16,24,40,.06);
}

/* ===== Auto Graph Cards (Lesson) ===== */
.mm-graph-card{
  margin:18px 0;
  background:#0b1220;
  color:#e5e7eb;
  border:1px solid rgba(255,255,255,.10);
  border-radius:16px;
  padding:14px;
  box-shadow:0 16px 34px rgba(2,6,23,.25);
  overflow:hidden;
}

.mm-graph-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  flex-wrap:wrap;
}

.mm-graph-title{
  font-weight:900;
  font-size:1.02rem;
}

.mm-graph-sub{
  color:rgba(255,255,255,.70);
  font-weight:700;
  margin-top:4px;
  font-size:.92rem;
}

.mm-graph-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.mm-graph-btn{
  border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.06);
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  font-weight:900;
  cursor:pointer;
}

.mm-graph-btn:hover{
  background:rgba(255,255,255,.10);
}

.mm-graph-canvas{
  width:100%;
  height:260px;
  display:block;
  margin-top:12px;
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
}

.mm-graph-foot{
  margin-top:10px;
  color:rgba(255,255,255,.75);
  font-size:.92rem;
  font-weight:700;
}

@media (max-width:620px){
  .mm-graph-canvas{ height:220px; }
}

/* ===== Lesson tools modal ===== */
.mm-tools-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  display:none;
  pointer-events:none;
  z-index:6000;
}

.mm-tools-backdrop.open{
  display:block;
  pointer-events:auto;
}

.mm-tools{
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  width:min(1180px, 96vw);
  height:min(92vh, 920px);
  background:#fff;
  border-radius:16px;
  box-shadow:0 25px 70px rgba(0,0,0,.25);
  overflow:hidden;
  border:1px solid rgba(0,0,0,.08);
  display:flex;
  flex-direction:column;
  z-index:6100;
}

.mm-tools.is-fullscreen{
  width:100vw !important;
  height:100vh !important;
  max-width:none !important;
  max-height:none !important;
  border-radius:0 !important;
}

.mm-tools.is-collapsed{
  height:auto !important;
  min-height:0 !important;
}

.mm-tools.is-collapsed .mm-tools-body{
  display:none !important;
}

.mm-tools-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  padding:12px 14px;
  background:#f8fafc;
  border-bottom:1px solid #eef2f7;
}

.mm-tools-body{
  display:grid;
  grid-template-columns:260px 1fr;
  flex:1;
  min-height:0;
  overflow:hidden;
}

.mm-tools-left{
  border-right:1px solid #eef2f7;
  padding:12px;
  background:#fbfdff;
  overflow:auto;
  min-height:0;
}

.mm-tools-right{
  padding:14px;
  overflow:auto;
  min-height:0;
}

.mm-panel{
  width:100%;
  max-width:100%;
}

.mm-panel .mm-row,
.mm-panel .mm-actions,
.mm-panel .mm-canvas-wrap,
.mm-panel .mm-result-box,
.mm-panel .mm-table-scroll,
.mm-panel .mm-hint,
.mm-panel .mm-in,
.mm-panel .mm-ta{
  width:100%;
  max-width:100%;
  box-sizing:border-box;
}

.mm-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
  align-items:center;
}

.mm-result-box{
  margin-top:12px;
  padding:12px;
  border-radius:12px;
  background:#f8fafc;
  border:1px solid #e5e7eb;
  line-height:1.65;
  font-weight:800;
  color:#0f172a;
  white-space:pre-wrap;
  overflow:auto;
  max-width:100%;
  box-sizing:border-box;
}

.mm-table-scroll{
  overflow:auto;
  border:1px solid #e5e7eb;
  border-radius:12px;
  margin-top:12px;
  max-width:100%;
  box-sizing:border-box;
}

.mm-table{
  width:100%;
  border-collapse:collapse;
  background:#fff;
}

.mm-table th,
.mm-table td{
  white-space:nowrap;
}

.mm-canvas-wrap{
  border:1px solid #e5e7eb;
  border-radius:14px;
  overflow:hidden;
  background:#fff;
  margin-top:12px;
  max-width:100%;
}

.mm-canvas-wrap canvas,
#mmCanvas,
#mmProbaCanvas{
  display:block;
  width:100%;
  max-width:100%;
}

/* ===== Bac blanc / examen ===== */
#mmBacHeader,
.mm-bac-header{
  display:block;
  width:100%;
  max-width:1100px;
  margin:0 auto 14px;
  position:relative;
  z-index:30;
  visibility:visible;
  opacity:1;
}

#mmBacHeader:empty,
.mm-bac-header:empty{
  display:none;
}

#mmBacHeader .mm-result-box,
.mm-bac-header .mm-result-box{
  display:block;
  width:100%;
  margin:0 0 12px;
  background:#f8fafc;
  border:1px solid #e5e7eb;
  border-radius:12px;
  padding:12px 14px;
  line-height:1.7;
  font-weight:800;
  color:#0f172a;
  box-sizing:border-box;
}

#mmExamTimer{
  position:fixed;
  top:10px;
  right:10px;
  z-index:12000;
}

@media (max-width:860px){
  .mm-tools{
    width:100vw;
    height:100vh;
    max-width:none;
    max-height:none;
    border-radius:0;
  }

  .mm-tools-body{
    grid-template-columns:1fr;
  }

  .mm-tools-left{
    border-right:none;
    border-bottom:1px solid #eef2f7;
  }
}