:root {
  --teal: #0F6E56;
  --teal-light: #1D9E75;
  --teal-pale: #E1F5EE;
  --teal-mid: #5DCAA5;
  --blue: #185FA5;
  --blue-pale: #E6F1FB;
  --amber: #BA7517;
  --amber-pale: #FAEEDA;
  --purple: #534AB7;
  --purple-pale: #EEEDFE;
  --red: #C0392B;
  --red-pale: #FDEDEC;
  --green: #3B6D11;
  --green-pale: #EAF3DE;
  --gray-100: #F5F4F0;
  --gray-200: #E8E7E2;
  --gray-400: #A8A7A1;
  --gray-600: #6B6A66;
  --gray-900: #1C1B18;
  --white: #FFFFFF;
  --bg: #F0EFEB;
  --border: rgba(28,27,24,0.1);
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--gray-900);
  overflow: hidden;
  /* iOS standalone safe-area */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, .syne, .logo { font-family: 'Syne', system-ui, sans-serif; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ============ APP SHELL (mobile-first, scales to desktop) ============ */
.app-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: auto;
}

/* On mobile, fill viewport. On desktop, frame as phone-like card. */
.app-window {
  width: 100%;
  height: 100%;
  max-width: none;
  background: var(--white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

@media (min-width: 720px) {
  .app-root {
    padding: 24px;
    background:
      radial-gradient(circle at 20% 0%, #E1F5EE 0%, transparent 40%),
      radial-gradient(circle at 100% 80%, #E6F1FB 0%, transparent 50%),
      var(--bg);
  }
  .app-window {
    width: min(100%, 1180px);
    height: min(100%, 820px);
    max-height: 880px;
    border-radius: 24px;
    border: 1px solid var(--gray-200);
    box-shadow: 0 30px 80px -30px rgba(15,110,86,0.25), 0 8px 24px rgba(0,0,0,0.04);
    display: grid;
    grid-template-columns: 260px 1fr;
  }
}

/* Tablet portrait (iPad-like, between phone and laptop) */
@media (min-width: 600px) and (max-width: 1023px) {
  .app-window {
    grid-template-columns: 220px 1fr;
  }
}

/* When running as installed standalone PWA, drop the desktop "frame" — fill screen */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .app-root { padding: 0; background: var(--bg); }
  .app-window {
    width: 100% !important;
    height: 100% !important;
    max-height: none;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
}

/* ============ DESKTOP SIDEBAR ============ */
.sidebar { display: none; }

@media (min-width: 720px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0F6E56 0%, #134A3D 100%);
    color: #fff;
    padding: 22px 18px 18px;
    gap: 4px;
  }
  .sidebar .brand { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; padding: 4px 8px 18px; }
  .sidebar .brand span { color: var(--teal-mid); }
  .sidebar .nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 12px; border-radius: 10px;
    font-size: 13px; color: rgba(255,255,255,0.78);
    cursor: pointer; transition: background .15s, color .15s;
    border: none; background: transparent; text-align: left;
  }
  .sidebar .nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
  .sidebar .nav-item.active { background: rgba(255,255,255,0.13); color: #fff; }
  .sidebar .nav-item svg { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }
  .sidebar .nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 12px 0; }
  .sidebar .footer {
    margin-top: auto;
    padding: 12px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    line-height: 1.55;
  }
  .sidebar .footer strong { color: #fff; }
  .sidebar .streak-pill {
    display:flex; align-items:center; gap:8px;
    padding: 10px 12px; border-radius: 10px;
    background: rgba(255,255,255,0.08);
    margin-top: 8px; font-size: 12px;
  }
  .main-area { display: flex; flex-direction: column; overflow: hidden; }
}

/* ============ MOBILE TOP BAR + BOTTOM NAV ============ */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--white);
  flex-shrink: 0;
}
.top-bar .logo-mark {
  font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700;
  color: var(--gray-900);
}
.top-bar .logo-mark span { color: var(--teal-light); }
.top-bar .title { font-size: 14px; font-weight: 500; }
.top-bar .back {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--gray-600);
  background: none; border: none; padding: 0;
}
.top-bar .actions { display: flex; gap: 8px; align-items: center; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal-pale); display: flex;
  align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--teal);
  cursor: pointer;
}

@media (min-width: 720px) {
  .top-bar { padding: 16px 28px; }
  .top-bar .logo-mark { display: none; }
}

.content-scroll {
  flex: 1;
  overflow-y: auto;
  background: var(--gray-100);
  padding: 16px 18px 24px;
  -webkit-overflow-scrolling: touch;
}
.content-scroll.flat { padding: 0; }
@media (min-width: 720px) {
  .content-scroll { padding: 24px 32px; }
}

.bottom-nav {
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--gray-200);
  background: var(--white);
  flex-shrink: 0;
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 12px; border-radius: 10px; cursor: pointer;
  background: none; border: none; min-width: 56px;
}
.bn-item.active { background: var(--teal-pale); }
.bn-item svg { width: 19px; height: 19px; stroke: var(--gray-400); fill: none; stroke-width: 2; }
.bn-item.active svg { stroke: var(--teal); }
.bn-lbl { font-size: 10px; color: var(--gray-400); }
.bn-item.active .bn-lbl { color: var(--teal); font-weight: 500; }

@media (min-width: 720px) {
  .bottom-nav { display: none; }
}

/* ============ COMPONENTS ============ */
.card {
  background: var(--white); border-radius: var(--radius);
  padding: 14px 16px; border: 1px solid var(--gray-200);
}
.card + .card { margin-top: 8px; }
.card.accent { border-color: var(--teal-mid); border-width: 2px; }

.sec-label {
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--gray-400);
  margin: 18px 0 8px;
}
.sec-label:first-child { margin-top: 0; }

.badge {
  display: inline-block; font-size: 10px; font-weight: 500;
  padding: 3px 9px; border-radius: 5px;
}
.b-green { background: var(--green-pale); color: var(--green); }
.b-teal { background: var(--teal-pale); color: var(--teal); }
.b-blue { background: var(--blue-pale); color: var(--blue); }
.b-amber { background: var(--amber-pale); color: var(--amber); }
.b-purple { background: var(--purple-pale); color: var(--purple); }
.b-red { background: var(--red-pale); color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 16px; font-size: 14px; font-weight: 500;
  border-radius: var(--radius); border: none;
  background: var(--teal-light); color: #fff; cursor: pointer;
  transition: transform .08s, opacity .15s, background .15s;
  width: 100%;
}
.btn:active { transform: scale(0.985); }
.btn:hover { background: var(--teal); }
.btn.secondary { background: transparent; color: var(--gray-900); border: 1px solid var(--gray-200); }
.btn.secondary:hover { background: var(--gray-100); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid #F0997B; }
.btn.danger:hover { background: var(--red-pale); }
.btn.small { padding: 9px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn + .btn { margin-top: 8px; }

.pbar-bg { background: var(--gray-200); border-radius: 4px; height: 8px; width: 100%; }
.pbar { height: 8px; border-radius: 4px; background: var(--teal-light); transition: width .4s; }
.pbar.red { background: var(--red); }
.pbar.amber { background: var(--amber); }

.input-field {
  width: 100%; padding: 12px 14px; font-size: 14px;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  background: var(--gray-100); color: var(--gray-900); outline: none;
  transition: border .15s, background .15s;
}
.input-field:focus { border-color: var(--teal-mid); background: var(--white); }
.input-field.err { border-color: #F0997B; background: var(--red-pale); }

.label { font-size: 12px; color: var(--gray-600); margin-bottom: 6px; display: block; }

.alert { border-radius: var(--radius); padding: 12px 14px; font-size: 12.5px; line-height: 1.55; }
.alert-red { background: var(--red-pale); color: var(--red); border: 1px solid #F0997B; }
.alert-teal { background: var(--teal-pale); color: var(--teal); border: 1px solid var(--teal-mid); }
.alert-blue { background: var(--blue-pale); color: var(--blue); border: 1px solid #85B7EB; }
.alert-amber { background: var(--amber-pale); color: var(--amber); border: 1px solid #EF9F27; }
.alert-title { font-weight: 600; margin-bottom: 3px; }

/* Progress card */
.progress-card {
  background: linear-gradient(135deg, #E1F5EE 0%, #C8EBDC 100%);
  border-radius: var(--radius-lg); padding: 16px 18px;
}
.pc-label { font-size: 12px; color: var(--teal); margin-bottom: 2px; font-weight: 500; }
.pc-module { font-size: 18px; font-weight: 600; font-family: 'Syne', sans-serif; color: var(--teal); margin-bottom: 10px; }
.pc-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--teal); margin-top: 6px; }

/* Module rows */
.mod-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--white);
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  cursor: pointer; transition: transform .08s, border-color .15s;
  text-align: left; width: 100%; font: inherit;
}
.mod-row:hover { border-color: var(--teal-mid); }
.mod-row:active { transform: scale(0.99); }
.mod-row + .mod-row { margin-top: 8px; }
.mod-row.active { border-color: var(--teal-mid); border-width: 1.5px; background: var(--white); }
.mod-row.locked { opacity: 0.55; cursor: default; }
.mod-row.locked:hover { border-color: var(--gray-200); }
.mod-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.mod-info { flex: 1; min-width: 0; }
.mod-name { font-size: 13.5px; font-weight: 500; color: var(--gray-900); }
.mod-sub { font-size: 11px; color: var(--gray-400); margin-top: 1px; }
.mod-badge {
  font-size: 11px; padding: 3px 9px; border-radius: 5px; font-weight: 500;
}

/* Quiz */
.qopt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--gray-200);
  background: var(--white); font-size: 13px;
  cursor: pointer; transition: all .15s;
  text-align: left; width: 100%; color: var(--gray-900); line-height: 1.5;
}
.qopt:hover:not(:disabled) { border-color: var(--teal-mid); background: var(--teal-pale); }
.qopt + .qopt { margin-top: 7px; }
.qopt:disabled { cursor: default; }
.qopt-letter {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gray-100); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.qopt.correct { background: var(--green-pale); border-color: #97C459; color: var(--green); }
.qopt.correct .qopt-letter { background: #97C459; color: #fff; }
.qopt.wrong { background: var(--red-pale); border-color: #F0997B; color: var(--red); }
.qopt.wrong .qopt-letter { background: #F0997B; color: #fff; }
.qopt.dim { opacity: 0.45; }

.qexpl {
  background: var(--teal-pale); border-radius: 10px;
  padding: 11px 13px; margin-top: 10px;
  font-size: 12px; color: var(--teal); line-height: 1.55;
}

/* Quiz progress dots */
.dots { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gray-200); }
.dot.ok { background: var(--teal-light); }
.dot.bad { background: var(--red); }
.dot.cur { background: var(--blue); transform: scale(1.25); }

/* Tabs */
.tab-row { display: flex; gap: 6px; margin-bottom: 14px; background: var(--gray-200); padding: 4px; border-radius: 12px; }
.tab-btn {
  flex: 1; padding: 8px 10px; font-size: 12.5px; font-weight: 500;
  border-radius: 8px; border: none; background: transparent; color: var(--gray-600);
  cursor: pointer; transition: all .15s;
}
.tab-btn.active { background: var(--white); color: var(--gray-900); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }

/* Metrics */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.metric-card {
  background: var(--white); border-radius: var(--radius);
  padding: 13px; text-align: center;
  border: 1px solid var(--gray-200);
}
.metric-val { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; }
.metric-lbl { font-size: 10px; color: var(--gray-400); margin-top: 3px; }

/* Chat */
.chat-area { display: flex; flex-direction: column; padding: 16px 18px; flex: 1; overflow-y: auto; gap: 4px; background: var(--gray-100); }
.ia-label { font-size: 10px; color: var(--gray-400); margin-bottom: 2px; }
.ia-bubble, .user-bubble {
  padding: 11px 13px; font-size: 13px; line-height: 1.55;
  max-width: 85%; margin-bottom: 6px;
}
.ia-bubble {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 14px 14px 14px 4px; color: var(--gray-900);
}
.user-bubble {
  background: var(--teal-light); color: #fff;
  border-radius: 14px 14px 4px 14px; align-self: flex-end;
}
.chat-input-row {
  display: flex; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--gray-200); background: var(--white);
  align-items: center;
}
.chat-input {
  flex: 1; padding: 11px 16px; font-size: 13px;
  border: 1px solid var(--gray-200); border-radius: 100px;
  background: var(--gray-100); outline: none;
}
.chat-input:focus { background: var(--white); border-color: var(--teal-mid); }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--teal-light); border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.5; }

.suggest-chip {
  font-size: 12px; padding: 6px 11px; border-radius: 100px;
  border: 1px solid var(--gray-200); background: var(--white); color: var(--gray-600);
  cursor: pointer;
}
.suggest-chip:hover { background: var(--teal-pale); color: var(--teal); border-color: var(--teal-mid); }

/* Device rows */
.device-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--gray-200);
  border-radius: var(--radius); background: var(--white);
}
.device-row + .device-row { margin-top: 8px; }
.device-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.s-dot { width: 8px; height: 8px; border-radius: 50%; }
.s-dot.green { background: var(--teal-light); }
.s-dot.gray { background: var(--gray-200); }

/* Auth screen */
.auth-shell {
  flex: 1; display: flex; flex-direction: column;
  padding: 40px 28px 24px; background: var(--gray-100);
  overflow-y: auto;
}
@media (min-width: 720px) {
  .auth-shell { padding: 60px 80px; max-width: 520px; margin: 0 auto; width: 100%; justify-content: center; }
}
.auth-logo-block { text-align: center; margin-bottom: 36px; }
.auth-logo {
  width: 64px; height: 64px; border-radius: 18px; background: var(--teal-pale);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}

/* Streak / Duolingo-ish */
.streak-card {
  background: linear-gradient(135deg, #FAEEDA 0%, #F0D49C 100%);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
}
.streak-flame {
  width: 48px; height: 48px; border-radius: 14px;
  background: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.streak-num { font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 700; color: var(--amber); line-height: 1; }
.streak-lbl { font-size: 11px; color: var(--amber); margin-top: 2px; font-weight: 500; }

.streak-week {
  display: flex; justify-content: space-between; margin-top: 10px;
}
.streak-day {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 10px; color: var(--gray-400);
}
.streak-day .ball {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.streak-day.done .ball { background: var(--teal-light); color: #fff; }
.streak-day.today .ball { background: var(--amber); color: #fff; outline: 3px solid var(--amber-pale); }

/* Reminder banner */
.duo-banner {
  background: linear-gradient(135deg, #1D9E75 0%, #0F6E56 100%);
  color: #fff; border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; gap: 14px; align-items: center;
}
.duo-banner .icon-circle {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 22px;
}
.duo-banner h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.duo-banner p { font-size: 12px; opacity: 0.92; line-height: 1.5; }
.duo-banner .x-btn {
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  flex-shrink: 0;
}

/* Toast */
.toast-root {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; z-index: 200;
}
@media (min-width: 720px) {
  .toast-root { bottom: 24px; right: 24px; left: auto; align-items: flex-end; }
}
.toast {
  background: var(--gray-900); color: #fff;
  padding: 12px 16px; border-radius: 12px; font-size: 13px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  max-width: 320px; pointer-events: auto;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } }

/* Modal */
.modal-root {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  max-width: 360px; width: 100%;
  animation: scaleIn .25s ease;
}
@keyframes scaleIn { from { transform: scale(0.96); opacity: 0; } }
.modal-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; font-family: 'Syne', sans-serif; }
.modal-card p { font-size: 13px; color: var(--gray-600); line-height: 1.55; margin-bottom: 14px; }

/* Install card */
.install-card {
  background: var(--white); border-radius: var(--radius);
  padding: 14px 16px; border: 1px dashed var(--teal-mid);
  display: flex; align-items: center; gap: 14px;
}
.install-card .icon-square {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--teal-pale); color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Ladder + Guide rows */
.ladder-row, .guide-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--gray-200); background: var(--white);
}
.ladder-row + .ladder-row, .guide-row + .guide-row { margin-top: 7px; }
.ladder-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.guide-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}

/* Copy box */
.copy-box {
  background: rgba(255,255,255,0.7); border: 1.5px dashed var(--teal-mid);
  border-radius: var(--radius); padding: 12px;
  text-align: center; font-family: 'Syne', sans-serif;
  font-size: 18px; font-weight: 700; color: var(--teal);
  letter-spacing: .1em; margin-bottom: 10px; cursor: pointer;
}

/* Chain steps */
.chain-step { display: flex; gap: 12px; align-items: flex-start; }
.chain-step + .chain-step { margin-top: 12px; }
.chain-dot-big {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0; color: #fff;
}

/* Outline schema */
.node-box {
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 10px; padding: 9px 12px; font-size: 11px; text-align: center;
}
.arrow-d { text-align: center; font-size: 14px; color: var(--gray-400); margin: 3px 0; }

/* misc */
.hr { height: 1px; background: var(--gray-200); margin: 14px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.small { font-size: 11px; }
.muted { color: var(--gray-400); }
.text-teal { color: var(--teal); }
.text-red { color: var(--red); }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }

/* Headings reused */
.h1 { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; }
.h2 { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 600; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.spinner.dark { border: 2px solid rgba(0,0,0,0.1); border-top-color: var(--gray-600); }
@keyframes spin { to { transform: rotate(360deg); } }

/* References */
.ref-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--gray-200); align-items: flex-start; }
.ref-row:last-child { border-bottom: none; }
.ref-dot-sm { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

/* Question palette */
.suggest-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* Scrollbars */
.content-scroll::-webkit-scrollbar, .chat-area::-webkit-scrollbar { width: 6px; }
.content-scroll::-webkit-scrollbar-thumb, .chat-area::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* ============ THEORY CONTENT (markdown) ============ */
.theory-page { background: var(--white); }
.theory-content {
  font-size: 14.5px; line-height: 1.65; color: var(--gray-900);
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
}
.theory-content h1, .theory-content h2, .theory-content h3, .theory-content h4 {
  font-family: 'Syne', sans-serif;
  color: var(--gray-900);
  margin: 1.2em 0 0.5em;
  line-height: 1.25;
}
.theory-content > h1:first-child,
.theory-content > h2:first-child,
.theory-content > h3:first-child { margin-top: 0; }
.theory-content h1 { font-size: 22px; font-weight: 700; }
.theory-content h2 { font-size: 18px; font-weight: 600; color: var(--teal); }
.theory-content h3 { font-size: 15.5px; font-weight: 600; color: var(--teal); }
.theory-content h4 { font-size: 14px; font-weight: 600; }
.theory-content p { margin: 0 0 0.85em; }
.theory-content ul, .theory-content ol { margin: 0 0 0.85em; padding-left: 22px; }
.theory-content li { margin-bottom: 4px; }
.theory-content strong { color: var(--gray-900); font-weight: 600; }
.theory-content code {
  background: var(--gray-100); padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em;
}
.theory-content blockquote {
  border-left: 3px solid var(--teal-mid);
  background: var(--teal-pale);
  margin: 0.8em 0;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  color: var(--teal);
  font-size: 13.5px;
}
.theory-content blockquote p { margin: 0; }
.theory-content a { color: var(--teal); text-decoration: underline; }
.theory-content table {
  width: 100%; border-collapse: collapse;
  margin: 0.5em 0 1em;
  font-size: 13px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}
.theory-content thead { background: var(--gray-100); }
.theory-content th, .theory-content td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
  vertical-align: top;
}
.theory-content th { font-weight: 600; font-family: 'Syne', sans-serif; }
.theory-content tr:last-child td { border-bottom: none; }

.theory-actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 18px;
}

/* ============ SECURITY: WATERMARK ============ */
#ad-watermark {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
  user-select: none;
  mix-blend-mode: multiply;
  opacity: 0.08;
}
@media (prefers-color-scheme: dark) {
  #ad-watermark { mix-blend-mode: screen; opacity: 0.12; }
}

/* Anti-screenshot privacy curtain (when tab loses focus) */
#ad-curtain {
  position: fixed; inset: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #0F6E56 0%, #134A3D 100%);
  color: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  font-family: 'Syne', sans-serif;
  text-align: center;
  padding: 30px;
}
#ad-curtain .lock-circle {
  width: 70px; height: 70px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
}
#ad-curtain .title { font-size: 22px; font-weight: 700; }
#ad-curtain .sub { font-size: 13px; opacity: 0.8; font-family: 'DM Sans', sans-serif; max-width: 320px; line-height: 1.5; }

/* Disable native selection except in inputs/textareas */
body.locked-selection,
body.locked-selection * {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}
body.locked-selection input,
body.locked-selection textarea,
body.locked-selection [contenteditable="true"] {
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* Hide content from print */
@media print {
  body * { visibility: hidden !important; }
  body::after {
    content: "AcademiaDental — La impresión está deshabilitada por seguridad.";
    visibility: visible !important;
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Syne', sans-serif; font-size: 18px; color: #0F6E56;
  }
}
