/* ═══════════ مدرّس لسان — Tutor ═══════════
   بيتبع وضع الموقع (فاتح / ليلي) تلقائي: لما body ياخد الكلاس dark-mode الألوان بتتبدّل.
   مستقل بالكامل: كل الكلاسات بتبدأ بـ tt- ومفيش أي تعديل على قواعد باقي الموقع. */

#tutor-screen,
.tt-home-card {
  --tt-card: #ffffff;
  --tt-bg2: #f4f5fc;
  --tt-bd: #e3e6f3;
  --tt-tx: #1c1c2e;
  --tt-mut: #656d8a;
  --tt-ac: #6c63ff;
  --tt-ac-soft: rgba(108, 99, 255, 0.1);
  --tt-ac-tx: #4834d4;
  --tt-gold: #ffba00;
  --tt-on-gold: #1a1a1a;
  --tt-ok: #00a884;
  --tt-ok-soft: rgba(0, 184, 148, 0.12);
  --tt-warn: #b87500;
  --tt-warn-soft: rgba(255, 186, 0, 0.16);
  --tt-bad: #c8000a;
  --tt-bad-soft: rgba(200, 0, 10, 0.08);
}
body.dark-mode #tutor-screen,
body.dark-mode .tt-home-card {
  --tt-card: #0f1424;
  --tt-bg2: #111827;
  --tt-bd: rgba(255, 255, 255, 0.09);
  --tt-tx: #dde3f8;
  --tt-mut: #8d96b8;
  --tt-ac: #7c6aff;
  --tt-ac-soft: rgba(124, 106, 255, 0.16);
  --tt-ac-tx: #b9b0ff;
  --tt-gold: #ffc947;
  --tt-on-gold: #05070f;
  --tt-ok: #00d68f;
  --tt-ok-soft: rgba(0, 214, 143, 0.14);
  --tt-warn: #ffc947;
  --tt-warn-soft: rgba(255, 201, 71, 0.14);
  --tt-bad: #ff5d73;
  --tt-bad-soft: rgba(255, 61, 87, 0.13);
}

.tt-wrap {
  max-width: 760px;
  margin: 0 auto;
  color: var(--tt-tx);
}
.tt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.tt-back {
  background: var(--tt-card);
  color: var(--tt-mut);
  border: 1px solid var(--tt-bd);
  border-radius: 50px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* بطاقات */
.tt-card {
  background: var(--tt-card);
  border: 1px solid var(--tt-bd);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.tt-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--tt-tx);
}
.tt-card-title i {
  color: var(--tt-ac);
}
.tt-card-title .tt-grow {
  flex: 1;
}
.tt-sub {
  font-size: 12.5px;
  color: var(--tt-mut);
  line-height: 1.7;
  margin: 0;
}

/* الهيدر */
.tt-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.tt-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--tt-ac);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.tt-head-txt {
  flex: 1;
  min-width: 0;
}
.tt-head-txt h2 {
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--tt-tx);
}
.tt-lvl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tt-ac-soft);
  color: var(--tt-ac-tx);
  border-radius: 50px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
}
.tt-ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.tt-ring svg {
  width: 64px;
  height: 64px;
  transform: rotate(-90deg);
}
.tt-ring .tt-ring-bg {
  stroke: var(--tt-bd);
}
.tt-ring .tt-ring-fg {
  stroke: var(--tt-gold);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.tt-ring-n {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--tt-tx);
  line-height: 1.1;
}
.tt-ring-n small {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--tt-mut);
}

/* التابات */
.tt-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--tt-bg2);
  border: 1px solid var(--tt-bd);
  border-radius: 14px;
  padding: 5px;
  margin: 14px 0;
}
.tt-tab {
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 9px 4px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--tt-mut);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: background 0.2s, color 0.2s;
}
.tt-tab i {
  font-size: 15px;
}
.tt-tab.active {
  background: var(--tt-card);
  color: var(--tt-ac-tx);
  box-shadow: 0 0 0 1px var(--tt-bd);
}

/* أزرار */
.tt-btn {
  background: var(--tt-ac);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.tt-btn.gold {
  background: var(--tt-gold);
  color: var(--tt-on-gold);
}
.tt-btn.ghost {
  background: transparent;
  color: var(--tt-ac-tx);
  border: 1px solid var(--tt-bd);
}
.tt-btn.block {
  width: 100%;
  padding: 11px;
  font-size: 13.5px;
}
.tt-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 50px;
  padding: 4px 10px;
  background: var(--tt-ac-soft);
  color: var(--tt-ac-tx);
  border: 1px solid transparent;
}
button.tt-chip {
  font-family: inherit;
  cursor: pointer;
  border-color: var(--tt-bd);
  background: transparent;
}
.tt-pct {
  font-size: 12px;
  font-weight: 800;
  border-radius: 8px;
  padding: 3px 9px;
  white-space: nowrap;
}
.tt-pct.ok {
  background: var(--tt-ok-soft);
  color: var(--tt-ok);
}
.tt-pct.mid {
  background: var(--tt-warn-soft);
  color: var(--tt-warn);
}
.tt-pct.bad {
  background: var(--tt-bad-soft);
  color: var(--tt-bad);
}

/* المهام */
.tt-task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--tt-bd);
}
.tt-task:first-of-type {
  border-top: none;
}
.tt-chk {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--tt-bd);
  background: transparent;
  color: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 0;
}
.tt-task.done .tt-chk {
  background: var(--tt-ok);
  border-color: var(--tt-ok);
  color: #fff;
}
.tt-task-b {
  flex: 1;
  min-width: 0;
}
.tt-task-t {
  font-size: 14px;
  font-weight: 800;
  margin: 0 0 2px;
  color: var(--tt-tx);
  overflow-wrap: anywhere;
}
.tt-task.done .tt-task-t {
  text-decoration: line-through;
  color: var(--tt-mut);
}
.tt-task-s {
  font-size: 12px;
  color: var(--tt-mut);
  margin: 0;
}

/* شرايط التقدم */
.tt-bar-row {
  margin-bottom: 12px;
}
.tt-bar-row:last-child {
  margin-bottom: 0;
}
.tt-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--tt-tx);
}
.tt-bar-top span:last-child {
  color: var(--tt-mut);
  font-size: 12px;
}
.tt-bar {
  height: 8px;
  border-radius: 8px;
  background: var(--tt-bg2);
  overflow: hidden;
}
.tt-bar > div {
  height: 100%;
  border-radius: 8px;
  background: var(--tt-ac);
  transition: width 0.6s ease;
}
.tt-bar > div.ok {
  background: var(--tt-ok);
}
.tt-bar > div.mid {
  background: var(--tt-gold);
}
.tt-bar > div.bad {
  background: var(--tt-bad);
}

/* النصايح */
.tt-tip {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--tt-bd);
}
.tt-tip:first-of-type {
  border-top: none;
}
.tt-tip-i {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tt-ac-soft);
  color: var(--tt-ac-tx);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.tt-tip p {
  margin: 0 0 6px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--tt-tx);
}

/* مسار المستويات */
.tt-path {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 14px;
}
.tt-node {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 0;
  border-radius: 10px;
  background: var(--tt-bg2);
  color: var(--tt-mut);
  border: 1px solid var(--tt-bd);
}
.tt-node.past {
  background: var(--tt-ok-soft);
  color: var(--tt-ok);
  border-color: transparent;
}
.tt-node.now {
  background: var(--tt-ac);
  color: #fff;
  border-color: transparent;
}

/* الأسابيع */
.tt-week-h {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tt-week-n {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--tt-gold);
  color: var(--tt-on-gold);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* دفتر الأخطاء */
.tt-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tt-filters .tt-chip.on {
  background: var(--tt-ac);
  color: #fff;
}
.tt-mist {
  border: 1px solid var(--tt-bd);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--tt-bg2);
}
.tt-mist-q {
  font-size: 14px;
  font-weight: 800;
  margin: 8px 0;
  color: var(--tt-tx);
  line-height: 1.7;
}
.tt-ans {
  font-size: 13px;
  border-radius: 9px;
  padding: 7px 10px;
  margin-bottom: 6px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.tt-ans.bad {
  background: var(--tt-bad-soft);
  color: var(--tt-bad);
}
.tt-ans.ok {
  background: var(--tt-ok-soft);
  color: var(--tt-ok);
}
.tt-exp {
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--tt-mut);
  margin: 6px 0 8px;
}

/* الشات */
.tt-chat-box {
  max-height: 58vh;
  overflow-y: auto;
  padding: 4px 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tt-msg {
  max-width: 92%;
  font-size: 13.5px;
  line-height: 1.8;
  border-radius: 16px;
  padding: 10px 13px;
  overflow-wrap: anywhere;
}
.tt-msg.u {
  align-self: flex-start;
  background: var(--tt-ac);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.tt-msg.t {
  align-self: flex-end;
  background: var(--tt-bg2);
  border: 1px solid var(--tt-bd);
  color: var(--tt-tx);
  border-bottom-left-radius: 5px;
  width: 92%;
}
.tt-msg h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--tt-tx);
}
.tt-msg p {
  margin: 0 0 8px;
}
.tt-ex {
  background: var(--tt-card);
  border: 1px solid var(--tt-bd);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
.tt-ex b {
  color: var(--tt-ac-tx);
}
.tt-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.tt-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.tt-input {
  flex: 1;
  min-width: 0;
  background: var(--tt-bg2);
  color: var(--tt-tx);
  border: 1px solid var(--tt-bd);
  border-radius: 50px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.tt-input:focus {
  border-color: var(--tt-ac);
}
.tt-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--tt-gold);
  color: var(--tt-on-gold);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}
.tt-opt {
  display: block;
  width: 100%;
  text-align: start;
  background: var(--tt-card);
  color: var(--tt-tx);
  border: 1px solid var(--tt-bd);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.tt-opt.ok {
  background: var(--tt-ok-soft);
  border-color: var(--tt-ok);
  color: var(--tt-ok);
}
.tt-opt.bad {
  background: var(--tt-bad-soft);
  border-color: var(--tt-bad);
  color: var(--tt-bad);
}
.tt-empty {
  text-align: center;
  padding: 22px 12px;
  color: var(--tt-mut);
  font-size: 13.5px;
  line-height: 1.8;
}
.tt-empty i {
  display: block;
  font-size: 28px;
  color: var(--tt-ac);
  margin-bottom: 10px;
}

/* كارت الرئيسية */
.tt-home-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--tt-card);
  border: 1px solid var(--tt-bd);
  border-right: 4px solid var(--tt-ac);
  border-radius: 18px;
  padding: 14px 16px;
  margin: 0 0 20px;
  cursor: pointer;
  color: var(--tt-tx);
}
.tt-home-ic {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--tt-ac);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.tt-home-b {
  flex: 1;
  min-width: 0;
}
.tt-home-b strong {
  display: block;
  font-size: 15px;
  margin-bottom: 3px;
}
.tt-home-b span {
  display: block;
  font-size: 12.5px;
  color: var(--tt-mut);
  line-height: 1.6;
}

@media (max-width: 768px) {
  .tt-hdr-btn {
    display: none !important;
  }
}
@media (max-width: 520px) {
  .tt-card {
    padding: 13px;
  }
  .tt-tab {
    font-size: 11.5px;
  }
  .tt-msg {
    max-width: 96%;
  }
  .tt-msg.t {
    width: 96%;
  }
}

/* إضافات الشات الموسّع */
.tt-chip {
  max-width: 100%;
  text-align: start;
  line-height: 1.5;
}
button.tt-chip {
  white-space: normal;
}
.tt-chip i {
  font-size: 11px;
}
.tt-ex .tt-sub {
  display: inline-block;
  margin-top: 4px;
}

/* ── AI layer (ai-engine.js): feedback + exercise ── */
.ai-fb{margin-top:10px;display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.ai-fb .tt-chip{cursor:pointer;min-height:36px}
.ai-ex{margin:8px 0}
