/* ============================================================
   StudyCircle — Main Stylesheet
   Theme: Dark Academic / Editorial — refined, focused, warm
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Variables ---------------------------------------- */
:root {
  --bg:          #0F0E0C;
  --bg-2:        #161410;
  --bg-3:        #1E1B16;
  --bg-card:     #1A1814;
  --border:      #2A2620;
  --border-soft: #231F1A;
  --text:        #F0EBE3;
  --text-muted:  #8A8070;
  --text-subtle: #5A5248;
  --gold:        #C9A84C;
  --gold-2:      #E8C878;
  --gold-dim:    rgba(201,168,76,0.12);
  --green:       #5CB880;
  --green-dim:   rgba(92,184,128,0.12);
  --red:         #E05A5A;
  --red-dim:     rgba(224,90,90,0.10);
  --blue:        #6B9FD4;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
  --transition:  0.2s ease;
  --font-serif:  'DM Serif Display', Georgia, serif;
  --font-sans:   'DM Sans', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ---- Layout ----------------------------------------------- */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.main-content {
  padding: 40px 48px;
  overflow-x: hidden;
}

/* ── Tablet (≤900px) ──────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 200px 1fr; }
  .main-content { padding: 28px 20px; }
  .stats-row { grid-template-columns: repeat(2,1fr); }
}

/* ---- Sidebar ---------------------------------------------- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 32px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0 24px 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.sidebar-logo h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--gold);
  letter-spacing: -0.01em;
}

.sidebar-logo span {
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.nav-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 24px;
  margin-bottom: 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.18s ease;
  border-left: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border-left-color: rgba(255,255,255,0.15);
  padding-left: 28px;
}

.nav-item.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: var(--gold-dim);
}

.nav-item.active:hover {
  padding-left: 24px;
  background: var(--gold-dim);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  transition: opacity 0.18s ease, transform 0.18s ease;
  flex-shrink: 0;
}

.nav-item:hover .nav-icon {
  opacity: 1;
  transform: scale(1.1);
}

.sidebar-footer {
  margin-top: auto;
  padding: 24px 24px 0;
  border-top: 1px solid var(--border);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.875rem;
  color: var(--gold);
  flex-shrink: 0;
}

.user-info .user-name { font-size: 0.875rem; font-weight: 500; }
.user-info .user-role {
  font-size: 0.7rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

/* ---- Typography ------------------------------------------- */
.page-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.section-title {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 600;
  margin-bottom: 16px;
}

/* ---- Cards ------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--border-soft); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ---- Plan Card -------------------------------------------- */
.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.plan-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 12px 40px rgba(201,168,76,0.15), 0 4px 12px rgba(0,0,0,0.3);
}

.plan-card:active {
  transform: translateY(-1px);
}

.plan-card-header {
  height: 6px;
}

.plan-card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.plan-card-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: 6px;
  line-height: 1.3;
}

.plan-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plan-card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.plan-meta {
  display: flex;
  gap: 16px;
}

.plan-meta-item {
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

.plan-meta-item span { color: var(--text-muted); }

/* ---- Progress Bar ----------------------------------------- */
.progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

.progress-percent {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--gold);
}

/* ---- Stats Row -------------------------------------------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Ripple shine on hover */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.18s ease;
  pointer-events: none;
}
.btn:hover::after { background: rgba(255,255,255,0.06); }
.btn:active::after { background: rgba(255,255,255,0.12); }

/* --- Primary (gold) --- */
.btn-primary {
  background: var(--gold);
  color: #0F0E0C;
  border-color: var(--gold);
  box-shadow: 0 2px 8px rgba(201,168,76,0.25);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--gold-2);
  border-color: var(--gold-2);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201,168,76,0.45);
  color: #0F0E0C;
}
.btn-primary:active {
  transform: translateY(0px);
  box-shadow: 0 2px 8px rgba(201,168,76,0.25);
}

/* --- Outline --- */
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.18);
}
.btn-outline:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: var(--gold-dim);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(201,168,76,0.15);
}
.btn-outline:active {
  transform: translateY(0px);
  box-shadow: none;
}

/* --- Outline danger (red) — aplicado inline com style= --- */
.btn-outline[style*="--red"]:hover,
.btn-outline.btn-danger:hover {
  color: var(--red) !important;
  border-color: var(--red) !important;
  background: var(--red-dim) !important;
  box-shadow: 0 4px 14px rgba(224,90,90,0.2) !important;
  transform: translateY(-2px);
}

/* --- Ghost --- */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 8px 12px;
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.1);
  transform: translateY(-1px);
}
.btn-ghost:active { transform: translateY(0); }

/* --- Voltar link especial --- */
a.btn-ghost:hover {
  color: var(--gold);
}

/* --- Danger hover variant ---------------------------------- */
.btn-danger-hover:hover {
  color: var(--red) !important;
  border-color: var(--red) !important;
  background: var(--red-dim) !important;
  box-shadow: 0 4px 14px rgba(224,90,90,0.25) !important;
  transform: translateY(-2px);
}

.btn-sm { padding: 6px 14px; font-size: 0.78rem; }

/* Cursor pointer garantido em todos os botões e links clicáveis */
.btn,
.btn:visited,
button.btn,
a.btn,
.nav-item,
.plan-card,
.topic-item[onclick],
.theme-card,
.color-swatch {
  cursor: pointer;
}

/* ---- Forms ------------------------------------------------- */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 7px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.form-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.form-input::placeholder { color: var(--text-subtle); }

textarea.form-input { resize: vertical; min-height: 90px; }

/* ---- Alerts ----------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(224,90,90,0.3);
  color: #F09090;
}

.alert-success {
  background: var(--green-dim);
  border: 1px solid rgba(92,184,128,0.3);
  color: #90D0A8;
}

/* ---- Auth Pages ------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
  background-image:
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(201,168,76,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 20%, rgba(107,159,212,0.03) 0%, transparent 70%);
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  color: var(--gold);
}

.auth-logo p {
  font-size: 0.82rem;
  color: var(--text-subtle);
  margin-top: 4px;
}

.auth-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
}

.auth-card h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.auth-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-subtle);
}

.auth-footer a { color: var(--gold); }
.auth-footer a:hover { color: var(--gold-2); }

/* ---- Topics / Modules ------------------------------------- */
.module-block {
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.module-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(90deg, rgba(201,168,76,0.08) 0%, var(--bg-3) 100%);
  border-left: 3px solid var(--gold);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.module-header:hover {
  background: linear-gradient(90deg, rgba(201,168,76,0.16) 0%, rgba(201,168,76,0.04) 100%);
  color: var(--gold);
}

.module-header h3 {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  color: var(--gold);
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}

.module-header:hover h3 { color: var(--gold-2); }

.module-header .chevron { color: var(--gold); opacity: 0.7; }

.module-progress-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-subtle);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 99px;
}

.topic-list { padding: 8px 0; }

/* Wrapper para tópico + painel de notas */
.topic-wrapper {
  border-bottom: 1px solid var(--border-soft);
}
.topic-wrapper:last-child { border-bottom: none; }

.topic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  transition: background 0.15s ease, padding-left 0.15s ease;
  border-left: 2px solid transparent;
}

.topic-item[style*="cursor:pointer"]:hover {
  background: rgba(201,168,76,0.05);
  border-left-color: rgba(201,168,76,0.3);
}

.topic-item.completed[style*="cursor:pointer"]:hover {
  background: rgba(92,184,128,0.05);
  border-left-color: rgba(92,184,128,0.3);
}

/* Ocultar o note-btn por defeito, mostrar no hover */
.note-btn { opacity: 0; transition: opacity 0.15s ease; }
.topic-item:hover .note-btn,
.note-btn.has-note { opacity: 1; }

.topic-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.topic-item[onclick]:hover .topic-checkbox,
.topic-item[style*="cursor:pointer"]:hover .topic-checkbox {
  border-color: var(--gold);
  background: var(--gold-dim);
  transform: scale(1.1);
}

.topic-item.completed .topic-checkbox {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 8px rgba(92,184,128,0.4);
}

.topic-item.completed .topic-checkbox::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}

.topic-title {
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: color 0.15s ease;
  flex: 1;
  position: relative;
}

.topic-item[onclick]:hover .topic-title,
.topic-item[style*="cursor:pointer"]:hover .topic-title {
  color: var(--text);
}

.topic-item.completed .topic-title {
  color: var(--text-subtle);
  text-decoration: line-through;
}

/* ---- Ranking ---------------------------------------------- */
.ranking-list { display: flex; flex-direction: column; gap: 10px; }

.ranking-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.18s ease;
  color: var(--text);
}

a.ranking-item {
  cursor: pointer;
}

.ranking-item:hover {
  border-color: rgba(201,168,76,0.3);
  background: rgba(201,168,76,0.04);
  transform: translateX(3px);
}

/* Medalhas no número */
.rank-num {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-subtle);
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.rank-num.gold   { color: #C9A84C; }
.rank-num.silver { color: #A0A0A0; }
.rank-num.bronze { color: #C08060; }

/* Avatar colorido por posição */
.rank-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.rank-avatar.pos-1 { background: rgba(201,168,76,0.20); color: #C9A84C; border-color: rgba(201,168,76,0.5); }
.rank-avatar.pos-2 { background: rgba(160,160,160,0.15); color: #A0A0A0; border-color: rgba(160,160,160,0.4); }
.rank-avatar.pos-3 { background: rgba(192,128,96,0.15); color: #C08060; border-color: rgba(192,128,96,0.4); }
.rank-avatar.pos-n { background: rgba(255,255,255,0.06); color: var(--text-muted); border-color: var(--border); }
.rank-avatar.pos-me { background: var(--gold-dim); color: var(--gold); border-color: var(--gold); }

.rank-name {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.rank-name small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  margin-top: 1px;
}

.rank-bar-wrap {
  flex: 2;
  height: 7px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.rank-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

.ranking-item:nth-child(1) .rank-bar-fill { background: linear-gradient(90deg, #C9A84C, #E8C878); }
.ranking-item:nth-child(2) .rank-bar-fill { background: linear-gradient(90deg, #909090, #C0C0C0); }
.ranking-item:nth-child(3) .rank-bar-fill { background: linear-gradient(90deg, #A0694A, #C08060); }

.rank-percent {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  width: 46px;
  text-align: right;
}

/* ---- Notes panel ------------------------------------------ */
.note-panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  display: none;
  animation: fadeUp 0.2s ease both;
}

.note-panel.open { display: block; }

.note-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.note-toolbar span {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-subtle);
  letter-spacing: 0.05em;
}

.note-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.6;
  min-height: 100px;
  max-height: 240px;
}

.note-textarea::placeholder { color: var(--text-subtle); }

.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.note-saved-msg {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--green);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.note-saved-msg.visible { opacity: 1; }

.note-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.note-btn:hover { color: var(--gold); background: var(--gold-dim); }
.note-btn.has-note { color: var(--gold); opacity: 1 !important; }

/* ---- Indicadores de nota e anexo no tópico ---------------- */
.topic-has-note,
.topic-has-att {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 99px;
  cursor: default;
  flex-shrink: 0;
}

.topic-has-note {
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid rgba(201,168,76,0.25);
}

.topic-has-att {
  color: var(--blue);
  background: rgba(107,159,212,0.10);
  border: 1px solid rgba(107,159,212,0.25);
}

.topic-has-att span {
  font-weight: 700;
  font-size: 0.65rem;
}


/* ---- Attachment styles ------------------------------------ */
.note-attachments {
  padding: 0 16px;
  border-top: 1px solid var(--border);
}

.att-list { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }

.att-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.att-name {
  flex: 1;
  color: var(--gold);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.att-name:hover { text-decoration: underline; }

.att-size {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.att-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-subtle);
  font-size: 0.75rem;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}

.att-del:hover { color: var(--red); }

.att-uploading {
  font-size: 0.78rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  padding: 6px 8px;
  animation: pulse 1s ease-in-out infinite;
}

.note-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-subtle);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.note-upload-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: var(--gold-dim);
}


}

/* ---- Plan Detail Header ----------------------------------- */
.plan-hero {
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 32px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  position: relative;
  overflow: hidden;
}

.plan-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background: radial-gradient(ellipse 80% 60% at 80% 50%, currentColor, transparent);
}

.plan-hero-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.plan-hero h2 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin-bottom: 8px;
  line-height: 1.15;
}

.plan-hero p { color: var(--text-muted); font-size: 0.9rem; max-width: 560px; }

/* ---- Activity Feed ---------------------------------------- */
.activity-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-text { font-size: 0.85rem; }
.activity-text strong { font-weight: 600; color: var(--text); }
.activity-text .plan-tag {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-subtle);
}

.activity-time {
  font-size: 0.72rem;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  margin-left: auto;
  white-space: nowrap;
}


/* ---- Topic timestamp -------------------------------------- */
.topic-timestamp {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--green);
  opacity: 0.8;
  white-space: nowrap;
  margin-left: auto;
  padding-left: 12px;
  transition: opacity 0.2s ease;
}
.topic-item:not(.completed) .topic-timestamp { display: none; }

/* ---- Plan Builder (Create/Edit Form) ---------------------- */
.module-builder {
  border: 1px solid var(--gold);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, rgba(201,168,76,0.06) 0%, var(--bg-3) 100%);
}

.module-builder input[name^="module_title"] {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  background: transparent;
  border-color: rgba(201,168,76,0.3);
  letter-spacing: 0.01em;
  flex: 1;
  min-width: 0;
}

.module-builder input[name^="module_title"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.module-builder input[name^="module_title"]::placeholder {
  color: rgba(201,168,76,0.4);
  font-weight: 400;
}

.topic-builder {
  margin-top: 6px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.topic-builder input { flex: 1; min-width: 0; }

.add-topic-btn, .add-module-btn {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.18s ease;
  width: 100%;
  margin-top: 10px;
  font-family: var(--font-sans);
}

.add-topic-btn:hover {
  border-color: rgba(201,168,76,0.5);
  color: var(--gold);
  background: var(--gold-dim);
}

.add-module-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-dim);
}


/* ---- Color Picker ----------------------------------------- */
.color-picker-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.color-swatch:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.color-swatch.selected {
  border-color: white;
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}

/* ---- Theme cards ------------------------------------------ */
.theme-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease !important;
}

.theme-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}

/* ---- Responsive ------------------------------------------- */
/* ── Mobile (≤768px) ──────────────────────────────────────── */
@media (max-width: 768px) {
  /* Grid colapsa para 1 coluna — sidebar sai do fluxo via position:fixed */
  .app-layout {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 0 0 24px;
    width: 100%;
    min-width: 0;
  }

  /* Topbar visível no mobile */
  .mobile-topbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 54px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 300;
    margin-bottom: 16px;
  }
  .mobile-topbar-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--gold);
  }

  /* Sidebar como drawer — fora do grid */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 500;
    transition: left 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 32px rgba(0,0,0,0.5);
  }

  /* Overlay escuro atrás do drawer */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 400;
  }
  .sidebar-overlay.open { display: block; }

  /* Botão X dentro da sidebar */
  .sidebar-logo { position: relative; }
  #sidebar-close-btn { display: flex !important; }

  /* Padding interno do conteúdo */
  .main-content > *:not(.mobile-topbar) {
    padding-left: 14px;
    padding-right: 14px;
  }

  /* Grids */
  .card-grid { grid-template-columns: 1fr !important; }
  .stats-row { grid-template-columns: repeat(2,1fr) !important; }

  /* Plan hero */
  .plan-hero { padding: 18px 14px 14px !important; border-radius: 10px !important; }
  .plan-hero h2 { font-size: 1.3rem !important; }
  .plan-hero .flex.items-center { flex-wrap: wrap; gap: 6px !important; }
  .plan-hero .btn { font-size: 0.76rem !important; padding: 5px 9px !important; }

  /* Tópicos */
  .topic-item { padding: 9px 10px; }
  .topic-title { font-size: 0.82rem; }

  /* Modal */
  #sc-modal-overlay > div { max-width: 96vw !important; padding: 20px 16px 16px !important; }
}

/* ── Small mobile (≤480px) ─────────────────────────────────── */
@media (max-width: 480px) {
  .main-content { padding: 14px 10px; }
  .card { padding: 14px; }
  .page-title { font-size: 1.3rem; }
  .topic-timestamp { display: none; }
}

/* Prevenir zoom automático nos inputs iOS */
@media (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="password"],
  input[type="url"], input[type="number"], select, textarea { font-size: 16px !important; }
}

/* ---- Utilities -------------------------------------------- */
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 8px; }
.mt-2   { margin-top: 16px; }
.mt-3   { margin-top: 24px; }
.mb-1   { margin-bottom: 8px; }
.mb-2   { margin-bottom: 16px; }
.mb-3   { margin-bottom: 24px; }
.text-muted  { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-gold   { color: var(--gold); }
.text-green  { color: var(--green); }
.text-sm     { font-size: 0.85rem; }
.text-xs     { font-size: 0.75rem; font-family: var(--font-mono); }
.font-serif  { font-family: var(--font-serif); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 500;
}

.badge-gold  { background: var(--gold-dim);  color: var(--gold);  border: 1px solid rgba(201,168,76,0.3); }
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(92,184,128,0.3); }

/* Fade-in animation */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up {
  animation: fadeUp 0.35s ease both;
}

.fade-up-1 { animation-delay: 0.05s; }
.fade-up-2 { animation-delay: 0.10s; }
.fade-up-3 { animation-delay: 0.15s; }
.fade-up-4 { animation-delay: 0.20s; }


/* ============================================================
   PLAN BUILDER (create/edit) — layout original + format/video
   ============================================================ */

/* Botões de ícone pequenos nas linhas de módulo/tópico */
.builder-icon-btn {
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  background: none;
  transition: all 0.15s;
  line-height: 1.4;
}
.builder-icon-btn.gold  { color: var(--gold);  border-color: rgba(201,168,76,0.35); }
.builder-icon-btn.gold:hover  { background: var(--gold); color: #1a1a1a; }
.builder-icon-btn.blue  { color: var(--blue);  border-color: rgba(107,159,212,0.35); }
.builder-icon-btn.blue:hover  { background: var(--blue); color: #fff; }
.builder-icon-btn.green { color: var(--green, #059669); border-color: rgba(5,150,105,0.35); }
.builder-icon-btn.green:hover { background: var(--green, #059669); color: #fff; }
.builder-icon-btn.red   { color: var(--text-subtle); border-color: transparent; }
.builder-icon-btn.red:hover   { color: #e05252; border-color: #e05252; }
.builder-icon-btn.muted { color: var(--text-subtle); border-color: transparent; }
.builder-icon-btn.muted:hover { color: #e05252; }
.builder-icon-btn.small { font-size: 0.72rem; padding: 2px 6px; }

/* Linha de tópico */
.topic-builder-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

/* Input do tópico ocupa todo o espaço disponível */
.topic-builder-row .topic-title-input {
  flex: 1;
  min-width: 0;
}

/* Grupo de botões — sempre à direita, nunca encolhem */
.topic-builder-row .builder-icon-btn {
  flex-shrink: 0;
}

/* Tags de vídeo abaixo do tópico */
.topic-video-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 2px 0 4px 4px;
}
.video-tag {
  font-size: 0.67rem;
  font-family: var(--font-mono);
  background: rgba(107,159,212,0.1);
  border: 1px solid rgba(107,159,212,0.25);
  color: var(--blue);
  border-radius: 99px;
  padding: 1px 8px;
}

/* Format Picker popup */
#format-picker {
  position: absolute;
  z-index: 9999;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  min-width: 230px;
  display: none;
}
#format-picker label { font-size: 0.8rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
#format-picker input[type="color"] { width: 100%; height: 30px; border-radius: 5px; border: 1px solid var(--border); cursor: pointer; margin-top: 2px; }
#format-picker select { width: 100%; }
.fp-row { margin-bottom: 10px; }
.fp-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Video Manager modal */
#video-manager {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.vm-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 600px;
  padding: 24px;
  max-height: 88vh;
  overflow-y: auto;
}
.vm-panel h3 { font-family: var(--font-serif); color: var(--gold); margin-bottom: 8px; }
.vm-panel p  { font-size: 0.83rem; color: var(--text-muted); margin-bottom: 16px; }
.vm-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.vm-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
  align-items: center;
}

/* Botão cancelar com realce claro */
.btn-cancel {
  border-color: var(--text-subtle) !important;
  color: var(--text-muted) !important;
  background: transparent !important;
}
.btn-cancel:hover {
  border-color: #e05252 !important;
  color: #e05252 !important;
  background: rgba(224,82,82,0.08) !important;
}

/* ---- Video Player (show.php) ------------------------------- */
.topic-videos {
  padding: 0 0 8px 0;
}

.video-player-wrap {
  background: #000;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
  width: 100%;
  border-radius: 0;  /* sem radius — fica encaixado no módulo */
}
.video-player-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none; display: block;
}
.video-external-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(107,159,212,0.08);
  border: 1px solid rgba(107,159,212,0.28);
  border-radius: 8px;
  color: var(--blue);
  text-decoration: none;
  font-size: 0.84rem;
  margin: 4px 0 6px 20px;
  transition: all 0.15s;
}
.video-external-link:hover { background: var(--blue); color: #fff; }
.video-label {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-bottom: 4px;
  padding-left: 20px;
  font-family: var(--font-mono);
}
.video-quality-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 8px 20px;
  font-size: 0.74rem;
  color: var(--text-subtle);
}
.video-quality-bar select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.74rem;
  cursor: pointer;
}

/* ---- Painéis de nota — 3 modos ---------------------------- */
.note-panel-read,
.note-panel-atts {
  margin: 4px 0 8px 28px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  overflow: hidden;
}

.note-read-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  background: var(--gold-dim);
}

.note-read-body {
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
  min-height: 40px;
}

.note-atts-list {
  padding: 10px 12px;
}

/* Auto-grow textarea */
.note-textarea.auto-grow {
  resize: none;
  overflow: hidden;
  min-height: 80px;
  max-height: 400px;
  transition: height 0.1s ease;
}

/* Painel de edição — oculto por defeito com display:none */
.note-panel-edit {
  /* mesmos estilos do .note-panel original */
}

/* ---- Reorder arrows (up/down) ----------------------------- */
.topic-reorder {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.reorder-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-subtle);
  font-size: 0.55rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.reorder-btn:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}




/* ---- Subtópicos no editor --------------------------------- */
.subtopics-container {
  margin-left: 44px;
  padding-left: 10px;
  border-left: 2px dashed var(--border);
  margin-top: 2px;
}
.subtopic-builder { margin-top: 3px; }
.subtopic-builder .topic-title-input { font-size: 0.85rem !important; }

.add-subtopic-btn {
  display: block; background: none; border: none;
  color: var(--text-subtle); font-size: 0.72rem;
  padding: 2px 0 4px 46px; cursor: pointer;
  text-align: left; width: 100%; transition: color 0.12s;
}
.add-subtopic-btn:hover { color: var(--blue); }

/* ---- Subtópicos na view do plano — lista indentada -------- */
.subtopics-list {
  margin-left: 28px;            /* indentação em relação ao tópico pai */
  border-left: 2px dashed var(--border);
  padding-left: 0;
  margin-top: 2px;
  margin-bottom: 2px;
}

/* O subtópico usa topic-item mas com visual ligeiramente mais pequeno */
.subtopic-item-row.topic-item {
  font-size: 0.88rem;
}
.subtopic-item-row .topic-title {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Painéis de nota dos subtópicos — mesmo estilo, sem mudanças */
.vid-badge {
  margin-left: 5px; font-size: 0.67rem;
  background: rgba(107,159,212,0.13); color: var(--blue);
  border-radius: 99px; padding: 1px 7px;
  font-family: var(--font-mono); cursor: pointer;
}
.vid-badge:hover { background: var(--blue); color: #fff; }

/* ---- Botão de colapso do módulo no editor ----------------- */
.module-collapse-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-subtle);
  font-size: 0.65rem;
  padding: 3px 8px;
  cursor: pointer;
  line-height: 1.4;
  transition: all 0.12s;
  font-family: Arial, sans-serif;
}
.module-collapse-btn:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}
