:root {
  --as-ai-bg: #071f16;
  --as-ai-panel: #0d2f23;
  --as-ai-soft: #123c2d;
  --as-ai-gold: #f3d27a;
  --as-ai-text: #f8f7ed;
  --as-ai-muted: #d8ccb0;
  --as-ai-danger: #ffb4a9;
  --as-ai-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.as-ai-button {
  position: fixed;
  z-index: 99998;
  left: 18px;
  right: auto;
  bottom: 18px;
  border: 1px solid rgba(243,210,122,.6);
  background: linear-gradient(135deg, #0d3a2b, #123f31);
  color: var(--as-ai-text);
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 800;
  box-shadow: var(--as-ai-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.as-ai-button:hover { transform: translateY(-1px); }

.as-ai-panel {
  position: fixed;
  z-index: 99999;
  left: 50%;
  right: auto;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(860px, calc(100vw - 28px));
  height: min(860px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  background: #0b281e;
  color: var(--as-ai-text);
  border: 1px solid rgba(243,210,122,.32);
  border-radius: 22px;
  box-shadow: var(--as-ai-shadow);
  overflow: hidden;
  display: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.as-ai-panel.open { display: flex; flex-direction: column; }

.as-ai-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(0,0,0,.18);
  border-bottom: 1px solid rgba(243,210,122,.22);
  flex: 0 0 auto;
}

.as-ai-header strong { color: var(--as-ai-gold); font-size: 1rem; }
.as-ai-header small { display: block; color: var(--as-ai-muted); margin-top: 2px; }
.as-ai-close {
  border: none;
  background: transparent;
  color: var(--as-ai-text);
  font-size: 24px;
  cursor: pointer;
}

.as-ai-body {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
}
.as-ai-body, .as-ai-body * { box-sizing: border-box; max-width: 100%; }

.as-ai-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.as-ai-chip,
.as-ai-send,
.as-ai-correct,
.as-ai-tts,
.as-ai-quiz-btn {
  border: 1px solid rgba(243,210,122,.22);
  background: rgba(255,255,255,.06);
  color: var(--as-ai-text);
  border-radius: 12px;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 700;
}

.as-ai-chip:hover,
.as-ai-send:hover,
.as-ai-correct:hover,
.as-ai-tts:hover,
.as-ai-quiz-btn:hover {
  background: rgba(243,210,122,.12);
}

.as-ai-textarea,
.as-ai-input,
.as-ai-select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(243,210,122,.24);
  background: rgba(0,0,0,.24);
  color: var(--as-ai-text);
  border-radius: 14px;
  padding: 12px;
  outline: none;
  font: inherit;
}

.as-ai-textarea { min-height: 96px; resize: vertical; }

.as-ai-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  margin-top: 8px;
}

.as-ai-send {
  background: linear-gradient(135deg, #f3d27a, #c9993f);
  color: #102117;
}

.as-ai-correct {
  background: rgba(243,210,122,.10);
  color: var(--as-ai-text);
}

.as-ai-response {
  margin-top: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(243,210,122,.18);
  border-radius: 16px;
  padding: 12px;
  min-height: 80px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.as-ai-response[dir="rtl"] { text-align: right; font-size: 1.2rem; }
.as-ai-error { color: var(--as-ai-danger); }
.as-ai-muted { color: var(--as-ai-muted); }
.as-ai-reader-status {
  display: inline-block;
  min-height: 1.35em;
  margin-top: 7px;
  color: #e7dcc1;
  font-size: .88rem;
  font-weight: 700;
}
.as-ai-provider-link {
  display: inline-block;
  margin: 6px 0 0 8px;
  color: #ffe6a3 !important;
  font-size: .82rem;
  font-weight: 800;
  text-decoration: underline;
}
.as-ai-inline-reader {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}
.as-ai-inline-reader.compact {
  display: flex;
  justify-content: flex-start;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(243,210,122,.18);
}
.as-ai-reader-btn.compact {
  border: 1px solid rgba(243,210,122,.38);
  border-radius: 999px;
  background: #f3d27a;
  color: #071f16;
  padding: 8px 12px;
  font-weight: 900;
  cursor: pointer;
}
.as-ai-reader-btn.compact.secondary { background: rgba(255,255,255,.09); color: #fffaf0; }
.as-ai-reader-btn:disabled { opacity: .65; cursor: wait; }

.as-ai-quiz {
  margin-top: 12px;
  border-top: 1px solid rgba(243,210,122,.18);
  padding-top: 12px;
}

.as-ai-quiz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.as-ai-question-card {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  border-radius: 14px;
  padding: 11px;
  margin-top: 10px;
}

.as-ai-choice {
  width: 100%;
  text-align: left;
  margin: 5px 0;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: var(--as-ai-text);
  padding: 9px;
  border-radius: 10px;
  cursor: pointer;
}

.as-ai-choice.good { background: rgba(95, 201, 126, .28); }
.as-ai-choice.bad { background: rgba(255, 99, 99, .25); }

@media (max-width: 620px) {
  .as-ai-panel { left: 6px; right: 6px; bottom: 6px; width:auto; height:calc(100dvh - 12px); max-height:calc(100dvh - 12px); transform:none; border-radius:16px; }
  .as-ai-button { left: 12px; right: auto; bottom: 12px; }
  .as-ai-tools, .as-ai-quiz-grid, .as-ai-actions { grid-template-columns: 1fr; }
}


.as-canvas-result-box {
  width: min(980px, calc(100% - 24px));
  margin: 18px auto;
  padding: 18px;
  border-radius: 18px;
  border: 2px solid rgba(189, 143, 55, .55);
  background: linear-gradient(135deg, rgba(7,31,22,.96), rgba(18,60,45,.94));
  color: #f8f7ed;
  box-shadow: 0 14px 40px rgba(0,0,0,.25);
  direction: ltr;
  text-align: left;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.as-canvas-result-box h3 {
  margin: 0 0 12px;
  color: #f3d27a;
  font-size: clamp(18px, 3vw, 24px);
}

.as-canvas-line,
.as-canvas-correction {
  white-space: pre-wrap;
  line-height: 1.65;
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(243,210,122,.2);
  margin-top: 10px;
}

.as-canvas-line {
  font-weight: 800;
  color: #fffbe8;
}

.as-canvas-correction {
  color: #f8f7ed;
}

.as-canvas-result-ready {
  animation: asCanvasPulse 1.1s ease-out 1;
}

@keyframes asCanvasPulse {
  0% { box-shadow: 0 0 0 0 rgba(243,210,122,.55); }
  100% { box-shadow: 0 14px 40px rgba(0,0,0,.25); }
}


.as-home-button {
  position: fixed;
  z-index: 99997;
  left: 16px;
  top: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 15px;
  border-radius: 999px;
  border: 1px solid rgba(243,210,122,.72);
  background: linear-gradient(135deg, #0d3a2b, #123f31);
  color: #f8f7ed !important;
  text-decoration: none !important;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 12px 36px rgba(0,0,0,.25);
  cursor: pointer;
}

.as-home-button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #123f31, #18513f);
}

@media (max-width: 620px) {
  .as-home-button {
    top: 10px;
    left: 10px;
    min-height: 38px;
    padding: 9px 12px;
    font-size: 14px;
  }
}


/* Indicateur discret de suivi établissement */
.as-db-sync-pill{position:fixed;left:14px;bottom:88px;z-index:9998;border:1px solid rgba(243,210,122,.35);background:rgba(6,24,18,.86);color:#f3d27a;border-radius:999px;padding:8px 11px;font-weight:800;font-size:.82rem;display:none;box-shadow:0 10px 30px rgba(0,0,0,.25)}
.as-db-sync-pill.show{display:block}
@media(max-width:640px){.as-db-sync-pill{bottom:76px;font-size:.78rem}}

/* v29 - résultat ArabicSchool visible directement dans la page */
.as-page-ai-result {
  width: min(1100px, calc(100% - 24px));
  margin: 18px auto 22px;
  padding: 18px;
  border-radius: 22px;
  border: 2px solid rgba(243,210,122,.38);
  background: linear-gradient(180deg, rgba(7,31,22,.97), rgba(16,56,40,.95));
  color: #fffaf0;
  box-shadow: 0 18px 52px rgba(0,0,0,.28);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  direction: ltr;
  text-align: left;
}
.as-page-ai-hidden { display: none !important; }
.as-page-ai-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(243,210,122,.20);
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.as-page-ai-result-kicker {
  display: inline-block;
  color: #ffe6a3;
  font-weight: 900;
  font-size: .92rem;
  letter-spacing: .02em;
  margin-bottom: 4px;
}
.as-page-ai-result h2 {
  margin: 0;
  color: #f3d27a;
  font-size: clamp(1.25rem, 2.6vw, 2rem);
}
.as-page-ai-result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.as-page-ai-result-actions > .as-ai-inline-reader { flex: 1 1 100%; }
.as-page-ai-result-btn {
  border: 1px solid rgba(243,210,122,.34);
  border-radius: 999px;
  background: linear-gradient(135deg, #f3d27a, #c9993f);
  color: #071f16;
  padding: 9px 13px;
  font-weight: 950;
  cursor: pointer;
}
.as-page-ai-result-btn.secondary {
  background: rgba(255,255,255,.10);
  color: #fffaf0;
}
.as-page-ai-result-content {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: clamp(1rem, 2.4vw, 1.18rem);
  border-radius: 18px;
  border: 1px solid rgba(243,210,122,.18);
  background: rgba(255,255,255,.07);
  padding: 16px;
  max-height: 70vh;
  overflow: auto;
}
.as-page-ai-turn {
  white-space: pre-wrap;
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 12px;
}
.as-page-ai-turn:last-child { margin-bottom: 0; }
.as-page-ai-turn strong { display: block; margin-bottom: 6px; color: #ffe6a3; }
.as-page-ai-turn.user {
  margin-left: min(12%, 90px);
  background: rgba(243,210,122,.14);
  border: 1px solid rgba(243,210,122,.30);
}
.as-page-ai-turn.assistant {
  margin-right: min(7%, 55px);
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.13);
}
.as-page-ai-followup {
  margin-top: 14px;
  padding: 15px;
  border-radius: 18px;
  border: 2px solid rgba(243,210,122,.45);
  background: rgba(3,20,14,.78);
}
.as-page-ai-followup label {
  display: block;
  color: #f3d27a;
  font-weight: 900;
  font-size: 1.05rem;
  margin-bottom: 8px;
}
.as-page-ai-followup-input {
  display: block;
  width: 100%;
  min-height: 86px;
  resize: vertical;
  box-sizing: border-box;
  border: 1px solid rgba(243,210,122,.48);
  border-radius: 14px;
  padding: 12px 14px;
  background: #f9fbf7;
  color: #102117;
  font: inherit;
  line-height: 1.5;
}
.as-page-ai-followup-input::placeholder { color: #56655d; opacity: 1; }
.as-page-ai-followup-input:focus { outline: 3px solid rgba(243,210,122,.28); border-color: #f3d27a; }
.as-page-ai-followup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}
.as-page-ai-followup-send,
.as-page-ai-followup-choice {
  border: 1px solid rgba(243,210,122,.36);
  border-radius: 12px;
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 850;
}
.as-page-ai-followup-send { background: linear-gradient(135deg, #f3d27a, #c9993f); color: #102117; }
.as-page-ai-followup-choice { background: rgba(255,255,255,.10); color: #fffaf0; }
.as-page-ai-followup-send:disabled,
.as-page-ai-followup-choice:disabled { opacity: .55; cursor: wait; }
.as-page-ai-followup-status { min-height: 1.4em; margin-top: 8px; color: #d8ccb0; font-size: .92rem; }
.as-page-ai-ready {
  animation: asPageResultPulse 1s ease-out 1;
}
.as-page-ai-copy-helper {
  position: fixed;
  left: -9999px;
  top: -9999px;
}
@keyframes asPageResultPulse {
  0% { box-shadow: 0 0 0 0 rgba(243,210,122,.55); }
  100% { box-shadow: 0 18px 52px rgba(0,0,0,.28); }
}
@media(max-width: 720px) {
  .as-page-ai-result { width: calc(100% - 16px); padding: 14px; border-radius: 18px; }
  .as-page-ai-result-header { display: grid; }
  .as-page-ai-result-actions { justify-content: stretch; }
  .as-page-ai-result-btn { flex: 1 1 auto; }
  .as-ai-inline-reader { justify-content: stretch; width: 100%; }
  .as-ai-inline-reader .as-ai-reader-btn { flex: 1 1 auto; }
  .as-page-ai-result-content { max-height: 60vh; }
  .as-page-ai-turn.user,.as-page-ai-turn.assistant { margin-left: 0; margin-right: 0; }
  .as-page-ai-followup-actions { display: grid; grid-template-columns: 1fr; }
}
@media print {
  .as-page-ai-result-actions { display: none !important; }
  .as-page-ai-result { box-shadow: none; background: white; color: #111; border: 1px solid #ddd; }
  .as-page-ai-result h2 { color: #064e3b; }
  .as-page-ai-result-kicker { color: #8a6a17; }
  .as-page-ai-result-content { color: #111; background: #fafafa; border: 1px solid #ddd; max-height: none; }
  .as-page-ai-followup { display: none !important; }
}
/* v107 — AI Teacher phase 1 */
.as-ai-teacher-modal{position:fixed;inset:0;z-index:100000;background:rgba(3,18,12,.78);display:grid;place-items:center;padding:18px}.as-ai-teacher-modal[hidden]{display:none}.as-ai-teacher-card{position:relative;width:min(680px,100%);max-height:90vh;overflow:auto;background:linear-gradient(180deg,#123b2b,#09261b);color:#fff;border:1px solid rgba(243,210,122,.42);border-radius:26px;padding:24px;box-shadow:0 30px 80px rgba(0,0,0,.45)}.as-ai-teacher-kicker{color:#f3d27a;font-weight:900}.as-ai-teacher-card h2{margin:.45rem 0 1rem}.as-ai-teacher-close{position:absolute;right:14px;top:10px;border:0;background:transparent;color:#fff;font-size:2rem;cursor:pointer}.as-ai-teacher-explain,.as-ai-teacher-warning{padding:14px;border-radius:16px;background:rgba(255,255,255,.07);border:1px solid rgba(243,210,122,.2);margin:12px 0}.as-ai-teacher-warning{background:rgba(255,174,66,.12);border-color:rgba(255,174,66,.45)}.as-ai-teacher-exercises{display:grid;gap:10px;padding-left:22px}.as-ai-teacher-exercises li{padding:10px 12px;border-radius:14px;background:rgba(255,255,255,.055)}.as-ai-teacher-exercises strong,.as-ai-teacher-exercises span{display:block}.as-ai-teacher-exercises span{margin-top:4px;color:#e7dfcb}.as-ai-teacher-mastery{margin:14px 0}.as-ai-teacher-mastery>span,.as-ai-teacher-mastery>strong{display:inline-block;margin-right:8px}.as-ai-teacher-mastery>div{height:10px;background:rgba(255,255,255,.12);border-radius:999px;overflow:hidden;margin-top:7px}.as-ai-teacher-mastery i{display:block;height:100%;background:linear-gradient(90deg,#2fb46c,#f3d27a)}.as-ai-teacher-ok{width:100%;border:0;border-radius:999px;padding:13px 18px;background:#f3d27a;color:#082218;font-weight:900;cursor:pointer}.as-ai-teacher-open{overflow:hidden}

.as-discovery-banner{display:grid;gap:.55rem;padding:1rem;border:2px solid #d6a42b;border-radius:16px;background:linear-gradient(135deg,#fff8dc,#fff);margin-bottom:1rem}.as-discovery-banner strong{font-size:1.15rem}.as-discovery-banner small{color:#6b5a2d}
