/* ========== AI TUTOR (tutor.html) ========== */

.tutor-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 120px 16px 40px;
}

/* ---------- Header ---------- */
.tutor-head { text-align: center; margin-bottom: 26px; }
.tutor-tag {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 30px;
  border: 1px solid var(--brand-primary);
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.tutor-head h1 { font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1.15; margin-bottom: 10px; }
.tutor-head h1 .accent { color: var(--brand-primary); }
.tutor-head p { color: var(--text-muted); line-height: 1.6; max-width: 620px; margin: 0 auto; }

.level-pick {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tutor-page select,
.tutor-page input[type="text"],
.tutor-page textarea {
  font: inherit;
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.tutor-page select { padding: 8px 10px; }
.tutor-page input[type="text"]:focus,
.tutor-page textarea:focus,
.tutor-page select:focus { border-color: var(--brand-primary); outline: none; }

/* ---------- Tabs ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}
.tabs button {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: 13px;
  padding: 12px 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tabs button:hover { color: var(--text-light); }
.tabs button[aria-selected="true"] {
  color: #04121a;
  background: var(--brand-primary);
  box-shadow: 0 6px 22px var(--brand-glow);
}

/* ---------- Panels ---------- */
.panel {
  padding: 0;
  border-radius: 22px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.panel[hidden] { display: none; }
.muted { color: var(--text-muted); line-height: 1.6; }
.label { color: var(--text-muted); font-size: 0.9rem; margin: 18px 0 8px; }

/* ---------- Chips & small buttons ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chip {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 30px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.chip:hover { border-color: var(--brand-primary); }
.chip.on { border-color: var(--brand-primary); background: rgba(0, 212, 255, 0.12); color: var(--brand-primary); }

.link-btn {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px 4px;
}
.link-btn:hover { color: var(--brand-primary); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--brand-primary); }

.send {
  font: inherit;
  font-weight: 700;
  color: #04121a;
  background: var(--brand-primary);
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, opacity 0.2s;
}
.send:hover { transform: translateY(-1px); }
.send:disabled { opacity: 0.5; cursor: wait; transform: none; }
.send.big { display: block; margin: 24px auto 0; padding: 14px 34px; font-size: 1rem; border-radius: 16px; }

.icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  font-size: 1.15rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-light);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand-primary); }
.icon-btn.listening {
  background: #ff3b5c;
  border-color: #ff3b5c;
  animation: pulse 1.2s infinite;
}
.icon-btn.big-mic { width: 50px; height: 50px; font-size: 1.35rem; border-radius: 50%; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 92, 0.6); }
  100% { box-shadow: 0 0 0 14px rgba(255, 59, 92, 0); }
}

.input-row { display: flex; gap: 8px; align-items: flex-end; }
.input-row textarea,
.input-row input[type="text"] { flex: 1; resize: none; max-height: 160px; line-height: 1.45; }

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 6px 8px 6px 12px;
  border-radius: 10px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid var(--border-glow);
  margin-bottom: 8px;
  max-width: 100%;
}
.file-chip[hidden] { display: none; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { background: none; border: 0; color: var(--text-muted); cursor: pointer; font-size: 1rem; }

/* ---------- Chat ---------- */
.chat {
  height: min(58vh, 560px);
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.empty { margin: auto; text-align: center; max-width: 520px; padding: 10px; }
.empty-icon { font-size: 2.4rem; margin-bottom: 8px; }
.empty h3 { margin-bottom: 8px; }
.empty p { color: var(--text-muted); line-height: 1.6; font-size: 0.95rem; }

.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg.user { flex-direction: row-reverse; }
.avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.08);
}
.bubble {
  position: relative;
  max-width: min(85%, 720px);
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}
.msg.bot .bubble { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); border-top-left-radius: 4px; }
.msg.user .bubble { background: rgba(0, 212, 255, 0.14); border: 1px solid var(--border-glow); border-top-right-radius: 4px; white-space: pre-wrap; }
.bubble .attach { display: block; font-size: 0.8rem; color: var(--brand-primary); margin-bottom: 4px; }
.bubble-tools { display: flex; gap: 6px; margin-top: 8px; }
.bubble-tools button {
  font: inherit;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 3px 8px;
  cursor: pointer;
}
.bubble-tools button:hover { color: var(--brand-primary); border-color: var(--border-glow); }

.typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.error-msg {
  align-self: center;
  font-size: 0.88rem;
  color: #ffb4c0;
  background: rgba(255, 59, 92, 0.1);
  border: 1px solid rgba(255, 59, 92, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
}

/* Rendered markdown */
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p, .rich ul, .rich ol, .rich table, .rich pre, .rich blockquote { margin: 0 0 10px; }
.rich ul, .rich ol { padding-left: 22px; }
.rich li { margin-bottom: 4px; }
.rich h1, .rich h2, .rich h3, .rich h4 { font-size: 1.02rem; margin: 14px 0 8px; color: var(--brand-primary); }
.rich code { background: rgba(255, 255, 255, 0.08); padding: 1px 5px; border-radius: 5px; font-size: 0.88em; }
.rich pre { background: #02040c; padding: 12px; border-radius: 10px; overflow-x: auto; }
.rich pre code { background: none; padding: 0; }
.rich table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.rich th, .rich td { border: 1px solid rgba(255, 255, 255, 0.16); padding: 5px 12px; text-align: center; }
.rich th { background: rgba(255, 255, 255, 0.06); }
.rich blockquote { border-left: 3px solid var(--brand-primary); padding-left: 12px; color: var(--text-muted); }
.rich hr { border: 0; border-top: 1px solid rgba(255, 255, 255, 0.1); margin: 12px 0; }
.rich .katex-display { margin: 8px 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* ---------- Composer ---------- */
.composer { border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 12px 14px 14px; background: rgba(0, 0, 0, 0.18); }
.composer-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.composer-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 8px; }
.composer-top .composer-opts { margin-top: 0; }
.modes { display: flex; flex-wrap: wrap; gap: 6px; }
.mode {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
}
.mode.on { color: var(--brand-primary); border-color: var(--brand-primary); background: rgba(0, 212, 255, 0.1); }

/* ---------- Live class ---------- */
.class-setup, .lang-setup { padding: 34px 20px; text-align: center; }
.class-setup h3, .lang-setup h3 { font-size: 1.35rem; margin-bottom: 8px; }
.class-setup .muted, .lang-setup .muted { max-width: 560px; margin: 0 auto; }
.class-form { display: flex; gap: 8px; max-width: 640px; margin: 22px auto 10px; }
.class-form input { flex: 1; }

.classroom { padding: 16px; }
.class-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.class-title h3 { font-size: 1.1rem; }

.board {
  position: relative;
  min-height: 300px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 22px 22px 26px;
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 255, 255, 0.05), transparent 60%),
    #17312a;
  border: 10px solid #5b3d23;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45), 0 10px 30px rgba(0, 0, 0, 0.4);
  font-family: 'Kalam', 'Inter', cursive;
  color: #f4f1e8;
  font-size: 1.15rem;
  line-height: 1.6;
  scroll-behavior: smooth;
}
.board .katex { font-size: 1.12em; color: #fffdf6; }
.board-line {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 8px;
  opacity: 0.55;
  transition: opacity 0.3s, background 0.3s;
}
.board-line.current { opacity: 1; background: rgba(255, 255, 255, 0.05); }
.board-line.done { opacity: 0.85; }
.board-line .num { flex: 0 0 auto; font-size: 0.85rem; color: #ffd36b; min-width: 20px; }
.board-line .content { flex: 1; min-width: 0; overflow-x: auto; }
.board-line .content > * { margin: 0; }
.board-line .content p + p { margin-top: 4px; }
.board-line .content table { margin: 4px 0; }
.board-line .content th, .board-line .content td { border-color: rgba(244, 241, 232, 0.35); }
.board-line.write .content { animation: write-in 0.7s ease-out; }
@keyframes write-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
.board-note {
  margin: 6px 0 6px 32px;
  padding: 8px 12px;
  border-left: 3px solid #ffd36b;
  border-radius: 6px;
  background: rgba(255, 211, 107, 0.08);
  color: #ffe9b0;
  font-size: 1.02rem;
}
.board-note .who { font-family: 'Inter', sans-serif; font-size: 0.75rem; font-weight: 700; color: #ffd36b; display: block; margin-bottom: 2px; }
.board-note.right { border-left-color: #6ee7a8; background: rgba(110, 231, 168, 0.08); color: #c9f7dc; }
.board-note.right .who { color: #6ee7a8; }
.board-empty { text-align: center; opacity: 0.7; padding-top: 90px; }

.caption {
  min-height: 52px;
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.55;
  font-size: 0.95rem;
}
.caption .who { color: var(--brand-primary); font-weight: 700; margin-right: 6px; }

.turn {
  margin: 12px 0;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 211, 107, 0.5);
  background: rgba(255, 211, 107, 0.07);
}
.turn[hidden] { display: none; }
.turn.hand { border-color: var(--border-glow); background: rgba(0, 212, 255, 0.07); }
.turn-head { margin-bottom: 6px; }
.turn p { margin-bottom: 10px; line-height: 1.5; }
.turn .link-btn { margin-top: 6px; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ctl {
  font: inherit;
  font-size: 1.05rem;
  min-width: 46px;
  height: 46px;
  padding: 0 12px;
  border-radius: 14px;
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
}
.ctl:hover { border-color: var(--brand-primary); }
.ctl:disabled { opacity: 0.4; cursor: default; }
.ctl.main { background: var(--brand-primary); color: #04121a; border: 0; font-size: 1.15rem; }
.ctl.hand-btn { font-size: 0.95rem; font-weight: 700; border-color: rgba(255, 211, 107, 0.6); color: #ffd36b; }
.ctl.hand-btn.raised { background: #ffd36b; color: #241a05; }
.ctl-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-left: auto; }

.progress { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); margin-top: 14px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--brand-primary); transition: width 0.4s; }

/* ---------- Languages ---------- */
.lang-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 640px; margin: 24px auto 0; text-align: left; }
.lang-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--text-muted); }
.lang-room { display: flex; flex-direction: column; }
.lang-room .class-title { padding: 14px 16px 0; margin-bottom: 0; }
.lang-room .chat { height: min(56vh, 540px); }

.tr { display: block; margin-top: 6px; font-size: 0.85rem; color: var(--text-muted); font-style: italic; }
.tr[hidden] { display: none; }
.fixes {
  align-self: flex-end;
  max-width: min(85%, 640px);
  margin-top: -6px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.86rem;
  background: rgba(255, 211, 107, 0.07);
  border: 1px solid rgba(255, 211, 107, 0.35);
}
.fixes.ok { background: rgba(110, 231, 168, 0.07); border-color: rgba(110, 231, 168, 0.4); color: #c9f7dc; }
.fixes ul { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.fixes .wrong { color: #ff9fb0; text-decoration: line-through; }
.fixes .right { color: #6ee7a8; font-weight: 700; }
.fixes .why { display: block; color: var(--text-muted); }
.words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.words span {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid var(--border-glow);
}
.words b { color: var(--brand-primary); }
.tip { display: block; margin-top: 8px; font-size: 0.82rem; color: #ffe9b0; }

.tutor-note { text-align: center; color: #777; font-size: 0.82rem; line-height: 1.6; margin-top: 18px; }
.tutor-note a { color: var(--brand-primary); }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .tutor-wrap { padding-top: 100px; }
  .tabs button span { display: block; font-size: 0.8rem; margin-top: 2px; }
  .tabs button { padding: 10px 4px; }
  .chat { height: max(300px, calc(100svh - 330px)); padding: 14px 10px; }
  .lang-room .chat { height: max(280px, calc(100svh - 300px)); }
  .composer { padding: 10px; }
  .composer-top { margin-bottom: 8px; }
  .modes { flex-wrap: nowrap; overflow-x: auto; }
  .mode { flex: 0 0 auto; padding: 5px 10px; }
  .composer-top .composer-opts { justify-content: space-between; }
  .input-row { gap: 6px; }
  .icon-btn { width: 40px; height: 40px; }
  .send { padding: 10px 14px; }
  .bubble { max-width: 88%; }
  .avatar { display: none; }
  .class-form { flex-wrap: wrap; }
  .class-form input { flex-basis: 100%; }
  .class-form .send { flex: 1; }
  .board { border-width: 6px; padding: 14px 12px 18px; font-size: 1.02rem; min-height: 240px; }
  .board-note { margin-left: 12px; }
  .ctl-opts { margin-left: 0; width: 100%; justify-content: space-between; }
  .ctl.hand-btn span { display: none; }
  .lang-grid { grid-template-columns: 1fr; }
  .composer-top { flex-direction: column; align-items: stretch; }
  footer { padding: 40px 16px; }
}
