/* ── RESET & BASE ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  overflow-x: hidden;
  max-width: 100%;
}
body {
  font-family: 'Inter', 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── LAYOUT ───────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; max-width: 100%; overflow-x: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--ease-slow);
  padding: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.25rem 1.25rem 1.125rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.logo-icon { font-size: 22px; line-height: 1; }
.logo-text {
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  font-size: 17px;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0.5rem 0.625rem 0.75rem;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.2);
  padding: 1rem 0.75rem 0.3rem;
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), box-shadow var(--ease);
  text-decoration: none;
  user-select: none;
  position: relative;
}
.nav-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.8;
  transition: color var(--ease), opacity var(--ease);
}
.nav-item span { flex: 1; line-height: 1; }
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}
.nav-item:hover i { opacity: 1; }
.nav-item.active {
  background: var(--primary-subtle);
  color: rgba(255,255,255,0.95);
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav-item.active i { color: var(--primary-hover); opacity: 1; }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease-slow);
  backdrop-filter: blur(1px);
}
.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  align-items: center;
  padding: 0 0.75rem 0 1rem;
  gap: 0.875rem;
  z-index: 200;
}
.menu-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 17px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--ease), background var(--ease);
  flex-shrink: 0;
}
.menu-btn:hover { color: white; background: rgba(255,255,255,0.07); }
.topbar-title {
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  font-size: 16px;
  letter-spacing: -0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-streak { color: var(--warning); font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 2rem;
  min-height: 100vh;
  overflow-x: hidden;
}

.impersonation-banner {
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: .85rem 1rem;
  background: var(--primary-pale);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius);
  color: var(--text-primary);
}
.impersonation-banner-text {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
  font-size: .92rem;
}
.impersonation-banner-text i { color: var(--primary); }
.impersonation-banner-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page { display: none; }
.page.active { display: block; }

/* ── TYPOGRAPHY ───────────────────────────────────────────────────── */
.page-title {
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}
.page-subtitle { font-size: 14px; color: var(--text-secondary); font-weight: 400; margin-bottom: 1.75rem; }
.section-title {
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

/* ── CARDS ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-lg { border-radius: var(--radius-lg); }

/* ── FOCUS VISIBLE (global) ────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { border-radius: var(--radius-sm); }

/* ── GLOBAL SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }

/* ── GLOBAL PLACEHOLDER ────────────────────────────────────────── */
::placeholder { color: var(--text-muted); opacity: 1; }

/* ── SKELETON LOADER ───────────────────────────────────────────── */
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.skeleton { background: var(--surface-2); border-radius: var(--radius-sm); animation: skeleton-pulse 1.6s ease infinite; }
.skeleton-text { height: 14px; border-radius: 4px; }
.skeleton-title { height: 22px; border-radius: 4px; }
.skeleton-card { height: 120px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ── LOADING STATE ─────────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 4rem 2rem;
  color: var(--text-secondary); font-size: 14px;
}
.loading i { color: var(--primary); }

/* ── DASHBOARD ───────────────────────────────────────────────────── */
.dashboard-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.625rem 1.75rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.dashboard-hero .page-title { margin-bottom: 0.25rem; }
.dashboard-hero .page-subtitle { margin-bottom: 0; }
.dashboard-hero-action { flex-shrink: 0; }
.dashboard-section { margin-bottom: 1.75rem; }

/* ── DASHBOARD MODULE GRID (new) ───────────────────────────────── */
.dashboard-module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.dashboard-module-grid--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ── PREMIUM MODULE CARD (dmc-*) ───────────────────────────────── */
.dmc {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', 'DM Sans', sans-serif;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.18s;
  position: relative;
  width: 100%;
}
.dmc:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(108,116,220,0.2);
  transform: translateY(-2px);
}
.dmc:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.dmc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.dmc-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.dmc-arrow {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
  transition: background var(--ease), color var(--ease), transform var(--ease);
}
.dmc:hover .dmc-arrow {
  background: var(--primary-pale);
  color: var(--primary-hover);
  transform: translateX(2px);
}
.dmc-body { flex: 1; min-width: 0; }
.dmc-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 0.3rem;
}
.dmc-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}
.dmc-meta {
  display: inline-flex;
  align-items: center;
  background: var(--primary-pale);
  color: var(--primary-hover);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.025em;
  align-self: flex-start;
}

/* ── FEATURED CARD (Study Plan hub) ───────────────────────────────── */
.dmc-featured {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.375rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.dmc-featured::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
}
.dmc-featured:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.dmc-featured-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.dmc-featured-body { flex: 1; min-width: 0; }
.dmc-featured-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.dmc-featured-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}
.dmc-featured-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.dmc-featured-chips span {
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-pale);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.dmc-featured-arrow {
  color: var(--primary);
  font-size: 15px;
  flex-shrink: 0;
  transition: transform var(--ease);
}
.dmc-featured:hover .dmc-featured-arrow { transform: translateX(3px); }

@media (max-width: 640px) {
  .dmc-featured { flex-direction: column; align-items: flex-start; gap: 0.875rem; }
  .dmc-featured-arrow { display: none; }
}

/* Legacy card (preserved for compat) */
.dashboard-module-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr auto;
  align-items: start;
  gap: 0.8rem;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s, transform 0.15s;
}
.dashboard-module-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.dashboard-module-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dashboard-module-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--primary-light); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
}
.dashboard-module-body { min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.dashboard-module-title { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.dashboard-module-text { font-size: 13px; line-height: 1.35; color: var(--text-secondary); }
.dashboard-module-meta {
  grid-column: 2; align-self: end; width: fit-content;
  border-radius: 999px; background: var(--primary-pale); color: var(--primary-hover);
  padding: 0.2rem 0.55rem; font-size: 11px; font-weight: 600;
}
.dashboard-module-arrow {
  grid-column: 3; grid-row: 1 / span 2; align-self: center;
  color: var(--text-muted); font-size: 13px; transition: color var(--ease), transform var(--ease);
}
.dashboard-module-card:hover .dashboard-module-arrow { color: var(--primary); transform: translateX(2px); }

/* ── GRID ─────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ── BUTTONS ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:not(:disabled):active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-primary); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border-2); color: var(--text-primary); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-hover); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid transparent; }
.btn-success:hover { background: var(--success); color: white; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 15px; border-radius: var(--radius); }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 12px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── ICON BUTTONS ─────────────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text-primary);
}
.icon-btn--danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger-bg);
  color: var(--danger);
}

/* ── BADGE / PILL ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}
.badge-orange { background: var(--primary-light); color: var(--primary); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--text-secondary); }

/* ── PROGRESS BAR ─────────────────────────────────────────────────── */
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.4s ease; }
.progress-fill.success { background: var(--success); }

/* ── CATEGORY TABS ────────────────────────────────────────────────── */
.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1rem; }
.cat-tab {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.cat-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── SURVIVAL SCENARIO GRID ───────────────────────────────────────── */
.scenario-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--card);
  text-align: center;
}
.scenario-card:hover { border-color: var(--primary); background: var(--primary-light); }
.scenario-card.active { border-color: var(--primary); background: var(--primary-light); }
.scenario-card .sc-icon { font-size: 28px; margin-bottom: 6px; }
.scenario-card h4 { font-size: 13px; font-weight: 500; color: var(--text-primary); }

/* ── PHRASE LIST ITEMS ────────────────────────────────────────────── */
.phrase-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 6px;
  transition: border-color 0.12s;
}
.phrase-item:hover { border-color: var(--border-2); }
.phrase-item .pi-text .en { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.phrase-item .pi-text .pt { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 300; }
.phrase-item .pi-btn {
  background: var(--primary-light);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
  transition: background var(--ease), color var(--ease);
}
.phrase-item .pi-btn:hover { background: var(--primary); color: white; }

/* ── STAT CARDS ───────────────────────────────────────────────────── */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-card .stat-value { font-weight: 700; font-size: 26px; color: var(--text-primary); letter-spacing: -0.02em; }
.stat-card .stat-sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

/* ── INPUT FIELD ──────────────────────────────────────────────────── */
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-pale); }
.input-row input::placeholder { color: var(--text-muted); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── SPIN ANIMATION ───────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.fa-spin { animation: spin 1s linear infinite; }

/* ── EMPTY STATE ──────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 36px; margin-bottom: 0.75rem; display: block; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ── TOAST NOTIFICATIONS ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 320px;
  line-height: 1.4;
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--success); color: white; }
.toast--error { background: var(--danger); color: white; }
.toast--info { background: var(--primary); color: white; }

/* ── MODAL LAYOUT ─────────────────────────────────────────────────── */
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 1.75rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: 17px; color: var(--text-primary); }
.modal-body  { padding: 1.5rem 1.75rem; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 1.25rem 1.75rem; border-top: 1px solid var(--border);
  background: rgba(108,116,220,0.02);
}

/* ── FORM ─────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.form-input {
  width: 100%; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem; font-size: 14px; font-family: inherit;
  background: var(--surface-2); color: var(--text-primary); outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-pale); }
.form-input::placeholder { color: var(--text-muted); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ── AUDIO SECTION ────────────────────────────────────────────────── */
.audio-section {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; background: var(--surface-2);
}
.audio-section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1rem; gap: 8px;
}
.audio-tabs {
  display: flex; border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 1rem;
}
.audio-tab {
  flex: 1; padding: 0.55rem 0.5rem; background: var(--surface); border: none;
  border-right: 1px solid var(--border-2);
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: background var(--ease), color var(--ease);
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.audio-tab:last-child { border-right: none; }
.audio-tab.active { background: var(--primary); color: white; }
.audio-tab:hover:not(.active) { background: var(--surface-hover); color: var(--text-primary); }
.audio-panel { animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* ── DROP ZONE ────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-2); border-radius: var(--radius);
  padding: 2rem 1rem; text-align: center; cursor: pointer;
  transition: all 0.15s; background: var(--surface);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: var(--primary-pale); }
.drop-zone.has-file { border-style: solid; border-color: var(--success); background: var(--success-bg); }

/* ── SIDEBAR FOOTER ───────────────────────────────────────────────── */
.sidebar-footer {
  padding: 0.625rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex-shrink: 0;
}

.sidebar-theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.38);
  font-size: 12px;
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
}
.sidebar-theme-toggle i { font-size: 12px; flex-shrink: 0; }
.sidebar-theme-toggle:hover {
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.05);
  border-color: var(--sidebar-border);
}

.sidebar-streak {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(232,165,48,0.08);
  border: 1px solid rgba(232,165,48,0.15);
}
.streak-num {
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--warning);
  line-height: 1;
  min-width: 24px;
}
.streak-label {
  font-size: 11.5px;
  color: rgba(255,255,255,0.4);
  line-height: 1.3;
  flex: 1;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.45rem 0.625rem;
  border-radius: var(--radius-sm);
  transition: background var(--ease);
}
.sidebar-user:hover { background: rgba(255,255,255,0.04); }

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255,255,255,0.48);
  font-size: 12.5px;
  font-weight: 400;
  min-width: 0;
  overflow: hidden;
}
.sidebar-user-info i { font-size: 15px; flex-shrink: 0; }
.sidebar-user-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.28);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 13px;
  flex-shrink: 0;
  transition: color var(--ease), background var(--ease);
}
.sidebar-logout:hover { color: var(--danger); background: rgba(224,90,90,0.1); }

.sidebar-version {
  text-align: center;
  font-size: 10.5px;
  color: rgba(255,255,255,0.18);
  padding: 0 0.625rem 0.5rem;
  letter-spacing: 0.02em;
}

/* ── AUTH SCREEN ──────────────────────────────────────────────────── */
@keyframes auth-enter {
  from { opacity: 0; transform: translateY(14px) scale(0.984); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#auth-screen {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.75rem 2.25rem 2.25rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.1);
  animation: auth-enter 0.35s cubic-bezier(0.22,1,0.36,1) both;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 0.35rem;
}
.auth-logo-icon { font-size: 28px; }
.auth-logo-text {
  font-weight: 800;
  font-size: 22px;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.auth-tagline {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 1.75rem;
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 1.5rem;
  gap: 3px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
.auth-field input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.925rem;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.auth-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}
.auth-field input::placeholder { color: var(--text-muted); }

.auth-field-password {
  position: relative;
}
.auth-field-password input {
  padding-right: 2.75rem;
  width: 100%;
}
.auth-pwd-toggle {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.auth-pwd-toggle:hover { color: var(--text-secondary); }
.auth-pwd-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(224,90,90,0.2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-size: 13px;
  font-weight: 500;
}

.auth-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(61,190,122,0.2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-size: 13px;
  font-weight: 500;
}

.auth-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.825rem;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  box-shadow: 0 2px 8px rgba(108,116,220,0.28);
  margin-top: 0.125rem;
}
.auth-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 20px rgba(108,116,220,0.42);
  transform: translateY(-1px);
}
.auth-btn:active:not(:disabled) { transform: scale(0.99); box-shadow: none; }
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.auth-social {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.auth-social-label {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.auth-social-label::before,
.auth-social-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-social-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.auth-social-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.18s, background 0.18s, transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow-sm);
}
.auth-social-btn:hover {
  border-color: var(--border-2);
  background: var(--surface);
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
}
.auth-social-btn:active { transform: scale(0.94); }
.auth-social-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

/* ── Role selection toggle ────────────────────────────────────────── */
.auth-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.auth-role-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.auth-role-info-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-role-info-link:hover { color: var(--primary); }
.auth-role-toggle {
  display: flex;
  background: var(--surface-2, #1a1c27);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.auth-role-opt {
  flex: 1;
  padding: 7px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.auth-role-opt.active {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
}
.auth-role-opt:not(.active):hover { color: var(--text-primary); }

/* ── English levels ─────────────────────────────────────────────── */
.el-header,
.el-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.el-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
  max-width: 680px;
}
.el-band-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.el-band-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px;
}
.el-band-card span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}
.el-band-card strong {
  display: block;
  color: var(--text-primary);
  font-size: 15px;
  margin-top: 4px;
}
.el-band-card p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 6px;
}
.el-level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.el-level-card {
  display: grid;
  grid-template-columns: 82px 1fr 24px;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 156px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--level-color);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.el-level-card:hover {
  transform: translateY(-2px);
  border-color: var(--level-color);
  box-shadow: var(--shadow-md);
}
.el-level-code,
.el-detail-code {
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--level-color) 18%, transparent);
  color: var(--level-color);
  font-size: 28px;
  font-weight: 800;
}
.el-level-band,
.el-detail-copy span {
  color: var(--level-color);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.el-level-body h2,
.el-detail-copy h1 {
  color: var(--text-primary);
  font-size: 22px;
  margin: 4px 0 6px;
}
.el-level-body p,
.el-detail-copy p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}
.el-content-count {
  display: inline-block;
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 10px;
}
.el-detail-header {
  border: 1px solid var(--border);
  border-left: 5px solid var(--level-color);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
}
.el-detail-copy {
  flex: 1;
  min-width: 0;
}
.el-can-do {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.el-can-do div {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.35;
}
.el-can-do i {
  color: var(--success);
  margin-top: 2px;
}
.el-filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.el-category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.el-category-chips button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.el-category-chips button.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-pale);
}
.el-category-chips span {
  color: var(--text-muted);
  margin-left: 3px;
}
.el-content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.el-content-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px;
  min-height: 178px;
}
.el-content-card-top,
.el-content-meta,
.el-card-actions,
.el-form-footer,
.el-modal-actions,
.el-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}
.el-content-card-top {
  justify-content: space-between;
  margin-bottom: 10px;
}
.el-content-card-top span,
.el-draft {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 8px;
}
.el-content-card h3 {
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.3;
  margin-bottom: 7px;
}
.el-content-card p,
.el-content-card details {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}
.el-content-card summary {
  color: var(--primary);
  cursor: pointer;
  margin-top: 10px;
}
.el-content-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 12px;
}
.el-card-actions {
  justify-content: space-between;
  margin-top: 12px;
}
.el-empty {
  grid-column: 1 / -1;
}
.el-pagination {
  justify-content: center;
  color: var(--text-secondary);
  margin-top: 16px;
}
.el-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.el-form-footer {
  justify-content: space-between;
  margin-top: 10px;
}
.el-form-footer label {
  color: var(--text-secondary);
  font-size: 13px;
}
.el-form-footer .form-input {
  max-width: 120px;
}
.el-modal-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

/* ── Role info modal ──────────────────────────────────────────────── */
.role-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.role-modal-col {
  background: var(--surface-2, #1a1c27);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.role-modal-col-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.role-modal-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.role-modal-list li {
  font-size: 12px;
  color: var(--text-secondary);
  padding-left: 14px;
  position: relative;
  line-height: 1.45;
}
.role-modal-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}
.role-modal-notice {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .topbar { display: flex; }
  .main-content { margin-left: 0; padding: 1rem; padding-top: calc(var(--topbar-h) + 1rem); }
  .impersonation-banner { align-items: stretch; flex-direction: column; }
  .impersonation-banner-text span { white-space: normal; }
  .dashboard-hero { flex-direction: column; align-items: stretch; gap: 1rem; padding: 1.25rem; overflow: hidden; }
  .dashboard-hero > div { min-width: 0; }
  .sp-hero-actions { flex-shrink: 1; }
  .dashboard-hero-action { width: 100%; }
  .page-title { font-size: 21px; word-break: break-word; overflow-wrap: break-word; }
  .dashboard-module-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .el-header,
  .el-detail-header {
    align-items: stretch;
    flex-direction: column;
  }
  .el-band-grid,
  .el-level-grid,
  .el-can-do,
  .el-content-grid {
    grid-template-columns: 1fr;
  }
  .el-level-card {
    grid-template-columns: 64px 1fr;
    min-height: 0;
  }
  .el-level-card > i {
    display: none;
  }
  .el-level-code,
  .el-detail-code {
    width: 58px;
    height: 58px;
    font-size: 22px;
  }
  .el-filters,
  .el-form-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-module-grid--compact { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .cls-card-header,
  .cls-plan-section-head,
  .cls-plan-add {
    flex-direction: column;
    align-items: stretch;
  }
  .cls-member {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .auth-card { padding: 2rem 1.5rem; }
}

@media (max-width: 480px) {
  .dashboard-module-grid { grid-template-columns: 1fr; }
  .dmc { padding: 1rem; }
}

/* ── STUDY PLAN ───────────────────────────────────────────────────── */

/* Topic pills row */
.sp-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: none;
  margin-bottom: 1.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.sp-pills::-webkit-scrollbar { display: none; }
.sp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.sp-pill:hover { border-color: var(--border-2); color: var(--text-primary); }
.sp-pill--active { background: var(--primary-pale); border-color: var(--primary); color: var(--primary); }
.sp-pill-emoji { font-size: 14px; line-height: 1; }
.sp-pill-count {
  font-size: 11px;
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: 20px;
  color: var(--text-muted);
  font-weight: 600;
}
.sp-pill--active .sp-pill-count { background: var(--primary-subtle); color: var(--primary); }

/* Study plan hero actions */
.sp-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Topic header */
.sp-thdr {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 1.25rem;
}
.sp-thdr-emoji { font-size: 26px; line-height: 1.2; flex-shrink: 0; margin-top: 1px; }
.sp-thdr-body { flex: 1; min-width: 0; }
.sp-thdr-name { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0; line-height: 1.2; }
.sp-thdr-meta { font-size: 13px; color: var(--text-muted); margin: 3px 0 0; }
.sp-thdr-actions { display: flex; gap: 4px; flex-shrink: 0; padding-top: 2px; }

/* Practice CTA */
.sp-practice {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.375rem;
  margin-bottom: 1.75rem;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.sp-practice:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.sp-practice-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.sp-practice-body { flex: 1; min-width: 0; }
.sp-practice-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin: 0; }
.sp-practice-desc { font-size: 12px; color: var(--text-secondary); margin: 2px 0 0; }
.sp-practice-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.sp-practice-badge--ok { background: var(--success-bg); color: var(--success); }
.sp-practice-arrow { font-size: 13px; color: var(--primary); flex-shrink: 0; opacity: 0.6; }

/* Empty states */
.sp-empty-pills {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0.25rem 0 1.5rem;
}
.sp-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 2rem;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  min-height: 260px;
  gap: 8px;
}
.sp-detail-empty i { font-size: 30px; color: var(--text-muted); opacity: 0.25; }
.sp-detail-empty p { font-size: 14px; color: var(--text-secondary); margin: 0; }
.sp-detail-empty small { font-size: 12px; color: var(--text-muted); }

.sp-tabs {
  display: flex;
  gap: 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0;
  width: 100%;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.sp-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sp-tab:hover { color: var(--text-primary); background: none; }
.sp-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: none; }

/* ── STUDY PLAN — Words toolbar, filter, pagination ─────────────────── */
.sp-words-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.sp-words-actions { display: flex; gap: 8px; flex-shrink: 0; }
.sp-words-search-wrap {
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
  transition: border-color 0.15s;
}
.sp-words-search-wrap:focus-within {
  border-color: var(--primary);
  color: var(--primary);
}
.sp-words-search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  padding: 7px 0;
  width: 100%;
}
.sp-words-filters-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.sp-words-filter-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.sp-words-type-btn {
  padding: 4px 14px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.sp-words-type-btn:hover { border-color: var(--primary); color: var(--primary); }
.sp-words-type-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.sp-words-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-2);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.sp-words-audio-btn:hover { border-color: var(--primary); color: var(--primary); }
.sp-words-audio-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.sp-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.sp-pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.sp-pagination-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.sp-pagination-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.sp-pagination-info { font-size: 13px; font-weight: 600; color: var(--text-primary); min-width: 70px; text-align: center; }
.sp-pagination-meta { text-align: center; font-size: 11px; color: var(--muted); margin-top: 6px; }

.sp-items-list { display: flex; flex-direction: column; gap: 8px; }

.sp-item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sp-item-card:hover {
  border-color: var(--border-2);
  box-shadow: 0 2px 8px var(--surface-2);
}
.sp-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.sp-item-text { flex: 1; min-width: 0; }
.sp-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding-top: 1px;
}
.sp-item-en { font-weight: 600; font-size: 15px; color: var(--text-primary); line-height: 1.3; word-break: break-word; overflow-wrap: break-word; }
.sp-item-pt { font-size: 13px; color: var(--muted); margin-top: 2px; }
.sp-item-example {
  font-size: 12px;
  color: var(--info);
  font-style: italic;
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.sp-item-example i { font-size: 9px; opacity: 0.5; flex-shrink: 0; }
.sp-item-notes {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.sp-item-notes i { font-size: 11px; color: var(--primary); flex-shrink: 0; }
.sp-item-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.sp-item-audio-btn { color: var(--success) !important; }

.sp-note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.sp-note-card:hover { box-shadow: var(--shadow); }
.sp-note-summary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.sp-note-summary:hover { background: var(--primary-pale); }
.sp-note-card--expanded .sp-note-summary { background: var(--primary-pale); }
.sp-note-summary-left { flex: 1; min-width: 0; }
.sp-note-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-note-preview {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-note-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sp-note-date { font-size: 11px; color: var(--muted-2); }
.sp-note-dirty-badge { font-size: 11px; color: var(--primary); font-weight: 600; }
.sp-note-chevron { font-size: 11px; color: var(--muted); transition: transform 0.2s ease; }
.sp-note-chevron--open { transform: rotate(180deg); }
.sp-note-body { border-top: 1px solid var(--border); padding: 12px 16px 14px; }

.sp-modules-grid { display: flex; flex-direction: column; gap: 8px; }
.sp-module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Linked modules */
.sp-linked-module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.sp-linked-module-emoji { font-size: 24px; flex-shrink: 0; }
.sp-linked-module-info { flex: 1; min-width: 0; }
.sp-linked-module-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-linked-module-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sp-linked-module-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Flashcard session */
.sp-fc-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.sp-fc-progress { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; max-width: 400px; }
.sp-fc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-2); transition: background 0.3s; }
.sp-fc-dot.done { background: var(--success); }
.sp-fc-dot.current { background: var(--primary); width: 18px; border-radius: 4px; }
.sp-fc-stage { width: 100%; max-width: 420px; perspective: 1000px; cursor: pointer; }
.sp-fc-inner { position: relative; width: 100%; height: 250px; transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.4,0,0.2,1); }
.sp-fc-inner.flipped { transform: rotateY(180deg); }
.sp-fc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--card); }
.sp-fc-back { transform: rotateY(180deg); background: var(--primary-pale); border-color: var(--border-2); }

/* Modal */
.sp-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  backdrop-filter: blur(2px);
}
.sp-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  position: relative; box-shadow: var(--shadow-lg);
}
.sp-modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; font-size: 18px; color: var(--muted);
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.sp-modal-close:hover { color: var(--text-primary); background: var(--surface-2); }
.sp-modal-title { font-weight: 700; font-size: 18px; margin-bottom: 1.25rem; color: var(--text-primary); }

/* Emoji/color pickers */
.sp-emoji-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.sp-emoji-btn { background: var(--card); border: 1.5px solid var(--border); border-radius: 8px; font-size: 20px; padding: 6px 8px; cursor: pointer; transition: all 0.12s; }
.sp-emoji-btn:hover { border-color: var(--primary); }
.sp-emoji-btn.active { border-color: var(--primary); background: var(--primary-light); }
.sp-color-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.sp-color-btn { width: 32px; height: 32px; border-radius: 50%; border: 2.5px solid transparent; cursor: pointer; transition: transform 0.12s; }
.sp-color-btn:hover { transform: scale(1.15); }
.sp-color-btn.active { border-color: var(--text-primary); transform: scale(1.1); }

/* ── STUDY PLAN — Audio section ───────────────────────────────────── */
.sp-audio-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface-2);
  margin-top: 0.75rem;
}
.sp-audio-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.sp-audio-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sp-audio-tab {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sp-audio-tab:hover { color: var(--text-primary); border-color: var(--primary); }
.sp-audio-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.sp-audio-panel { padding: 4px 0; }

.sp-rec-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
  animation: pulse 1s infinite;
  flex-shrink: 0;
}

/* ── STUDY PLAN — Flashcard tab header ────────────────────────────── */
.sp-fc-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.sp-fc-tab-stats {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
  align-items: center;
}
.sp-fc-start-btn {
  background: var(--primary-pale);
  border: 1.5px solid var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.sp-fc-start-btn:hover { background: var(--primary); color: white; }

/* ── STUDY PLAN — Flashcard session ───────────────────────────────── */
.sp-fc-session-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

/* Session header */
.sp-fc-session-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sp-fc-exit-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.sp-fc-exit-btn:hover { border-color: var(--danger); color: var(--danger); }
.sp-fc-session-info { display: flex; align-items: center; gap: 10px; }
.sp-fc-counter {
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
}
.sp-fc-counter-sep { color: var(--muted); font-size: 16px; }
.sp-fc-learned-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--success);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

/* Progress bar */
.sp-fc-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.sp-fc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-mid));
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Card face text */
.sp-fc-face-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sp-fc-face-word {
  font-weight: 700;
  font-size: 32px;
  text-align: center;
  color: var(--text-primary);
  line-height: 1.2;
  word-break: break-word;
}
.sp-fc-face-translation {
  font-weight: 600;
  font-size: 26px;
  color: var(--primary);
  text-align: center;
  word-break: break-word;
}
.sp-fc-face-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
  margin-top: 10px;
  max-width: 90%;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.sp-fc-face-note i { color: var(--primary); flex-shrink: 0; margin-top: 2px; }

.sp-fc-face-examples {
  margin-top: 10px;
  max-width: 92%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sp-fc-face-example {
  font-size: 12px;
  color: var(--info);
  font-style: italic;
  text-align: left;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.sp-fc-face-example i { font-size: 9px; opacity: 0.5; flex-shrink: 0; }

/* Hint icon button on front face */
.sp-fc-hint-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 20px;
  padding: 5px;
  z-index: 5;
  border-radius: 50%;
  transition: background 0.15s, transform 0.15s;
  line-height: 1;
}
.sp-fc-hint-btn:hover { background: var(--primary-pale); transform: scale(1.12); }
.sp-fc-hint-popup {
  position: absolute;
  top: 44px;
  right: 8px;
  background: var(--card);
  border: 1.5px solid var(--primary);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
  min-width: 180px;
  max-width: 280px;
  max-height: 140px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  display: none;
  line-height: 1.5;
  z-index: 10;
}
.sp-fc-hint-popup.visible { display: block; }

.sp-fc-flip-hint {
  position: absolute;
  bottom: 14px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.65;
}
.sp-fc-flip-hint--back { color: var(--primary); }

/* Navigation row */
.sp-fc-nav-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sp-fc-nav-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.sp-fc-nav-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.sp-fc-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.sp-fc-nav-btn--next {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.sp-fc-nav-btn--next:hover:not(:disabled) { filter: brightness(0.9); }
.sp-fc-flip-btn {
  flex: 1;
  height: 46px;
  border: 1.5px solid var(--primary);
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}
.sp-fc-flip-btn:hover { background: var(--primary); color: white; }

/* Keyboard hint */
.sp-fc-kbd-hint {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
}
.sp-fc-kbd-hint kbd {
  display: inline-block;
  background: var(--border);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: monospace;
  margin: 0 1px;
}

/* Action strip */
.sp-fc-actions {
  width: 100%;
  display: flex;
  gap: 8px;
}
.sp-fc-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
}
.sp-fc-action-btn i { font-size: 17px; }
.sp-fc-action-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); }
.sp-fc-action-btn.learned { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.sp-fc-action-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); }

/* Note editor */
.sp-fc-note-editor {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.sp-fc-note-editor-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Session summary */
.sp-fc-summary {
  text-align: center;
  padding: 2rem 1rem;
  width: 100%;
}
.sp-fc-summary-icon { font-size: 56px; margin-bottom: 1rem; line-height: 1; }
.sp-fc-summary h3 {
  font-weight: 700;
  font-size: 24px;
  margin-bottom: 6px;
}
.sp-fc-summary p { font-size: 14px; color: var(--muted); margin-bottom: 1.5rem; }
.sp-fc-summary-stats { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.sp-fc-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 28px;
  min-width: 90px;
}
.sp-fc-stat-num {
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
}
.sp-fc-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sp-fc-summary-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── STUDY PLAN — Shadowing Mode ────────────────────────────────── */
/* ── Shadowing panel (bottom sheet) ──────────────────────────── */
.sp-sh-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 70vh;
  overflow-y: auto;
}
.sp-sh-panel--open {
  transform: translateY(0);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.25);
}
.sp-sh-panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.sp-sh-panel-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sp-sh-exit-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  transition: color 0.15s;
}
.sp-sh-exit-btn:hover { color: var(--text-primary); }
.sp-sh-listen-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.sp-sh-listen-btn:hover { border-color: var(--primary); color: var(--primary); }
.sp-sh-rec-btn {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.sp-sh-rec-btn:hover { border-color: var(--primary); background: var(--primary-pale); color: var(--primary); }
.sp-sh-rec-btn--active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: sp-sh-pulse 1.5s ease infinite;
}
.sp-sh-rec-btn--active:hover { background: var(--danger); color: #fff; }
@keyframes sp-sh-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,90,90,0.35); }
  50% { box-shadow: 0 0 0 8px rgba(224,90,90,0); }
}
.sp-sh-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  animation: pulse 1s infinite;
}
.sp-sh-listen-row {
  display: flex;
  gap: 10px;
}
.sp-sh-listen-row .sp-sh-listen-btn { flex: 1; }
.sp-sh-myvoice-btn { border-color: var(--success) !important; color: var(--success) !important; }
.sp-sh-myvoice-btn:hover { background: color-mix(in srgb, var(--success) 10%, transparent) !important; }
.sp-sh-rerecord-btn {
  width: 100%;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.15s, color 0.15s;
}
.sp-sh-rerecord-btn:hover { border-color: var(--danger); color: var(--danger); }
.sp-sh-next-btn {
  width: 100%;
  padding: 0.875rem;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s;
}
.sp-sh-next-btn:hover { filter: brightness(0.9); }

/* ── STUDY PLAN — Rating buttons (Errei / Difícil / Bom / Fácil) ────── */
.sp-fc-rating-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 4px;
}
.sp-fc-rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, box-shadow 0.1s;
}
.sp-fc-rating-btn:active { transform: scale(0.96); }
.sp-fc-rating-label {
  font-size: 13px;
  font-weight: 700;
}
.sp-fc-rating-interval {
  font-size: 10px;
  opacity: 0.8;
  font-weight: 500;
}
.sp-fc-rating-again,
.sp-fc-rating-hard,
.sp-fc-rating-good,
.sp-fc-rating-easy  { background: var(--surface-2); border-color: var(--border); color: var(--text-secondary); }
.sp-fc-rating-again:hover,
.sp-fc-rating-hard:hover,
.sp-fc-rating-good:hover,
.sp-fc-rating-easy:hover  { background: var(--surface-hover); border-color: var(--border-2); color: var(--text-primary); }
@media (max-width: 480px) {
  .sp-fc-rating-btn { padding: 8px 4px; }
  .sp-fc-rating-label { font-size: 12px; }
}

/* ── STUDY PLAN — Spaced Repetition UI ───────────────────────────────── */
.sp-fc-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 3px;
}
.sp-fc-mode-btn {
  background: none;
  border: none;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sp-fc-mode-btn.active {
  background: var(--primary);
  color: #fff;
}
.sp-fc-sr-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--info-pale, #e8f4fd);
  color: var(--info, #2196f3);
  white-space: nowrap;
}
.sp-fc-allgood {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 2.5rem 1.5rem;
  text-align: center;
}
.sp-fc-allgood-icon {
  font-size: 52px;
  line-height: 1;
}
.sp-fc-allgood h3 {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
}
.sp-fc-allgood p {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}
.sp-fc-allgood-next {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  margin: 4px auto 0;
}
/* Due-count badge on the Flashcards tab button */
.sp-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin-left: 5px;
  vertical-align: middle;
}

@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* ── Role badge ──────────────────────────────────────────────────── */
.sidebar-role-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 6px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* ── Admin panel ─────────────────────────────────────────────────── */
.admin-stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.admin-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem 1.5rem;
  min-width: 130px;
  text-align: center;
}
.admin-stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}
.admin-stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .3rem;
}
.admin-card-hint {
  margin-top: .25rem;
  color: var(--text-muted);
  font-size: .84rem;
}
.admin-empty-action {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 1rem 1.25rem 0;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .9rem;
}
.admin-empty-action i { color: var(--primary); }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.admin-table th {
  text-align: left;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.admin-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-row-inactive td { opacity: .55; }
.admin-email { color: var(--text-muted); font-size: .85rem; }
.admin-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.admin-role-select {
  padding: .3rem .5rem;
  font-size: .82rem;
  height: auto;
  max-width: 130px;
}
.admin-self-label { color: var(--text-muted); font-size: .85rem; font-style: italic; }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--danger-bg); color: var(--danger); }
.card-header   { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }

/* ── Classes (turmas) ────────────────────────────────────────────── */
.cls-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.cls-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.cls-card-name  { font-weight: 700; font-size: 1rem; }
.cls-card-desc  { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }
.cls-card-actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }
.cls-plan-section {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cls-plan-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: .75rem;
}
.cls-plan-add {
  display: flex;
  gap: .5rem;
  align-items: center;
  min-width: min(360px, 100%);
}
.cls-plan-add .form-input { min-width: 0; }
.cls-plan-list,
.cls-member-plans,
.cls-plan-check-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.cls-member-plans { margin-top: .35rem; }
.cls-plan-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  max-width: 100%;
  padding: .25rem .5rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--plan-color, var(--primary)) 35%, transparent);
  background: color-mix(in srgb, var(--plan-color, var(--primary)) 12%, transparent);
  color: var(--text-primary);
  font-size: .78rem;
  line-height: 1.2;
}
.cls-plan-chip button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.cls-plan-chip button:hover { color: var(--danger); }
.cls-member-no-plans {
  color: var(--text-muted);
  font-size: .8rem;
}
.cls-plan-check-list {
  flex-direction: column;
  flex-wrap: nowrap;
}
.cls-plan-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.cls-members    { padding: .75rem 1.25rem; display: flex; flex-direction: column; gap: .4rem; }
.cls-member {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .9rem;
  padding: .35rem .5rem;
  border-radius: 8px;
}
.cls-member:hover { background: var(--hover-bg, #f5f3f0); }
.cls-member-email { color: var(--text-muted); font-size: .8rem; margin-left: .25rem; }
.cls-member .icon-btn { margin-left: auto; }
.cls-empty-members { color: var(--text-muted); font-size: .85rem; margin: 0; padding: .25rem 0; }

/* ── Topic shared / owner badges ─────────────────────────────────── */
.sp-shared-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  vertical-align: middle;
  margin-left: 5px;
}
.sp-topic-owner-label {
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .3rem;
  white-space: nowrap;
}

/* ── Nav notification badge ──────────────────────────────────────── */
.nav-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* ── Plan invites banner (student) ───────────────────────────────── */
.sp-plan-invites-banner {
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.sp-plan-invites-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sp-plan-invites-list { display: flex; flex-direction: column; gap: .6rem; }
.sp-plan-invite-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.sp-plan-invite-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.sp-plan-invite-info { flex: 1; min-width: 0; }
.sp-plan-invite-name { font-weight: 700; font-size: .95rem; }
.sp-plan-invite-desc { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }
.sp-plan-invite-from { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.sp-plan-invite-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ── YouGlish tip banner ─────────────────────────────────────────── */
.sp-youglish-tip {
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .85rem 1.1rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.sp-youglish-tip-icon { font-size: 1.3rem; color: var(--primary); flex-shrink: 0; }
.sp-youglish-tip-text { flex: 1; min-width: 220px; font-size: .85rem; color: var(--text-primary); line-height: 1.4; }
.sp-youglish-tip-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  flex-shrink: 0;
}
.sp-youglish-tip-close:hover { color: var(--text-primary); }

/* ── YouGlish widget modal ───────────────────────────────────────── */
.sp-yg-hint { font-size: .85rem; color: var(--text-muted); margin: -.25rem 0 .85rem; }
.sp-yg-widget-wrap {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  min-height: 360px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.sp-yg-add-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.sp-yg-caption-preview {
  flex: 1;
  min-width: 200px;
  font-size: .85rem;
  font-style: italic;
  color: var(--text-muted);
}

/* ── Shared topics section ───────────────────────────────────────── */
.sp-shared-section { margin-top: 2rem; }
.sp-shared-section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* ── Share modal sections (teacher) ──────────────────────────────── */
.sp-share-section { }
.sp-share-section-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.sp-share-class-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .6rem .75rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: .9rem;
  margin-bottom: .4rem;
  transition: background .15s;
}
.sp-share-class-row:hover { background: var(--hover-bg, #f5f3f0); }
.sp-share-class-empty { opacity: .5; cursor: default; }

/* ── Class invite cards (student) ───────────────────────────────── */
.cls-invites-section { margin-bottom: 1.5rem; }
.cls-section-title {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.cls-invite-card {
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .9rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}
.cls-invite-info { flex: 1; min-width: 0; }
.cls-invite-name { font-weight: 700; font-size: .95rem; }
.cls-invite-desc { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }
.cls-invite-from { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }
.cls-invite-actions { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }

/* ── Class member rows ───────────────────────────────────────────── */
.cls-member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cls-member-name { font-weight: 600; font-size: .9rem; }

/* ── Classes modal ───────────────────────────────────────────────── */
.cls-modal-box { max-width: 460px; width: 100%; }
/* ── Student Performance View ────────────────────────────────────── */
.sp-act-student-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sp-act-student-card:hover {
  border-color: var(--orange);
  box-shadow: 0 4px 16px rgba(108,116,220,0.12);
  transform: translateY(-2px);
}

/* ── Attempt Card (collapsible) ──────────────────────────────────── */
.sp-act-attempt-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.2s;
}

.sp-act-attempt-card:hover {
  border-color: var(--orange);
  box-shadow: var(--shadow);
}

.sp-act-attempt-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(to right, rgba(108,116,220,0.03), transparent);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.sp-act-attempt-header:hover {
  background: linear-gradient(to right, rgba(108,116,220,0.06), transparent);
}

.sp-act-attempt-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 500px;
  overflow-y: auto;
}

.sp-act-attempt-body.hidden {
  display: none;
}

/* ── Answer rows in attempt ──────────────────────────────────────── */
.sp-act-answer-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border-left: 3px solid var(--border);
}

.sp-act-answer-row i { flex-shrink: 0; margin-top: 2px; }

/* ── FILL BLANK: Input integrado na frase ────────────────────────────── */
.sp-act-fillblank-card {
  background: var(--surface);
  border: 2px solid var(--border);
}

.sp-act-fillblank-statement {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 1.25rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  line-height: 1.8;
  word-spacing: 0.1em;
}

.sp-act-fillblank-statement span {
  display: inline;
}

.sp-act-fillblank-input {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  height: 36px;
  padding: 0 10px;
  border: 2px solid var(--orange);
  border-radius: 4px;
  background: var(--primary-pale);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.sp-act-fillblank-input:focus {
  border-color: var(--orange);
  background: linear-gradient(135deg, var(--orange-pale) 0%, var(--orange-light) 100%);
  box-shadow: 0 0 0 3px rgba(108,116,220,0.15);
  transform: scale(1.05);
}

.sp-act-fillblank-input::placeholder {
  color: rgba(108,116,220,0.5);
  font-weight: 400;
}

/* ── Question text ───────────────────────────────────────────────────── */
.sp-act-question-text {
  font-size: 15px;
  line-height: 1.8;
  padding: 1rem;
  background: rgba(108,116,220,0.03);
  border-left: 4px solid var(--orange);
  border-radius: 4px;
  color: var(--text-primary);
}

/* ── Multiple Choice: Botões modernos ─────────────────────────────────── */
.sp-act-alts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

.sp-act-alt-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.sp-act-alt-btn:hover {
  border-color: var(--primary);
  background: var(--primary-pale);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(108,116,220,0.15);
}

.sp-act-alt-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 2px 12px rgba(108,116,220,0.2);
  transform: translateX(4px);
}

.sp-act-alt-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-mid) 100%);
  border-radius: 4px;
  color: white;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

/* ── True/False: Botões lado a lado ──────────────────────────────────── */
.sp-act-truefalse-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.sp-act-truefalse-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  min-height: 100px;
}

.sp-act-truefalse-btn i {
  font-size: 24px;
}

.sp-act-truefalse-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.sp-act-truefalse-btn.selected {
  border-color: var(--orange);
  background: var(--primary-pale);
  box-shadow: 0 4px 16px rgba(108,116,220,0.15);
}

.sp-act-truefalse-true.selected i {
  color: var(--success);
}

.sp-act-truefalse-false.selected i {
  color: var(--danger);
}

/* ── Result feedback cards ───────────────────────────────────────────── */
.sp-act-result-correct {
  padding: 1rem;
  background: var(--success-bg);
  border: 2px solid var(--success);
  border-radius: 8px;
}

.sp-act-result-wrong {
  padding: 1rem;
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: 8px;
}

.sp-act-result-icon {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Player improvements ─────────────────────────────────────────────── */
.sp-act-player-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.sp-act-player-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 0.75rem;
  background: var(--orange-pale);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}

.sp-act-player-type i {
  font-size: 13px;
}

.sp-act-fillblank-card .sp-act-player-type {
  background: var(--orange-pale);
  color: var(--orange);
}

/* ── Exercise Group Cards ────────────────────────────────────────── */
.sp-act-exercise-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.sp-act-exercise-group:hover {
  border-color: var(--orange);
  box-shadow: 0 2px 8px rgba(108,116,220,0.12);
}

.sp-act-exercise-header {
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  user-select: none;
  transition: all 0.2s ease;
}

.sp-act-exercise-header:hover {
  background: var(--primary-pale);
}

.sp-act-exercise-header i:last-child {
  transition: transform 0.2s ease;
}

.sp-act-exercise-group .sp-act-exercise-body.hidden ~ .sp-act-exercise-header i:last-child {
  transform: rotate(-90deg);
}

.sp-act-exercise-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slideDown 0.2s ease;
}

.sp-act-exercise-body.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Question Items ──────────────────────────────────────────────── */
.sp-act-question-item {
  padding: 0.875rem;
  background: rgba(232, 88, 26, 0.03);
  border: 1px solid rgba(232, 88, 26, 0.1);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.sp-act-question-item:hover {
  background: rgba(232, 88, 26, 0.06);
  border-color: rgba(232, 88, 26, 0.2);
}

/* ── Fill Blank Preview ──────────────────────────────────────────┐ */
.sp-act-blank-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  height: 32px;
  padding: 0 8px;
  background: linear-gradient(135deg, var(--orange-pale) 0%, var(--orange-light) 100%);
  border: 2px dashed var(--orange);
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.sp-act-blank-preview::after {
  content: '→ clique para preencher';
  position: absolute;
  top: -20px;
  left: 0;
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.sp-act-blank-preview:hover {
  background: var(--orange-light);
  border-color: var(--orange);
  transform: scale(1.05);
}

/* ── Exercise Hint ───────────────────────────────────────────────── */
.sp-exercise-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: rgba(42, 125, 79, 0.06);
  border: 1px solid rgba(42, 125, 79, 0.15);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  margin-top: 0.5rem;
}

.sp-exercise-hint i {
  color: var(--success);
  flex-shrink: 0;
  font-size: 13px;
}

/* ── Activities: toolbar & type badge ────────────────────────────── */
.sp-acts-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.sp-act-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(232, 88, 26, 0.12);
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── Activities: student view preview ────────────────────────────── */
.sp-acts-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.sp-act-preview-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
}

/* ── Activities: activity item (teacher list) ────────────────────── */
.sp-act-item {
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.625rem;
  transition: border-color 0.15s;
}

.sp-act-item:hover {
  border-color: var(--orange);
}

/* ── Activities: player container ────────────────────────────────── */
.sp-act-player {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 2rem;
}

.sp-act-player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.sp-act-player-progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.sp-act-player-statement {
  font-size: 17px;
  line-height: 1.7;
  font-weight: 500;
  color: var(--text-primary);
  margin: 1.25rem 0 1.5rem;
  word-break: break-word;
}

.sp-act-blank {
  display: inline-block;
  padding: 1px 10px;
  border-bottom: 2px solid var(--orange);
  color: var(--orange);
  font-weight: 700;
  letter-spacing: 2px;
}

/* ── Activities: result feedback ─────────────────────────────────── */
.sp-act-player-result {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}

.sp-act-result-correct {
  background: rgba(0, 212, 170, 0.08);
  border: 1.5px solid var(--success);
}

.sp-act-result-wrong {
  background: rgba(255, 80, 80, 0.07);
  border: 1.5px solid var(--danger);
}

.sp-act-result-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 17px;
  font-weight: 700;
}

.sp-act-explanation {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(232, 88, 26, 0.07);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--orange);
  font-size: 13px;
  color: var(--text-primary);
}

/* ── Activities: results screen ──────────────────────────────────── */
.sp-act-results {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.sp-act-results-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.sp-act-results-score {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  margin: 0.25rem 0;
  letter-spacing: -0.02em;
}

.sp-act-results-detail {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.sp-act-results-breakdown {
  text-align: left;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Student Exercise Stat Cards ─────────────────────────────────── */
.sp-exercise-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.sp-exercise-stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sp-exercise-stat-card:hover {
  border-color: var(--orange);
  box-shadow: 0 2px 8px rgba(108,116,220,0.1);
}

.sp-exercise-stat-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
}

.sp-exercise-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--orange-pale) 0%, var(--orange-light) 100%);
  color: var(--orange);
}

.sp-exercise-stat-info {
  flex: 1;
  min-width: 0;
}

.sp-exercise-stat-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.sp-exercise-stat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sp-ex-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sp-ex-status-not-started {
  background: rgba(0,0,0,0.06);
  color: var(--muted);
}

.sp-ex-status-in-progress {
  background: var(--warning-bg);
  color: var(--warning);
}

.sp-ex-status-completed {
  background: rgba(16,185,129,0.12);
  color: var(--success);
}

.sp-exercise-stat-scores {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  text-align: right;
}

.sp-exercise-stat-score-val {
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
}

.sp-exercise-stat-actions {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding: 0.625rem 1rem;
  background: rgba(0,0,0,0.015);
}

.sp-exercise-stat-history {
  padding: 0 1rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.sp-exercise-stat-history.hidden {
  display: none;
}

.sp-ex-attempt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.625rem;
  background: rgba(108,116,220,0.03);
  border: 1px solid rgba(108,116,220,0.08);
  border-radius: var(--radius-sm);
  font-size: 12px;
  gap: 8px;
}

/* ── Edit Question Card ──────────────────────────────────────────── */
.sp-edit-question-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  margin-bottom: 0.625rem;
  transition: border-color 0.15s;
}

.sp-edit-question-card:hover {
  border-color: var(--orange);
}

.sp-edit-question-card .form-group {
  margin-bottom: 0.625rem;
}

.sp-edit-question-card .form-group:last-child {
  margin-bottom: 0;
}

.sp-edit-deleted-q {
  opacity: 0.45;
  border: 1px dashed var(--danger);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
  background: rgba(220, 53, 69, 0.04);
}

/* ── Utility ─────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Tiptap note editor ──────────────────────────────────────────── */
.sp-notes-list { display: flex; flex-direction: column; gap: 12px; }

.sp-note-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.sp-tb-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
  line-height: 1.5;
  min-width: 28px;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.sp-tb-btn:hover { background: var(--primary-pale); border-color: var(--border); }
.sp-tb-btn.is-active { background: var(--primary-pale); border-color: var(--primary); color: var(--primary); }
.sp-tb-sep {
  display: inline-block;
  width: 1px;
  background: var(--border);
  margin: 3px 4px;
  align-self: stretch;
}

/* Editor container — visible click target */
.sp-note-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  cursor: text;
  background: var(--surface-2);
  transition: border-color 0.15s;
}
.sp-note-editor:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(108,116,220,0.1);
}

/* ProseMirror editor area */
.sp-note-editor .ProseMirror {
  outline: none;
  padding: 6px 4px;
  min-height: 72px;
  line-height: 1.7;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  word-break: break-word;
}
.sp-note-editor .ProseMirror.ProseMirror-focused { outline: none; }
.sp-note-editor .ProseMirror > *:first-child { margin-top: 0; }
.sp-note-editor .ProseMirror > *:last-child { margin-bottom: 0; }
.sp-note-editor .ProseMirror p { margin: 0 0 0.45em; }

.sp-note-editor .ProseMirror h1 { font-size: 1.35em; font-weight: 700; margin: 0.8em 0 0.3em; font-family: inherit; color: var(--text-primary); }
.sp-note-editor .ProseMirror h2 { font-size: 1.15em; font-weight: 700; margin: 0.7em 0 0.3em; font-family: inherit; color: var(--text-primary); }
.sp-note-editor .ProseMirror h3 { font-size: 1em; font-weight: 500; margin: 0.6em 0 0.25em; font-family: inherit; color: var(--text-primary); }

.sp-note-editor .ProseMirror ul,
.sp-note-editor .ProseMirror ol { padding-left: 1.5em; margin: 0.3em 0; }
.sp-note-editor .ProseMirror li { margin: 0.15em 0; }
.sp-note-editor .ProseMirror li p { margin: 0; }

.sp-note-editor .ProseMirror blockquote {
  border-left: 3px solid var(--primary);
  margin: 0.5em 0;
  padding: 4px 12px;
  color: var(--muted);
  font-style: italic;
}

.sp-note-editor .ProseMirror code {
  background: rgba(108,116,220,0.12);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.87em;
  font-family: monospace;
  color: var(--primary);
}
.sp-note-editor .ProseMirror pre {
  background: var(--sidebar-bg);
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.5em 0;
}
.sp-note-editor .ProseMirror pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 13px;
}

.sp-note-editor .ProseMirror a { color: var(--primary); text-decoration: underline; }
.sp-note-editor .ProseMirror a:hover { color: var(--primary-hover); }
.sp-note-editor .ProseMirror img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 0.6rem 0;
}
.sp-note-editor .ProseMirror img.ProseMirror-selectednode {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sp-note-editor .ProseMirror table { border-collapse: collapse; width: 100%; margin: 0.5em 0; overflow: hidden; border-radius: 4px; }
.sp-note-editor .ProseMirror th,
.sp-note-editor .ProseMirror td { border: 1px solid var(--border); padding: 5px 9px; font-size: 13px; position: relative; }
.sp-note-editor .ProseMirror th { background: var(--primary-pale); font-weight: 700; text-align: left; }
.sp-note-editor .ProseMirror .selectedCell::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(108,116,220,0.08);
  pointer-events: none;
}
.sp-note-editor .ProseMirror .column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
  cursor: col-resize;
}

/* Placeholder text */
.sp-note-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--muted);
  pointer-events: none;
  height: 0;
}

/* Note footer (save/cancel actions + status) */
.sp-note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  gap: 8px;
}
.sp-note-actions { display: flex; align-items: center; gap: 6px; }
.sp-note-status { font-size: 12px; color: var(--muted); font-style: italic; min-height: 16px; }
.sp-note-status--ok { color: var(--success); font-style: normal; font-weight: 600; }
.sp-note-status--err { color: var(--danger); font-style: normal; }

/* Readonly note content (shared topics) */
.sp-note-body .sp-note-content { font-size: 14px; line-height: 1.7; font-family: inherit; color: var(--text-primary); word-break: break-word; }
.sp-note-body .sp-note-content > *:first-child { margin-top: 0; }
.sp-note-body .sp-note-content > *:last-child { margin-bottom: 0; }
.sp-note-body .sp-note-content p { margin: 0 0 0.45em; }
.sp-note-body .sp-note-content h1 { font-size: 1.35em; font-weight: 700; margin: 0.8em 0 0.3em; font-family: inherit; }
.sp-note-body .sp-note-content h2 { font-size: 1.15em; font-weight: 700; margin: 0.7em 0 0.3em; font-family: inherit; }
.sp-note-body .sp-note-content h3 { font-size: 1em; font-weight: 500; margin: 0.6em 0 0.25em; font-family: inherit; }
.sp-note-body .sp-note-content ul,
.sp-note-body .sp-note-content ol { padding-left: 1.5em; margin: 0.3em 0; }
.sp-note-body .sp-note-content li { margin: 0.15em 0; }
.sp-note-body .sp-note-content blockquote { border-left: 3px solid var(--primary); margin: 0.5em 0; padding: 4px 12px; color: var(--muted); font-style: italic; }
.sp-note-body .sp-note-content code { background: var(--primary-pale); border-radius: 3px; padding: 1px 4px; font-size: 0.87em; font-family: monospace; color: var(--primary); }
.sp-note-body .sp-note-content pre { background: var(--sidebar-bg); color: var(--text-secondary); padding: 10px 14px; border-radius: var(--radius-sm); overflow-x: auto; margin: 0.5em 0; }
.sp-note-body .sp-note-content pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
.sp-note-body .sp-note-content a { color: var(--primary); text-decoration: underline; }
.sp-note-body .sp-note-content img,
.sp-pdf-note-body img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 0.6rem 0;
}
.sp-note-body .sp-note-content table { border-collapse: collapse; width: 100%; margin: 0.5em 0; }
.sp-note-body .sp-note-content th,
.sp-note-body .sp-note-content td { border: 1px solid var(--border); padding: 5px 9px; font-size: 13px; }
.sp-note-body .sp-note-content th { background: var(--primary-pale); font-weight: 700; text-align: left; }

/* Wide modal for note creation */
.sp-modal--wide { max-width: 680px !important; }

/* ── Study Plan Hub ──────────────────────────────────────────────────────── */
.sp-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.sp-hub-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 1.125rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  position: relative;
}
.sp-hub-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.sp-hub-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sp-hub-card--active { border-color: var(--primary); background: var(--primary-pale); }
.sp-hub-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.sp-hub-card--active .sp-hub-card-icon { background: var(--primary); color: #fff; }
.sp-hub-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.sp-hub-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; flex: 1; }
.sp-hub-card-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
}
.sp-hub-card-badge--ok { background: var(--success-bg); color: var(--success); }
.sp-hub-content { margin-top: 0; }

/* ── Study Plan — Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Hub: 2 colunas no tablet */
  .sp-hub { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Practice CTA */
  .sp-practice { padding: 0.875rem 1rem; gap: 0.75rem; }
  .sp-practice-arrow { display: none; }

  /* Flashcard: largura total */
  .sp-fc-session-wrap { max-width: 100%; }
  .sp-fc-stage { max-width: 100%; }

  /* Modal: padding menor */
  .sp-modal { padding: 20px 18px; }
}

@media (max-width: 480px) {
  /* ── Overflow global ── */
  .page { overflow-x: hidden; }

  /* ── Hub: 2 colunas compactas ── */
  .sp-hub { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 1.25rem; }
  .sp-hub-card { padding: 0.75rem; gap: 6px; }
  .sp-hub-card-icon { width: 30px; height: 30px; font-size: 13px; }
  .sp-hub-card-title { font-size: 13px; }
  .sp-hub-card-desc { display: none; }
  .sp-hub-card-badge { font-size: 10px; padding: 2px 6px; }

  /* ── Topic header ── */
  .sp-thdr { gap: 8px; margin-bottom: 0.875rem; flex-wrap: wrap; }
  .sp-thdr-emoji { font-size: 22px; }
  .sp-thdr-name { font-size: 15px; }
  .sp-thdr-meta { font-size: 12px; }

  /* ── Practice CTA ── */
  .sp-practice { padding: 0.75rem; gap: 0.625rem; margin-bottom: 1.125rem; }
  .sp-practice-icon { width: 34px; height: 34px; font-size: 14px; }
  .sp-practice-title { font-size: 13px; }
  .sp-practice-desc { display: none; }

  /* ── Pills ── */
  .sp-pills { margin-bottom: 1.125rem; }
  .sp-pill { padding: 6px 10px; font-size: 12px; }

  /* ── Words toolbar: vertical stack ── */
  .sp-words-toolbar { flex-direction: column; align-items: stretch; }
  .sp-words-actions { justify-content: flex-start; flex-wrap: wrap; }
  .sp-words-search-wrap { min-width: 0; width: 100%; }
  .sp-words-filters-row { gap: 8px; }
  .sp-words-filter-group { flex-wrap: wrap; gap: 4px; }

  /* ── Item cards: text wrap ── */
  .sp-item-top { flex-wrap: wrap; gap: 8px; }
  .sp-item-text { min-width: 0; width: 100%; }
  .sp-item-actions { width: 100%; justify-content: flex-end; }
  .sp-item-pt { word-break: break-word; }

  /* ── Flashcard session ── */
  .sp-fc-inner { height: 200px; }
  .sp-fc-face { padding: 14px; }
  .sp-fc-face-word { font-size: 24px; }
  .sp-fc-face-translation { font-size: 20px; }
  .sp-fc-nav-btn { width: 40px; height: 40px; }
  .sp-fc-flip-btn { height: 40px; font-size: 13px; }
  .sp-fc-kbd-hint { display: none; }
  .sp-fc-action-btn { padding: 10px 4px; font-size: 10px; }
  .sp-fc-action-btn i { font-size: 15px; }

  /* ── Flashcard summary ── */
  .sp-fc-stat { padding: 12px 16px; min-width: 0; flex: 1; }
  .sp-fc-stat-num { font-size: 24px; }

  /* ── Rating buttons ── */
  .sp-fc-rating-btn { padding: 6px 2px; min-width: 0; }
  .sp-fc-rating-label { font-size: 11px; }
  .sp-fc-rating-interval { font-size: 9px; }

  /* ── Shadowing ── */
  .sp-fc-shadow-step-label { min-width: 0; }

  /* ── Modal: centralizado no celular ── */
  .sp-modal-overlay { padding: 0.75rem; align-items: center; justify-content: center; }
  .sp-modal { border-radius: var(--radius-lg); max-height: 90dvh; overflow-y: auto; padding: 20px 16px; width: 100%; }
  .sp-modal--wide { max-width: 100% !important; }

  /* ── Empty state ── */
  .sp-detail-empty { padding: 2.5rem 1rem; min-height: 160px; }
  .sp-detail-empty i { font-size: 24px; }

  /* ── Plan invites banner ── */
  .sp-plan-invite-card { flex-wrap: wrap; gap: 8px; }
  .sp-plan-invite-actions { width: 100%; justify-content: flex-end; }
}

/* ── Flashcard Focus Mode Overlay ───────────────────────────────────────── */
.sp-fc-focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  justify-content: center;
  padding: 1.5rem 1.25rem 3rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}
.sp-fc-focus-overlay--open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.sp-fc-focus-overlay #sp-fc-session {
  width: 100%;
  max-width: 560px;
  padding-top: 0.25rem;
}
@media (max-width: 480px) {
  .sp-fc-focus-overlay { padding: 0.75rem 0.75rem 2rem; }
}

/* ── HABITS ────────────────────────────────────────────────────────────────── */
.hb-page { max-width: 680px; margin: 0 auto; padding: 1.5rem 1rem 4rem; display: flex; flex-direction: column; gap: 1.5rem; }

.hb-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.hb-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 0; display: flex; align-items: center; gap: 8px; }
.hb-subtitle { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

.hb-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.hb-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.hb-section-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.hb-today-badge { font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.hb-today-badge--done { background: color-mix(in srgb, var(--success) 15%, transparent); border-color: var(--success); color: var(--success); }
.hb-overall-pct { font-size: 12px; color: var(--muted); }

.hb-empty { text-align: center; padding: 2rem 1rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.hb-empty i { font-size: 32px; color: var(--border); }
.hb-empty p { font-size: 14px; }

/* Checklist */
.hb-checklist { display: flex; flex-direction: column; gap: 8px; }
.hb-habit-row {
  display: flex; align-items: center; gap: 12px;
  padding: 0.75rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
}
.hb-habit-row--done { border-color: var(--success); background: color-mix(in srgb, var(--success) 6%, transparent); }
.hb-habit-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.hb-habit-info { flex: 1; min-width: 0; }
.hb-habit-name { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-habit-meta { margin-top: 2px; }
.hb-streak { font-size: 11px; color: var(--orange); font-weight: 600; }
.hb-streak--zero { color: var(--muted); font-weight: 400; }
.hb-habit-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.hb-check-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.hb-check-btn:hover { border-color: var(--success); color: var(--success); }
.hb-check-btn--done { background: var(--success); border-color: var(--success); color: #fff; }
.hb-check-btn--done:hover { background: color-mix(in srgb, var(--success) 85%, #000); }

.hb-edit-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 6px; border-radius: 6px; font-size: 14px; transition: color 0.15s, background 0.15s;
}
.hb-edit-btn:hover { color: var(--text-primary); background: var(--surface-2); }

/* Heatmap */
.hb-heatmap { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin-bottom: 8px; }
.hb-heat-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: color-mix(in srgb, var(--primary) calc(var(--pct) * 1%), var(--surface-2));
  cursor: default;
  transition: transform 0.1s;
}
.hb-heat-cell:hover { transform: scale(1.2); }
.hb-heat-cell--today { outline: 2px solid var(--primary); outline-offset: 1px; }
.hb-heatmap-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.hb-heatmap-legend span { font-size: 11px; color: var(--muted); }

/* Day detail popup */
.hb-day-popup {
  position: fixed; z-index: 2000;
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
  min-width: 200px; max-width: 260px; max-height: 60vh; overflow-y: auto;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
}
.hb-day-popup-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px; font-size: 12px; font-weight: 700; color: var(--text-primary);
}
.hb-day-popup-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 14px; padding: 0; line-height: 1; flex-shrink: 0;
}
.hb-day-popup-close:hover { color: var(--text-primary); }
.hb-day-popup-list { display: flex; flex-direction: column; gap: 0; }
.hb-day-popup-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-primary);
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.hb-day-popup-item:last-child { border-bottom: none; }
.hb-day-popup-empty { font-size: 12px; color: var(--muted); margin: 0; }
.hb-day-popup-loading { text-align: center; color: var(--muted); font-size: 14px; padding: 6px 0; }

/* Clickable heatmap cells */
.hb-heat-cell--clickable { cursor: pointer; }
.hb-heat-cell--clickable:hover { transform: scale(1.3); outline: 2px solid var(--primary); outline-offset: 1px; }

/* View tab switcher */
.hb-view-tabs { display: flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.hb-view-tab {
  padding: 4px 12px; border: none; border-radius: 6px; font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; background: transparent; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.hb-view-tab.active { background: var(--card); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.hb-view-tab:hover:not(.active) { color: var(--text-primary); }

/* Week view */
.hb-week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.hb-week-day {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
}
.hb-week-day--today { border-color: var(--primary); background: var(--primary-pale); }
.hb-week-day--future { opacity: 0.4; }
.hb-week-dayname { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.hb-week-date { font-size: 11px; color: var(--text-secondary); }
.hb-week-day--today .hb-week-dayname,
.hb-week-day--today .hb-week-date { color: var(--primary); }
.hb-week-bar-wrap {
  width: 100%; height: 60px; background: var(--surface-2);
  border-radius: 4px; overflow: hidden; display: flex; align-items: flex-end;
}
.hb-week-bar { width: 100%; min-height: 2px; border-radius: 4px; transition: height 0.4s; }
.hb-week-count { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.hb-week-count--link { cursor: pointer; color: var(--primary); text-decoration: underline; }
.hb-week-day--has-data .hb-week-bar-wrap:hover .hb-week-bar { filter: brightness(1.15); }

/* ── Modal: centered on mobile ───────────────────────────────── */
@media (max-width: 768px) {
  .hb-modal-overlay {
    padding: 1rem;
    align-items: center;
    justify-content: center;
    padding-top: calc(var(--topbar-h) + 1rem);
  }
  .hb-modal {
    max-height: calc(100dvh - var(--topbar-h) - 2rem);
    overflow-y: auto;
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-lg);
  }
  .hb-modal--wide { max-width: 100%; }
  .hb-modal-header { position: sticky; top: 0; background: var(--card); z-index: 1; }
}

@media (max-width: 480px) {
  .hb-week-dayname { font-size: 9px; }
  .hb-week-date { font-size: 9px; }
  .hb-week-count { font-size: 9px; }
  .hb-week-bar-wrap { height: 44px; }
  .hb-week-grid { gap: 3px; }
  .hb-week-day { padding: 5px 2px; gap: 2px; }
}
.hb-legend-cell { width: 12px; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--primary) calc(var(--pct) * 1%), var(--surface-2)); }

/* Stats grid */
.hb-stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.hb-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
.hb-stat-card--clickable { cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.hb-stat-card--clickable:hover { border-color: var(--primary); transform: translateY(-2px); }
.hb-stat-card--clickable:hover .hb-stat-name { color: var(--primary); }
.hb-stat-header { display: flex; align-items: center; gap: 8px; margin-bottom: 0.75rem; }
.hb-stat-icon { font-size: 20px; }
.hb-stat-name { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-stat-nums { display: flex; gap: 8px; margin-bottom: 0.75rem; }
.hb-stat-item { flex: 1; text-align: center; min-width: 0; }
.hb-stat-val { display: block; font-size: 16px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.hb-stat-lbl { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
.hb-bar-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.hb-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }

/* Form modal */
.hb-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; backdrop-filter: blur(2px); }
.hb-modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; width: 100%; max-width: 420px; position: relative; transition: max-width 0.2s; }
.hb-modal--wide { max-width: min(720px, 95vw); }
.hb-detail-stats { display: flex; gap: 8px; margin-bottom: 4px; }
.hb-detail-stats .hb-stat-item { flex: 1; text-align: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 4px; }
.hb-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.hb-modal-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }

.hb-icon-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.hb-icon-opt { width: 36px; height: 36px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: border-color 0.12s; }
.hb-icon-opt:hover { border-color: var(--primary); }
.hb-icon-opt.active { border-color: var(--primary); background: var(--primary-pale); }

.hb-color-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.hb-color-opt { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid transparent; cursor: pointer; transition: transform 0.12s, border-color 0.12s; }
.hb-color-opt:hover { transform: scale(1.15); }
.hb-color-opt.active { border-color: var(--text-primary); transform: scale(1.1); }

.hb-form-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.hb-section--archived { opacity: 0.85; }
.hb-archived-title { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.hb-archived-badge { background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 20px; }

.hb-archived-list { display: flex; flex-direction: column; gap: 6px; }
.hb-archived-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.hb-habit-icon--sm { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.hb-archived-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hb-archived-name { font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-archived-meta { font-size: 11px; color: var(--muted); }
.hb-archived-actions { display: flex; gap: 6px; flex-shrink: 0; }

.hb-filter-row { margin-bottom: 10px; }
.hb-search-wrap { position: relative; display: flex; align-items: center; }
.hb-search-icon { position: absolute; left: 10px; font-size: 13px; color: var(--muted); pointer-events: none; }
.hb-search-input {
  width: 100%; padding: 7px 32px 7px 30px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary); font-size: 13px;
  outline: none; transition: border-color 0.15s;
}
.hb-search-input:focus { border-color: var(--primary); }
.hb-search-clear {
  position: absolute; right: 6px; background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px;
  line-height: 1; border-radius: 4px;
}
.hb-search-clear:hover { color: var(--text-primary); background: var(--surface-2); }

.hb-filter-empty { padding: 20px 0; text-align: center; color: var(--muted); font-size: 13px; }
.hb-filter-empty i { margin-right: 6px; }

.hb-pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.hb-page-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-primary); cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.hb-page-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-pale); color: var(--primary); }
.hb-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.hb-page-info { font-size: 12px; color: var(--muted); min-width: 80px; text-align: center; }

@media (max-width: 480px) {
  .hb-page { padding: 0.75rem 0.75rem 4rem; }
  .hb-section { padding: 0.875rem; }
  .hb-section-header { flex-wrap: wrap; gap: 0.5rem; }
  .hb-habit-row { gap: 8px; }
  .hb-habit-icon { width: 34px; height: 34px; font-size: 17px; }
  .hb-heatmap { grid-template-columns: repeat(6, 1fr); }
  .hb-stats-grid { grid-template-columns: 1fr; }
  .hb-check-btn span { display: none; }
  .hb-modal { padding: 1rem; }
  .hb-form-actions { flex-wrap: wrap; gap: 8px; }
  .hb-form-actions > div:last-child { margin-left: auto; }
}

@media (max-width: 360px) {
  .hb-view-tab { padding: 4px 8px; font-size: 11px; }
  .hb-section-title { font-size: 13px; }
}

/* ── PDF Preview Modal ──────────────────────────────────────────────────── */

.sp-pdf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.sp-pdf-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  max-height: calc(100dvh - 3rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.sp-pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--card);
}

.sp-pdf-modal-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}

.sp-pdf-modal-title i { color: var(--orange); }

.sp-pdf-modal-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.sp-pdf-preview {
  overflow-y: auto;
  padding: 1.5rem;
  background: #2a2a2a;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

[data-theme="light"] .sp-pdf-preview { background: #d0d0d0; }

.sp-pdf-page {
  background: #ffffff;
  color: #1a1a2e;
  border-radius: 4px;
  padding: 2.5rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

.sp-pdf-note-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  padding-bottom: 10px;
  margin-bottom: 6px;
  border-bottom: 2px solid #E8581A;
}

.sp-pdf-note-meta {
  font-size: 12px;
  color: #888;
  margin-bottom: 1.25rem;
}

.sp-pdf-note-body { color: #1a1a2e; }
.sp-pdf-note-body h1 { font-size: 20px; font-weight: 700; margin: 1.25rem 0 .5rem; }
.sp-pdf-note-body h2 { font-size: 17px; font-weight: 600; margin: 1.1rem 0 .4rem; }
.sp-pdf-note-body h3 { font-size: 15px; font-weight: 600; margin: 1rem 0 .375rem; }
.sp-pdf-note-body p  { margin-bottom: .75rem; }
.sp-pdf-note-body ul,
.sp-pdf-note-body ol { padding-left: 1.5rem; margin-bottom: .75rem; }
.sp-pdf-note-body li { margin-bottom: .25rem; }
.sp-pdf-note-body blockquote {
  border-left: 3px solid #E8581A;
  margin: .75rem 0;
  padding: .5rem .875rem;
  background: #fff8f5;
  color: #555;
}
.sp-pdf-note-body code {
  background: #f4f4f6;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}
.sp-pdf-note-body pre {
  background: #f4f4f6;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: .75rem;
  overflow-x: auto;
}
.sp-pdf-note-body pre code { background: none; padding: 0; }
.sp-pdf-note-body table { border-collapse: collapse; width: 100%; margin-bottom: .75rem; }
.sp-pdf-note-body th,
.sp-pdf-note-body td { border: 1px solid #ddd; padding: 6px 10px; text-align: left; }
.sp-pdf-note-body th { background: #f4f4f6; font-weight: 600; }
.sp-pdf-note-body a  { color: #E8581A; }
.sp-pdf-note-body strong { font-weight: 700; }
.sp-pdf-note-body em { font-style: italic; }
.sp-pdf-note-body hr { border: none; border-top: 1px solid #ddd; margin: 1rem 0; }

/* Hidden frame used only during window.print() */
#sp-pdf-print-frame { display: none; }

/* ── Survival Mode ──────────────────────────────────────────────────────── */

.sv-page { display: flex; flex-direction: column; gap: 1rem; }
.sv-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.sv-hero .page-title { margin: 0 0 4px; }
.sv-hero-actions,
.sv-detail-actions,
.sv-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sv-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) repeat(4, minmax(130px, 1fr));
  gap: 8px;
}
.sv-search { position: relative; }
.sv-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.sv-search .form-input { padding-left: 30px; }
.sv-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.sv-modules,
.sv-study {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.sv-modules { padding: 0.75rem; }
.sv-study { padding: 1rem; }
.sv-section-head,
.sv-detail-head,
.sv-resource-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.sv-section-head {
  color: var(--text-primary);
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 0.75rem;
}
.sv-section-head strong { color: var(--primary); }
.sv-module-list { display: flex; flex-direction: column; gap: 8px; }
.sv-module-card {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-primary);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}
.sv-module-card:hover,
.sv-module-card--active { border-color: var(--primary); background: var(--primary-pale); }
.sv-module-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--sv-color) 16%, transparent);
  color: var(--sv-color);
}
.sv-module-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sv-module-copy strong,
.sv-module-copy span,
.sv-module-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sv-module-copy strong { font-size: 13px; }
.sv-module-copy span,
.sv-module-copy small,
.sv-detail-kicker,
.sv-phrase-top,
.sv-phrase-card small { color: var(--muted); font-size: 11px; }
.sv-module-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.sv-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}
.sv-level--general { min-width: 44px; background: var(--surface-2); color: var(--muted); }
.sv-detail-head { margin-bottom: 1rem; }
.sv-detail-head h2 { margin: 3px 0 4px; color: var(--text-primary); font-size: 22px; }
.sv-detail-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.sv-lesson-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
}
.sv-lesson-strip > span { font-size: 12px; font-weight: 800; color: var(--text-primary); margin-right: 4px; }
.sv-lesson-strip button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  cursor: pointer;
}
.sv-lesson-strip small { color: var(--muted); font-size: 12px; }
.sv-lesson-add { width: 28px; height: 28px; padding: 0 !important; }
.sv-mode-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 1rem;
}
.sv-mode-tabs button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
}
.sv-mode-tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.sv-phrase-list { display: flex; flex-direction: column; gap: 10px; }
.sv-phrase-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 12px;
}
.sv-phrase-main { min-width: 0; flex: 1; }
.sv-phrase-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.sv-phrase-card h3 { margin: 0 0 4px; color: var(--text-primary); font-size: 17px; line-height: 1.35; }
.sv-phrase-card p { margin: 0 0 6px; color: var(--text-secondary); font-size: 13px; }
.sv-phrase-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.sv-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.sv-tags button {
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  padding: 3px 7px;
  cursor: pointer;
}
.sv-fav-active { color: #E0A52B !important; }
.sv-listening-mask {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}
.sv-hidden-text { filter: blur(4px); user-select: none; }
.sv-flash-wrap { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.sv-flash-counter { color: var(--muted); font-size: 12px; }
.sv-flash-card {
  width: min(520px, 100%);
  min-height: 230px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 1.5rem;
  cursor: pointer;
  text-align: center;
}
.sv-flash-card span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.sv-flash-card strong { font-size: clamp(22px, 4vw, 36px); line-height: 1.2; }
.sv-flash-actions,
.sv-quiz-options,
.sv-audio-grid { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sv-audio-grid button,
.sv-quiz-options button {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-primary);
  padding: 12px;
  cursor: pointer;
}
.sv-quiz { text-align: center; display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.sv-quiz span { color: var(--muted); font-size: 12px; font-weight: 800; }
.sv-quiz h3 { margin: 0; font-size: 24px; color: var(--text-primary); }
.sv-scenario-group { margin-bottom: 1rem; }
.sv-scenario-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
  font-size: 15px;
  margin: 0 0 8px;
}
.sv-welcome {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  gap: 8px;
}
.sv-welcome i { font-size: 42px; color: var(--primary); }
.sv-welcome h2 { margin: 0; color: var(--text-primary); }
.sv-welcome p { max-width: 460px; margin: 0; line-height: 1.6; }
.sv-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.sv-modal {
  width: min(560px, 100%);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sv-modal-title { font-size: 18px; font-weight: 800; color: var(--text-primary); margin-bottom: 2px; }
.sv-modal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sv-share-classes { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.sv-share-classes button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  cursor: pointer;
}
.sv-share-classes small { margin-left: auto; color: var(--muted); }

/* ── Study activity Kanban ──────────────────────────────────────────────── */

.sp-kanban-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.sp-kanban-toolbar strong { display: block; color: var(--text-primary); font-size: 14px; }
.sp-kanban-toolbar span { color: var(--muted); font-size: 12px; }
.sp-kanban-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sp-kanban-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.sp-kanban-column {
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 8px;
}
.sp-kanban-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}
.sp-kanban-column-head strong {
  color: var(--primary);
  background: var(--primary-pale);
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
  padding: 2px 6px;
}
.sp-kanban-list { display: flex; flex-direction: column; gap: 8px; min-height: 72px; }
.sp-kanban-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 9px;
  cursor: grab;
}
.sp-kanban-card:active { cursor: grabbing; }
.sp-kanban-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.sp-kanban-card-top span,
.sp-kanban-meta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.sp-kanban-card strong {
  display: block;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.35;
}
.sp-kanban-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.sp-kanban-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.sp-kanban-meta span {
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 6px;
}
.sp-kanban-check {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: transparent;
  cursor: pointer;
}
.sp-kanban-check.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.sp-kanban-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 12px 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

@media (max-width: 980px) {
  .sv-layout { grid-template-columns: 1fr; }
  .sv-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .sv-hero,
  .sv-detail-head,
  .sv-phrase-card { flex-direction: column; }
  .sv-hero-actions,
  .sv-detail-actions,
  .sv-phrase-actions { justify-content: flex-start; }
  .sv-filters,
  .sv-modal-grid { grid-template-columns: 1fr; }
  .sv-study,
  .sv-modules { padding: 0.75rem; }
  .sv-mode-tabs button span { display: none; }
}

/* ── English level resource links ───────────────────────────────────────── */

/* ── Level component ──────────────────────────────────────────────────────── */

/* ── CEFR color tokens ─────────────────────────────────────────────────────  */
:root {
  --level-a-bg:  rgba(34,197,94,0.12);   --level-a-text:  #15803d;  --level-a-border: #22c55e;
  --level-b-bg:  rgba(59,130,246,0.12);  --level-b-text:  #1d4ed8;  --level-b-border: #3b82f6;
  --level-c-bg:  rgba(249,115,22,0.12);  --level-c-text:  #c2410c;  --level-c-border: #f97316;
  --level-g-bg:  var(--surface-2);       --level-g-text:  var(--muted); --level-g-border: var(--border);
}

/* ── Badge (topic pills, item cards, flashcards) ───────────────────────────  */
.sp-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.03em;
  /* default = primary */
  background: var(--primary-pale);
  color: var(--primary);
}
.sp-level-badge--general { background: var(--level-g-bg); color: var(--level-g-text); min-width: 40px; }
.sp-level-badge--a       { background: var(--level-a-bg); color: var(--level-a-text); }
.sp-level-badge--b       { background: var(--level-b-bg); color: var(--level-b-text); }
.sp-level-badge--c       { background: var(--level-c-bg); color: var(--level-c-text); }

/* ── Filter row (main Study Plan view) ─────────────────────────────────────  */
.sp-level-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 0.75rem;
  flex-wrap: wrap;
}

.sp-level-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

/* Scrollable pill strip */
.sp-level-filter-pills {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;        /* Firefox */
  padding-bottom: 2px;          /* clip shadow */
  flex: 1;
  min-width: 0;
}
.sp-level-filter-pills::-webkit-scrollbar { display: none; }

/* Individual filter pill */
.sp-level-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.13s, color 0.13s, border-color 0.13s, box-shadow 0.13s;
  white-space: nowrap;
}
.sp-level-pill:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

/* Active states per group */
.sp-level-pill--all.sp-level-pill--active {
  background: var(--primary-pale);
  color: var(--primary);
  border-color: var(--primary);
}
.sp-level-pill--general.sp-level-pill--active {
  background: var(--level-g-bg); color: var(--level-g-text); border-color: var(--border-2);
}
.sp-level-pill--a.sp-level-pill--active {
  background: var(--level-a-bg); color: var(--level-a-text); border-color: var(--level-a-border);
}
.sp-level-pill--b.sp-level-pill--active {
  background: var(--level-b-bg); color: var(--level-b-text); border-color: var(--level-b-border);
}
.sp-level-pill--c.sp-level-pill--active {
  background: var(--level-c-bg); color: var(--level-c-text); border-color: var(--level-c-border);
}
.sp-level-pill--active { font-weight: 700; }

/* ── Picker (create/edit modals) ────────────────────────────────────────────  */
.sp-level-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sp-level-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  min-width: 44px;
}
.sp-level-pick:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-2);
}

/* Active states per group */
.sp-level-pick--general.sp-level-pick--active {
  background: var(--level-g-bg); color: var(--level-g-text); border-color: var(--border-2);
}
.sp-level-pick--a.sp-level-pick--active {
  background: var(--level-a-bg); color: var(--level-a-text); border-color: var(--level-a-border);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.sp-level-pick--b.sp-level-pick--active {
  background: var(--level-b-bg); color: var(--level-b-text); border-color: var(--level-b-border);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.sp-level-pick--c.sp-level-pick--active {
  background: var(--level-c-bg); color: var(--level-c-text); border-color: var(--level-c-border);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}
.sp-level-pick--active { font-weight: 700; }

.el-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.el-detail-header--general {
  --level-color: var(--primary);
}

.el-linked-resources {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.el-linked-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.el-linked-kicker {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 2px;
}

.el-linked-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
}

.el-linked-total {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.el-resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.el-resource-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  overflow: hidden;
}

.el-resource-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
}

.el-resource-panel-head span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.el-resource-panel-head i { color: var(--primary); }
.el-resource-panel-head strong { color: var(--primary); }

.el-resource-list {
  display: flex;
  flex-direction: column;
}

.el-resource-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px;
}

.el-resource-item:last-child { border-bottom: 0; }
button.el-resource-item { cursor: pointer; }
button.el-resource-item:hover { background: var(--surface-2); }

.el-resource-item span:first-child {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 13px;
}

.el-resource-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.el-resource-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.el-resource-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 14px 12px;
}

@media (max-width: 980px) {
  .el-resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .el-header-actions { width: 100%; justify-content: flex-start; }
  .el-resource-grid { grid-template-columns: 1fr; }
  .el-linked-header { flex-direction: column; gap: 4px; }
  .sp-level-filter-row { flex-wrap: nowrap; align-items: center; }
  .sp-level-filter-label { display: none; }
  .sp-level-filter-pills { flex: 1; }
  .sp-level-picker { flex-wrap: wrap; }
  .sp-level-pick { flex: 1; min-width: 48px; }
}

/* ── Feedback ───────────────────────────────────────────────────────────── */

.feedback-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 1rem;
  align-items: start;
}

.feedback-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 1rem;
}

.feedback-form {
  display: grid;
  gap: 0.875rem;
}

.feedback-upload {
  display: grid;
  gap: 0.5rem;
}

.feedback-upload label {
  min-height: 44px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-primary);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 700;
}

.feedback-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.feedback-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.feedback-file-list span,
.feedback-tech span,
.feedback-card-meta span {
  border-radius: 999px;
  background: var(--surface-2);
  padding: 4px 8px;
}

.feedback-tech,
.feedback-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.feedback-message {
  display: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 13px;
}

.feedback-message.success,
.feedback-message.error {
  display: block;
}

.feedback-message.success {
  color: var(--success);
  background: var(--success-bg);
}

.feedback-message.error {
  color: var(--danger);
  background: var(--danger-bg);
}

.feedback-list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.875rem;
}

.feedback-list-head strong {
  display: block;
  color: var(--text-primary);
  font-size: 15px;
}

.feedback-list-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.feedback-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 0.875rem;
  margin-bottom: 0.75rem;
}

.feedback-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.5rem;
}

.feedback-category,
.feedback-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.feedback-category {
  color: var(--primary);
  background: var(--primary-pale);
}

.feedback-status.status-open { color: var(--orange); background: rgba(255, 165, 0, 0.12); }
.feedback-status.status-in_review { color: var(--primary); background: var(--primary-pale); }
.feedback-status.status-resolved { color: var(--success); background: var(--success-bg); }
.feedback-status.status-closed { color: var(--muted); background: var(--surface-2); }

.feedback-card strong {
  display: block;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.35;
}

.feedback-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0.4rem 0 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 920px) {
  .feedback-layout { grid-template-columns: 1fr; }
}

@media print {
  body > *:not(#sp-pdf-print-frame) { display: none !important; }
  #sp-pdf-print-frame {
    display: block !important;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.65;
    color: #1a1a2e;
    padding: 1.5cm;
  }
  #sp-pdf-print-frame .sp-pdf-page {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    page-break-after: always;
  }
  #sp-pdf-print-frame .sp-pdf-page:last-child { page-break-after: avoid; }
}

@media (max-width: 768px) {
  .sp-pdf-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .sp-pdf-modal {
    max-height: calc(100dvh - var(--topbar-h));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .sp-pdf-modal-header { flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1rem; }
  .sp-pdf-modal-actions { width: 100%; }
  .sp-pdf-modal-actions .btn { flex: 1; justify-content: center; }
  .sp-pdf-preview { padding: 1rem; gap: 1rem; }
  .sp-pdf-page { padding: 1.25rem; }
  .sp-pdf-note-title { font-size: 18px; }
}

/* ── Segment rendering (used in editor, word cards, flashcards) ──────────── */
.sp-seg      { display: inline; }
.sp-seg-bold { font-weight: 700; }
/* Colors applied via inline style from spRenderSegments — no static color classes needed */

/* ── Contenteditable rich-text field ────────────────────────────────────── */
.sp-cefield {
  min-height: 42px;
  padding: 9px 12px;
  font-size: 15px;
  line-height: 1.75;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1.5px solid var(--border);
  cursor: text;
  outline: none;
  word-break: break-word;
  transition: border-color 0.15s, box-shadow 0.15s;
  user-select: text;
}
.sp-cefield:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 99,102,241), 0.12);
}
.sp-cefield:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
  font-style: italic;
}
.sp-cefield::selection,
.sp-cefield *::selection { background: rgba(99,102,241,0.18); }

/* ── Segment chips ─────────────────────────────────────────────────────── */
.sp-seg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.sp-seg-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 6px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 210px;
  overflow: hidden;
}
.sp-seg-chip-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;
}
.sp-seg-chip-rm {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 12px; line-height: 1;
  padding: 0 0 0 2px; flex-shrink: 0; transition: color 0.12s;
}
.sp-seg-chip-rm:hover { color: #ef4444; }

/* ── Floating formatting toolbar ─────────────────────────────────────────── */
.sp-seg-ftb {
  position: fixed;
  z-index: 3000;
  display: none;           /* overridden to flex-direction:column when shown */
  flex-direction: column;
  gap: 0;
  padding: 6px 8px;
  background: #1e2330;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.32), 0 2px 8px rgba(0,0,0,0.18);
  pointer-events: all;
  opacity: 0;
  transform: translateY(4px) scale(0.97);
  transition: opacity 0.14s ease, transform 0.14s ease;
  min-width: 0;
}

/* Arrow: default (toolbar above selection) → points down */
.sp-seg-ftb::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e2330;
}
/* Arrow flip: toolbar below selection → points up */
.sp-seg-ftb--below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1e2330;
}
.sp-seg-ftb--visible { opacity: 1; transform: translateY(0) scale(1); }

/* Each row inside the toolbar */
.sp-seg-ftb-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.sp-seg-ftb-row-tx { padding-top: 1px; }
.sp-seg-ftb-row-label {
  font-size: 9px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 3px 0 1px;
  user-select: none;
  flex-shrink: 0;
}
.sp-seg-ftb-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 3px 0;
}

.sp-seg-ftb-sep { width: 1px; height: 16px; background: rgba(255,255,255,0.14); margin: 0 2px; }

.sp-seg-ftb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  background: transparent;
  transition: background 0.12s, box-shadow 0.12s;
  min-width: 26px;
}
.sp-seg-ftb-btn:hover { background: rgba(255,255,255,0.1); }

/* Active state — when selection sits inside a matching segment */
.sp-seg-ftb-btn--active {
  background: rgba(255,255,255,0.18) !important;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.35);
}

/* Color dot circles */
.sp-seg-ftb-color { min-width: 24px; padding: 4px 5px; }

.sp-seg-ftb-clear { color: #94a3b8; min-width: 24px; }
.sp-seg-ftb-clear:hover { color: #f87171; background: rgba(239,68,68,0.12); }

/* Text-color "A" buttons */
.sp-seg-ftb-textcolor { min-width: 22px; padding: 3px 5px; font-size: 13px; }

/* Color dot (toolbar + chips) */
.sp-seg-ftb-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.22);
}

/* ── Language field card ───────────────────────────────────────────────────── */
.sp-lang-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.sp-lang-card:focus-within { border-color: var(--primary); }

.sp-lang-card-hdr {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.sp-lang-badge {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: 0.04em;
}
.sp-lang-badge-en { background: #dbeafe; color: #1d4ed8; }
.sp-lang-badge-pt { background: #dcfce7; color: #15803d; }
.sp-lang-req { color: var(--danger, #ef4444); font-size: 13px; line-height: 1; }
.sp-lang-card-hint {
  margin-left: auto;
  font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 4px;
}

/* Field inside card: no outer border/radius — card provides them */
.sp-lang-card .sp-cefield {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
}
.sp-lang-card .sp-seg-chips { padding: 0 10px 8px; }

/* ── Collapsible "Mais detalhes" ──────────────────────────────────────────── */
.sp-item-more {
  margin-top: 4px;
}
.sp-item-more-summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.12s;
  border-radius: var(--radius);
}
.sp-item-more-summary::-webkit-details-marker { display: none; }
.sp-item-more-summary::marker { display: none; }
.sp-item-more-summary:hover { color: var(--text-primary); }
.sp-item-more[open] .sp-item-more-summary { color: var(--text-primary); }
.sp-item-more-body {
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ══════════════════════════════════════════════════════════════════
   SURVIVAL GUIDE — .sg-*
   ══════════════════════════════════════════════════════════════════ */

/* ── Page wrapper ───────────────────────────────────────────────── */
.sg-page {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

.sg-page--student {
  max-width: 1080px;
}

/* ── Hero ───────────────────────────────────────────────────────── */
.sg-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.sg-hero-text { flex: 1; min-width: 0; }
.sg-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sg-page--student .sg-hero {
  margin-bottom: 1rem;
}

.sg-page--student .page-title {
  font-size: clamp(24px, 3vw, 34px);
}

.sg-page--student .page-subtitle {
  max-width: 520px;
}

/* ── Search bar ─────────────────────────────────────────────────── */
.sg-searchbar {
  margin-bottom: 1.5rem;
}
.sg-searchbar-inner {
  position: relative;
  display: flex;
  align-items: center;
}
.sg-searchbar-ico {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
  font-size: 14px;
}
.sg-searchbar-input {
  width: 100%;
  padding: 10px 40px 10px 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
}
.sg-searchbar-input::placeholder { color: var(--muted); }
.sg-searchbar-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}
.sg-searchbar-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  font-size: 13px;
}
.sg-searchbar-clear:hover { color: var(--text-primary); }

/* ── View body ──────────────────────────────────────────────────── */
.sg-view-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sg-student-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 2px;
}

.sg-student-section strong {
  color: var(--text-primary);
  font-size: 17px;
}

.sg-student-section span {
  color: var(--muted);
  font-size: 13px;
}

.sg-student-section--phrases {
  margin-top: -4px;
  margin-bottom: 4px;
}

/* ── Search results header ──────────────────────────────────────── */
.sg-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 14px;
  color: var(--muted);
  padding-bottom: 4px;
}

/* ── Categories grid ─────────────────────────────────────────────── */
.sg-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.sg-cat-grid--student {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* ── Category card ──────────────────────────────────────────────── */
.sg-cat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease), transform 0.1s;
  position: relative;
}
.sg-cat-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.sg-cat-card--inactive { opacity: 0.55; }

.sg-cat-card--student {
  min-height: 84px;
  padding: 14px;
  border-radius: var(--radius-sm);
}

.sg-cat-card--student .sg-cat-name {
  font-size: 14px;
}

.sg-cat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sg-cat-body { flex: 1; min-width: 0; }
.sg-cat-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sg-cat-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sg-cat-desc--student {
  display: block;
  margin-top: 2px;
  -webkit-line-clamp: unset;
}
.sg-cat-arrow {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}
.sg-cat-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  margin-top: 4px;
}
.sg-cat-badge--off { background: var(--danger-bg); color: var(--danger); }
.sg-cat-admin {
  display: none;
  position: absolute;
  top: 10px; right: 10px;
  gap: 4px;
}
.sg-cat-card:hover .sg-cat-admin { display: flex; }

/* ── Phrases header ─────────────────────────────────────────────── */
.sg-phrases-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.sg-phrases-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.sg-phrases-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.sg-count-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--primary-subtle);
  color: var(--primary);
  border-radius: var(--radius-full);
}

/* ── Phrase grid ─────────────────────────────────────────────────── */
.sg-phrase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  align-items: start;
}

.sg-page--student .sg-phrase-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ── Phrase card ─────────────────────────────────────────────────── */
.sg-phrase-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.sg-phrase-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}

.sg-phrase-card--student {
  gap: 12px;
  padding: 15px;
  border-radius: var(--radius-sm);
}

.sg-phrase-card--student .sg-phrase-en {
  font-size: 15px;
}

.sg-phrase-card--student .sg-phrase-pt {
  font-size: 13px;
}

.sg-phrase-card--student .sg-phrase-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sg-phrase-card--student .sg-act-examples {
  grid-column: 1 / -1;
}

.sg-phrase-card--student .sg-act-btn {
  justify-content: center;
}
.sg-phrase-langs { display: flex; flex-direction: column; gap: 6px; }
.sg-phrase-en {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.sg-phrase-pt {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  font-style: italic;
}
.sg-phrase-ctx {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 5px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.sg-phrase-ctx i { margin-top: 1px; flex-shrink: 0; }

.sg-phrase-kws {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.sg-kw {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--primary-subtle);
  color: var(--primary);
  border-radius: var(--radius-full);
}

/* ── Phrase action buttons ───────────────────────────────────────── */
.sg-phrase-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.sg-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
  white-space: nowrap;
}
.sg-act-btn:hover { background: var(--surface-hover); color: var(--text-primary); border-color: var(--border-2); }
.sg-act-audio--has { color: var(--primary); border-color: var(--primary-subtle); background: var(--primary-pale); }
.sg-act-audio--has:hover { background: var(--primary-subtle); }
.sg-act-practice { color: var(--success); border-color: rgba(61,190,122,0.2); background: var(--success-bg); }
.sg-act-practice:hover { background: rgba(61,190,122,0.2); }
.sg-act-examples { color: var(--warning); border-color: rgba(232,165,48,0.2); background: var(--warning-bg); }
.sg-act-examples:hover { background: rgba(232,165,48,0.2); }

/* ── Phrase admin controls ───────────────────────────────────────── */
.sg-phrase-admin {
  display: flex;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── Load more ───────────────────────────────────────────────────── */
.sg-load-more { margin: 0 auto; }

/* ══════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════ */
.sg-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.sg-modal-overlay--visible { opacity: 1; }

.sg-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: translateY(6px);
  transition: transform 0.18s ease;
}
.sg-modal-overlay--visible .sg-modal { transform: translateY(0); }

.sg-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sg-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sg-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  transition: color var(--ease);
}
.sg-modal-close:hover { color: var(--text-primary); }

.sg-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.sg-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sg-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Phrase form (in modal) ─────────────────────────────────────── */
.sg-phrase-form .form-label { margin-bottom: 4px; }

/* ── Examples in create form ─────────────────────────────────────── */
.sg-ex-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.sg-ex-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: start;
}
.sg-ex-row:not(:has(button)) { grid-template-columns: 1fr 1fr; }
.sg-add-ex-btn { align-self: flex-start; }

/* ── Examples manage section (edit modal) ────────────────────────── */
.sg-ex-manage-section {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.sg-ex-manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sg-ex-manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.sg-ex-manage-texts { flex: 1; min-width: 0; }
.sg-ex-manage-en { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.sg-ex-manage-pt { font-size: 12px; color: var(--muted); font-style: italic; }
.sg-ex-manage-actions { display: flex; gap: 4px; flex-shrink: 0; }
.sg-ex-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 12px 0; }

/* ══════════════════════════════════════════════════════════════════
   EXAMPLES MODAL (read-only)
   ══════════════════════════════════════════════════════════════════ */
.sg-ex-source {
  padding: 14px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.sg-ex-source-en { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.sg-ex-source-pt { font-size: 13px; color: var(--muted); margin-top: 4px; font-style: italic; }

.sg-examples-list {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sg-example-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.sg-ex-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.sg-ex-texts { flex: 1; min-width: 0; }
.sg-ex-en {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}
.sg-ex-en strong { font-weight: 700; color: var(--primary, #4F8EF7); }
.sg-ex-pt {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  font-style: italic;
  line-height: 1.4;
}
.sg-ex-audio-btn {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--primary-subtle);
  color: var(--primary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: background 0.15s ease, transform 0.1s ease;
  margin-top: 1px;
}
.sg-ex-audio-btn:hover { background: var(--primary); color: #fff; transform: scale(1.08); }
.sg-ex-audio-btn--tts  { background: var(--surface-2); color: var(--muted); }
.sg-ex-audio-btn--tts:hover { background: var(--border); color: var(--text-primary); }

/* Container for audio + edit buttons per example row */
.sg-ex-item-actions {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex-shrink: 0;
}

/* Edit button inside examples modal */
.sg-ex-edit-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  margin-top: 1px;
  flex-shrink: 0;
}
.sg-ex-edit-btn:hover { background: var(--warning, #e0a52b); color: #fff; transform: scale(1.08); }

/* Empty state inside examples modal */
.sg-examples-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
.sg-examples-empty i { font-size: 28px; margin-bottom: 10px; display: block; }
.sg-examples-empty p { font-size: 14px; margin: 0; }

/* ══════════════════════════════════════════════════════════════════
   AUDIO MODAL
   ══════════════════════════════════════════════════════════════════ */
.sg-audio-phrase {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sg-audio-status { margin-bottom: 16px; }
.sg-audio-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}
.sg-audio-badge--has { background: var(--success-bg); color: var(--success); }
.sg-audio-badge--none { background: var(--danger-bg); color: var(--danger); }
.sg-audio-player { width: 100%; border-radius: var(--radius-sm); }
.sg-audio-actions { display: flex; flex-direction: column; gap: 8px; }
.sg-audio-btn { justify-content: flex-start; }
.sg-upload-label { cursor: pointer; }

/* ══════════════════════════════════════════════════════════════════
   PRACTICE
   ══════════════════════════════════════════════════════════════════ */
.sg-practice {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}
.sg-practice-back { align-self: flex-start; }

.sg-practice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sg-practice-phrase { display: flex; flex-direction: column; gap: 8px; }
.sg-practice-en {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.sg-practice-pt {
  font-size: 16px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
}
.sg-practice-ctx {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: var(--surface-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.sg-practice-audio-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.sg-play-ref-btn { flex-shrink: 0; }
.sg-practice-attempts {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.sg-practice-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.sg-practice-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}
.sg-practice-steps li i {
  width: 18px;
  color: var(--primary);
  flex-shrink: 0;
  text-align: center;
}

/* ── Record area ─────────────────────────────────────────────────── */
.sg-record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 24px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

/* ── Recorder — novo sistema de botão ────────────────────────────── */
.sg-recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.sg-recorder-btn {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
  overflow: visible;
}

.sg-recorder-btn::before,
.sg-recorder-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  animation: sg-ring-idle 2.8s ease-out infinite;
  pointer-events: none;
}
.sg-recorder-btn::after { animation-delay: 1.4s; }

@keyframes sg-ring-idle {
  0%   { transform: scale(1);    opacity: 0.55; }
  100% { transform: scale(1.62); opacity: 0;    }
}

.sg-recorder-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 32px rgba(108,116,220,0.40);
}
.sg-recorder-btn:active { transform: scale(0.96); }

.sg-recorder-icon {
  font-size: 30px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Stop button (estado gravando) */
.sg-recorder-btn--stop {
  background: var(--danger);
  box-shadow: 0 4px 20px rgba(224,90,90,0.30);
}
.sg-recorder-btn--stop::before,
.sg-recorder-btn--stop::after {
  border-color: var(--danger);
  animation: sg-ring-record 1.5s ease-out infinite;
}
.sg-recorder-btn--stop:hover { box-shadow: 0 6px 30px rgba(224,90,90,0.44); }

@keyframes sg-ring-record {
  0%   { transform: scale(1);    opacity: 0.65; }
  100% { transform: scale(1.50); opacity: 0;    }
}

/* Status "GRAVANDO" */
.sg-recorder-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--danger);
}

.sg-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  animation: sg-dot-blink 1s ease-in-out infinite;
}

@keyframes sg-dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.15; }
}

/* Barra de progresso */
.sg-recorder-progress {
  width: 100%;
  max-width: 180px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.sg-recorder-progress-fill {
  height: 100%;
  background: var(--danger);
  border-radius: 2px;
  transition: width 0.9s linear;
}

/* Footer do recorder */
.sg-recorder-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sg-recorder-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.sg-recorder--active .sg-recorder-label { color: var(--danger); }

.sg-recorder-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ── Record result ───────────────────────────────────────────────── */
.sg-record-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.sg-record-success {
  font-size: 16px;
  font-weight: 600;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sg-record-result p { font-size: 14px; color: var(--muted); }
.sg-record-result-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ── Shadowing comparison area ───────────────────────────────────── */
.sg-shadowing-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

.sg-shadowing-done {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-bg);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  letter-spacing: 0.01em;
}

.sg-shadowing-players {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  width: 100%;
}

.sg-player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.sg-player-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.sg-player-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sg-player-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 0 0 6px var(--primary-pale);
}

.sg-player-btn--user {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}
.sg-player-btn--user:hover {
  box-shadow: 0 0 0 6px rgba(61,190,122,0.14);
}

.sg-player-btn--playing {
  animation: sg-player-pulse 1.2s ease-in-out infinite;
}
.sg-player-btn--user.sg-player-btn--playing {
  animation: sg-player-pulse-green 1.2s ease-in-out infinite;
}

@keyframes sg-player-pulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(108,116,220,0.45); }
  50%       { box-shadow: 0 0 0 10px rgba(108,116,220,0);   }
}
@keyframes sg-player-pulse-green {
  0%, 100% { box-shadow: 0 0 0 0   rgba(61,190,122,0.45); }
  50%       { box-shadow: 0 0 0 10px rgba(61,190,122,0);   }
}

.sg-player-vs {
  color: var(--border);
  font-size: 18px;
  padding: 0 4px;
  margin-top: 28px;
}

.sg-compare-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 22px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 0.01em;
}
.sg-compare-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-pale);
}
.sg-compare-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.sg-shadowing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Practice examples ───────────────────────────────────────────── */
.sg-practice-examples {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.sg-practice-ex-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sg-page { padding: 1rem 1rem 2.5rem; }
  .sg-cat-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .sg-phrase-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sg-hero { flex-direction: column; align-items: stretch; }
  .sg-hero-actions { flex-direction: row; }
  .sg-cat-grid { grid-template-columns: 1fr; }
  .sg-phrase-grid { grid-template-columns: 1fr; }
  .sg-phrases-header { gap: 8px; }
  .sg-btn-label { display: none; }
  .sg-practice-en { font-size: 18px; }
  .sg-practice-pt { font-size: 14px; }
  .sg-modal { max-height: 95vh; }
  .sg-ex-row { grid-template-columns: 1fr; }
  .sg-ex-row:not(:has(button)) { grid-template-columns: 1fr; }
  .sg-phrase-actions { gap: 4px; }
  .sg-act-btn { padding: 5px 9px; font-size: 11px; }
}

@media (max-width: 420px) {
  .sg-page { padding: 0.75rem 0.75rem 2rem; }
  .sg-practice-card { padding: 16px; }
  .sg-recorder-btn { width: 88px; height: 88px; }
  .sg-recorder-icon { font-size: 26px; }
  .sg-player-btn { width: 68px; height: 68px; font-size: 20px; }
  .sg-shadowing-players { gap: 14px; }
}

/* ══════════════════════════════════════════════════════════════════
   SMART SEARCH — Suggestion card (.sg-suggestion-*)
   ══════════════════════════════════════════════════════════════════ */

.sg-suggestion-card {
  background: var(--surface);
  border: 1px solid var(--primary-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 0 0 3px var(--primary-pale);
}
.sg-suggestion-card--notranslate {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  border-color: var(--border);
  box-shadow: none;
}

.sg-suggestion-header {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}
.sg-suggestion-bulb { font-size: 15px; }

.sg-suggestion-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
}
.sg-suggestion-lang { display: flex; flex-direction: column; gap: 6px; }
.sg-sugg-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}
.sg-sugg-badge--src { background: var(--success-bg); color: var(--success); }
.sg-sugg-badge--tgt { background: var(--primary-subtle); color: var(--primary); }

.sg-sugg-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
}
.sg-sugg-text--translated {
  color: var(--primary);
  font-weight: 600;
}

.sg-suggestion-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 24px;
  color: var(--muted);
  font-size: 13px;
}

.sg-suggestion-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sg-sugg-cat { max-width: 280px; }

.sg-suggestion-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* not-translate state */
.sg-suggestion-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
}
.sg-suggestion-body { flex: 1; }
.sg-suggestion-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.sg-suggestion-hint { font-size: 13px; color: var(--muted); }

/* ── Status de cadastro (etapas pós-registro) ────────────────────── */
.sg-register-status-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  transition: opacity 0.5s ease;
}
.sg-register-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.sg-register-step--active { color: var(--text-primary); }
.sg-register-step--muted  { color: var(--muted); font-style: italic; }
.sg-register-step--error  { color: var(--danger); background: var(--danger-bg, #fff1f1); }
.sg-step-icon       { font-size: 13px; width: 16px; text-align: center; }
.sg-step-icon--done  { color: var(--success); }
.sg-step-icon--error { color: var(--danger); }

/* Legacy single-line status (kept for compatibility) */
.sg-register-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}
.sg-register-status--saving { color: var(--primary); }

/* ── Indicador de geração de áudio ───────────────────────────────── */
.sg-audio-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  transition: opacity 0.4s ease;
}
.sg-audio-indicator--done {
  color: var(--success);
  background: var(--success-bg);
}
.sg-audio-indicator--warn {
  color: var(--warning);
  background: var(--warning-bg);
}

@media (max-width: 560px) {
  .sg-suggestion-pair {
    grid-template-columns: 1fr;
  }
  .sg-suggestion-sep { display: none; }
  .sg-sugg-cat { max-width: 100%; }
}
