:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --text: #2e3330;
  --muted: #6b736e;
  --border: #e4e6e2;
  --accent: #5a7d6f;      /* verde sálvia */
  --accent-soft: #eef2ef;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --topbar-h: 56px;
  --av-sm: 32px;
  --av-md: 42px;
  --av-lg: 52px;
  --av-xl: 96px;
  --danger: #b3493f;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --radius: 10px; --radius-lg: 12px;
}
[data-theme="dark"] {
  --bg: #161a18;
  --surface: #1f2522;
  --text: #e6e8e4;
  --muted: #9aa39d;
  --border: #2e3633;
  --accent: #7fa593;
  --accent-soft: #232b27;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --danger: #e08b81;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* autoridade sobre .login/.app/.section */
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}

/* ---- Login ---- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.brand { font-size: 2.4em; font-weight: 700; letter-spacing: 4px; color: var(--accent); }
.tagline { color: var(--muted); font-size: 0.8em; letter-spacing: 1px; margin: 4px 0 28px; }
.login-help { font-size: 0.9em; color: var(--muted); margin-bottom: 16px; }
#token-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg); color: var(--text); font-size: 0.95em;
}
#login-btn {
  width: 100%; margin-top: 12px; padding: 12px; border: none; border-radius: 10px;
  background: var(--accent); color: white; font-size: 1em; cursor: pointer;
}
#login-btn:hover { opacity: 0.9; }
#login-btn:disabled { opacity: 0.5; cursor: default; }
.login-msg { font-size: 0.85em; min-height: 1.2em; margin: 12px 0 0; }
.login-msg.error { color: var(--danger); }
.login-msg.ok { color: var(--accent); }

/* ---- App ---- */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "topbar topbar" "sidebar content";
  min-height: 100vh;
}
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h); padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand-mark { font-weight: 700; letter-spacing: 3px; color: var(--accent); font-size: 1.25em; }
.top-search-wrap {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px;
}
.top-search-ico { color: var(--muted); font-size: 0.85em; }
#top-search { flex: 1; border: none; background: transparent; padding: 9px 0; color: var(--text); font-size: 0.9em; outline: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-ghost { padding: 7px 9px; }
.top-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: inline-block;
  background: var(--accent-soft); background-size: cover; background-position: center;
  border: 1px solid var(--border); position: relative;
}
.presence-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #2e7d4f; border: 2px solid var(--surface); }
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); align-self: start; overflow-y: auto;
}
.brand-row { margin-bottom: 28px; padding: 0 8px; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-decoration: none; color: var(--text); padding: 10px 12px; border-radius: 8px;
  font-size: 0.95em; transition: background 0.15s;
}
.nav-item:hover { background: var(--accent-soft); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-foot { display: flex; gap: 8px; align-items: center; padding-top: 16px; border-top: 1px solid var(--border); }
.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 0.9em;
}
.ghost:hover { color: var(--text); }

.content { grid-area: content; padding: 32px 48px; max-width: 1240px; }
.section h1 { font-size: 1.8em; margin: 0 0 6px; }
.muted { color: var(--muted); margin: 0 0 28px; }
.placeholder {
  border: 1px dashed var(--border); border-radius: 12px; padding: 48px;
  text-align: center; color: var(--muted); background: var(--surface);
}
.err-state { display: flex; flex-direction: column; align-items: center; gap: 12px; }
/* Skeleton de carregamento (animação CSS pura, sem lib) */
.feed-skel { display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--surface); }
.skel-av { width: var(--av-md); height: var(--av-md); border-radius: 50%; background: var(--accent-soft); flex-shrink: 0; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.skel-lines span { height: 12px; border-radius: 6px; background: var(--accent-soft); display: block; }
.skel-lines span:first-child { width: 40%; }
.skel-lines span:last-child { width: 80%; }
@keyframes lepo-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.skel-av, .skel-lines span { animation: lepo-pulse 1.4s ease-in-out infinite; }

/* ---- Acervo ---- */
#acervo-search {
  width: 100%; max-width: 440px; padding: 10px 14px; margin-bottom: 20px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 0.95em;
}
.doc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
}
.doc-card:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.doc-card-title { font-weight: 600; }
.doc-card-meta { font-size: 0.82em; color: var(--muted); margin-top: 4px; }
.tag {
  display: inline-block; font-size: 0.7em; padding: 2px 8px; border-radius: 10px;
  background: var(--accent); color: #fff; margin-left: 6px; vertical-align: middle;
}
.tag-roteiro { background: #b9822e; }

.back-link { color: var(--accent); text-decoration: none; font-size: 0.9em; display: inline-block; margin-bottom: 16px; }
.back-link:hover { text-decoration: underline; }
#doc-content { line-height: 1.7; max-width: 680px; }
#doc-content h2 { font-size: 1.4em; margin-top: 1.4em; }
#doc-content h3 { font-size: 1.15em; }
#doc-content pre { background: var(--accent-soft); padding: 12px; border-radius: 8px; overflow: auto; white-space: pre-wrap; }
#doc-content code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
#doc-content blockquote { border-left: 3px solid var(--accent); margin: 1em 0; padding: 0.4em 1em; color: var(--muted); }

/* ---- Anotações no detalhe do documento ---- */
.doc-notes { margin-top: 2.5em; padding-top: 1em; border-top: 1px solid var(--border); }
.doc-notes h2 { font-size: 1.2em; }
.note-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.note-meta { font-size: 0.78em; color: var(--muted); margin-bottom: 5px; }
.note-text { white-space: pre-wrap; word-break: break-word; }
.doc-note-compose { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; }
.doc-note-compose textarea { flex: 1; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.93em; resize: vertical; }
.doc-note-compose button { white-space: nowrap; }
/* Resumos com mídia (Fase 1.5) — grid no leitor + grid editável */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 16px 0; max-width: 680px; }
.media-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
.media-ed { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; flex-wrap: wrap; }
.media-fig { margin: 0; display: flex; flex-direction: column; }
.media-cap { font-size: 0.72em; color: var(--muted); margin-top: 4px; line-height: 1.3; }
.doc-inline-fig { margin: 16px auto; max-width: 100%; }
.doc-inline-img { max-width: 100%; max-height: 460px; border-radius: 8px; cursor: zoom-in; display: block; margin: 0 auto; }
.doc-inline-fig .media-cap { text-align: center; }
.media-ins { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,0.5); color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.media-ins:hover { background: var(--accent); }
.refimg-card { max-width: 640px; }
.refimg-group { margin-bottom: 14px; }
.refimg-label { font-weight: 600; margin-bottom: 6px; }
.refimg-cands { display: flex; gap: 8px; flex-wrap: wrap; }
.refimg-cand { position: relative; width: 110px; height: 110px; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--bg); }
.refimg-cand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.refimg-cand:hover { border-color: var(--accent); }
.refimg-cand.refimg-added { outline: 2px solid var(--accent); outline-offset: -2px; }
.refimg-lic { position: absolute; bottom: 0; left: 0; right: 0; font-size: 0.62em; background: rgba(0,0,0,0.6); color: #fff; padding: 2px 4px; text-align: center; }
.media-edit-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.media-thumb { position: relative; width: 84px; height: 84px; cursor: grab; }
.media-thumb:active { cursor: grabbing; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); pointer-events: none; }
.media-del { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; line-height: 1; font-size: 12px; border: none; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

/* ---- Diário ---- */
#diario-list { max-width: 760px; }
.diary-entry {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.diary-entry:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.diary-entry:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.diary-meta { font-size: 0.8em; color: var(--muted); margin-bottom: 6px; }
.diary-text { white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
.diary-doc { font-size: 0.85em; color: var(--accent); text-decoration: none; }
.diary-entry:hover .diary-doc { text-decoration: underline; }

/* ---- LEPO Brain ---- */
#brain-card, #brain-result {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; margin-bottom: 16px; max-width: 680px;
}
#brain-prompt { font-size: 1.2em; margin-bottom: 14px; }
#brain-answer {
  width: 100%; box-sizing: border-box; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: inherit; font-size: 1em; line-height: 1.5; resize: vertical;
}
.brain-actions { display: flex; gap: 10px; margin-top: 12px; }
.brain-actions button {
  padding: 10px 22px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 0.95em; font-family: inherit;
}
.brain-actions button:hover { opacity: 0.9; }
.brain-actions .ghost-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.brain-actions button:disabled { opacity: 0.5; cursor: default; }

.brain-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.brain-global { font-size: 2em; font-weight: bold; }
.badge { display: inline-block; padding: 2px 12px; border-radius: 12px; font-size: 0.78em; color: #fff; }
.badge.valid { background: #2e7d4f; }
.badge.partial { background: #b9822e; }
.badge.invalid { background: #b3493f; }
.brain-dims { list-style: none; padding: 0; margin: 12px 0; }
.brain-dims li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 0.92em; }
.brain-dims span { color: var(--muted); }
.brain-rationale { font-style: italic; margin: 14px 0; }
.brain-timing { font-size: 0.82em; }
.brain-error { color: #b3493f; }
.tag-brain { background: #5a7d6f; }

/* ---- Revisão / LEPOphi ---- */
.revisao-modes { display: flex; gap: 8px; margin-bottom: 18px; }
.mode-btn {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 0.9em; font-family: inherit;
}
.mode-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.mode-btn:disabled { opacity: 0.5; cursor: default; }
.lepophi-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.lepophi-pick label { color: var(--muted); font-size: 0.9em; }
#lepophi-doc {
  flex: 1; min-width: 200px; max-width: 440px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font-size: 0.92em;
}
#lepophi-ask {
  padding: 9px 18px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 0.92em; font-family: inherit;
}
#lepophi-ask:hover { opacity: 0.9; }
#lepophi-ask:disabled { opacity: 0.5; cursor: default; }
.lepophi-question {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 16px 18px; font-size: 1.15em; margin-bottom: 14px; max-width: 680px;
}
#lepophi-answer {
  width: 100%; box-sizing: border-box; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: inherit; font-size: 1em; line-height: 1.5; resize: vertical; margin-bottom: 4px;
}
#lepophi-result {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; margin-top: 16px; max-width: 680px;
}
.tag-revisao { background: #7a6da5; }

/* ---- MemÓculos (flashcards) ---- */
.mem-make { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.mem-make label { color: var(--muted); font-size: 0.9em; }
#mem-doc {
  flex: 1; min-width: 200px; max-width: 380px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font-size: 0.92em;
}
#mem-generate {
  padding: 9px 18px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 0.92em; font-family: inherit;
}
#mem-generate:hover { opacity: 0.9; }
#mem-generate:disabled { opacity: 0.5; cursor: default; }
.deck-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px;
}
.deck-info { font-weight: 600; }
.deck-sub { font-size: 0.82em; color: var(--muted); font-weight: 400; margin-top: 3px; }
.deck-actions { display: flex; gap: 8px; }
.deck-actions button {
  padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 0.88em; font-family: inherit;
}
.deck-actions button:hover { opacity: 0.9; }
.flashcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px 24px; min-height: 150px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.flash-front { font-size: 1.3em; }
.flash-divider { width: 100%; border: none; border-top: 1px dashed var(--border); margin: 18px 0; }
.flash-back { font-size: 1.05em; line-height: 1.6; align-self: stretch; text-align: left; }
.flash-img { max-width: 100%; max-height: 440px; border-radius: 8px; margin: 12px 0; cursor: zoom-in; } /* dobro do antigo; clique → lightbox p/ ver detalhes */
.review-progress { text-align: center; color: var(--muted); font-size: 0.85em; margin-bottom: 12px; }
.review-bar { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.review-bar button {
  padding: 10px 22px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 0.95em; font-family: inherit; color: #fff;
}
.review-bar .show-btn { background: var(--accent); }
.review-bar .ghost-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.rate-again { background: #b3493f; }
.rate-good { background: #2e7d4f; }
.rate-easy { background: #5a7d6f; }
.tag-deck { background: #b9822e; }

/* ---- MemÓculos Fase 2: controles, biblioteca, editor ---- */
.ghost-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 9px 16px; cursor: pointer; font-family: inherit; font-size: 0.9em; }
.ghost-btn:hover { color: var(--text); }
.mem-make input[type="number"], .mem-make select#mem-depth {
  padding: 9px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 0.92em;
}
.mem-make input[type="number"] { width: 60px; }
.mem-make label { color: var(--muted); font-size: 0.9em; }
.mem-lib-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 12px; }
.mem-lib-head h2 { font-size: 1.15em; margin: 0; }
.lib-actions { display: flex; align-items: center; gap: 12px; }
.shuffle-lbl { color: var(--muted); font-size: 0.85em; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.deck-actions .manage-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.editor-head { margin-bottom: 14px; }
#deck-name { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 1.05em; }
.card-edit { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.card-edit textarea {
  width: 100%; box-sizing: border-box; min-height: 58px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 0.92em; line-height: 1.4; resize: vertical;
}
.card-edit .card-del { background: transparent; border: 1px solid var(--border); color: #b3493f; border-radius: 8px; cursor: pointer; padding: 8px 12px; }
#card-add { margin-top: 4px; }
.editor-foot { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.editor-foot button { padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.95em; font-family: inherit; color: #fff; background: var(--accent); }
.editor-foot button:hover { opacity: 0.9; }
.editor-foot .danger-btn { background: #b3493f; }
.editor-foot .ghost-btn { background: transparent; color: var(--muted); }

/* ---- Acervo: filtros por tipo + edição de doc + nota avulsa ---- */
.acervo-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.85em; cursor: pointer; font-family: inherit; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.chip-n { opacity: 0.65; }
.tag-summary { background: #5a7d6f; }
.tag-edit { background: #7a6da5; }
.tag-box { background: #4a6da0; }
.box-items { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.box-item { cursor: pointer; }
.doc-access-lbl { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88em; color: var(--muted); }
.doc-access-sel { padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); font-family: inherit; cursor: pointer; }
.doc-detail-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-detail-head h1 { flex: 1; }
#doc-meta a { color: var(--accent); }
#doc-ed-title { width: 100%; box-sizing: border-box; padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 1.1em; }
#doc-ed-content { width: 100%; box-sizing: border-box; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.95em; line-height: 1.6; resize: vertical; }
.doc-ed-hint { font-size: 0.82em; margin: 8px 0; }
.diario-new { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 20px; }
#diario-note-input { flex: 1; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-family: inherit; font-size: 0.95em; resize: vertical; }
#diario-note-add { padding: 10px 18px; border: none; border-radius: 8px; cursor: pointer; background: var(--accent); color: #fff; font-family: inherit; font-size: 0.92em; white-space: nowrap; }
#diario-note-add:hover { opacity: 0.9; }
#diario-note-add:disabled { opacity: 0.5; }

/* ---- LEPOphi Simulados ---- */
.sim-sep { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.sim-make { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sim-make label { color: var(--muted); font-size: 0.9em; }
.sim-make input[type="number"] { width: 60px; padding: 9px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 0.92em; }
.sim-make select { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 0.92em; }
#sim-generate { padding: 9px 18px; border: none; border-radius: 8px; cursor: pointer; background: var(--accent); color: #fff; font-size: 0.92em; font-family: inherit; }
#sim-generate:hover { opacity: 0.9; }
#sim-generate:disabled { opacity: 0.5; }
.sim-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.sim-navbtn { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 0.82em; }
.sim-navbtn.answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sim-navbtn.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.sim-q { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; max-width: 760px; }
.sim-q-text { font-size: 1.12em; margin-bottom: 14px; line-height: 1.5; }
.sim-opt { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.sim-opt:hover { border-color: var(--accent); }
.sim-opt.chosen { background: var(--accent-soft); border-color: var(--accent); }
.sim-opt input { margin-right: 8px; }
.sim-open { width: 100%; box-sizing: border-box; min-height: 110px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.95em; line-height: 1.5; resize: vertical; }
.sim-bar { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.sim-bar button { padding: 10px 18px; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 0.95em; color: #fff; background: var(--accent); }
.sim-bar button:hover { opacity: 0.9; }
.sim-bar .ghost-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.sim-bar .sim-deliver { background: #2e7d4f; }
.sim-bar button:disabled { opacity: 0.5; cursor: default; }
.sim-score { font-size: 1.6em; font-weight: bold; margin-bottom: 14px; }
.sim-res-q { border-bottom: 1px dashed var(--border); padding: 12px 0; line-height: 1.5; }
.sim-res-q .ok { color: #2e7d4f; }
.sim-res-q .no { color: #b3493f; }
.sim-progress { color: var(--muted); font-size: 0.95em; margin: 14px 0; }
.tag-test { background: #8a6d3b; }
.tag-td { background: #6a8caf; }

/* Simulados CRUD: lista, timer, editor de questões */
.sim-list-title { font-size: 1.05em; margin: 20px 0 10px; }
#sim-timer { width: 70px; padding: 9px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 0.92em; }
.sim-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.sim-timer { font-weight: bold; font-size: 1.15em; color: var(--accent); }
.sim-timer.low { color: #b3493f; }
.test-qedit { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.test-qedit .tq-q { width: 100%; box-sizing: border-box; min-height: 50px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.92em; resize: vertical; margin-bottom: 6px; }
.test-qedit .tq-ref { width: 100%; box-sizing: border-box; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.9em; resize: vertical; }
.test-qedit .tq-opt { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: 0.9em; }
.test-qedit .tq-opt .tq-o { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 0.9em; }
.test-qedit .card-del { float: right; margin-top: 4px; }

/* Exclusão: ferramentas do acervo, seleção múltipla, excluir nota */
.acervo-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.acervo-tools #acervo-search { margin-bottom: 0; }
.danger-ghost { color: #b3493f; border-color: rgba(179,73,63,0.35); }
.danger-ghost:hover { background: rgba(179,73,63,0.08); color: #b3493f; }
#acervo-bulk:not(:empty) { margin-bottom: 12px; }
.bulk-bar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--accent-soft); border-radius: 10px; font-size: 0.9em; }
.bulk-bar #bulk-del { padding: 8px 16px; border: none; border-radius: 8px; background: #b3493f; color: #fff; cursor: pointer; font-family: inherit; font-size: 0.9em; }
.bulk-bar #bulk-del:disabled { opacity: 0.5; cursor: default; }
.doc-card.selectable { display: flex; align-items: center; gap: 10px; }
.doc-card .doc-card-body { flex: 1; }
.note-item { position: relative; }
.note-del { position: absolute; top: 8px; right: 8px; background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 0.9em; line-height: 1; }
.note-del:hover { color: #b3493f; }

/* Mídia nos flashcards (imagem + áudio) */
.card-media { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.media-btn { cursor: pointer; padding: 4px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 1em; }
.media-btn:hover { border-color: var(--accent); }
.media-prev { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.media-thumb { height: 36px; border-radius: 4px; }
.mem-prev-img { height: 72px; width: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; vertical-align: middle; } /* preview do card: clique amplia */
.media-aud { font-size: 0.82em; color: var(--muted); }
.media-x { background: transparent; border: none; color: #b3493f; cursor: pointer; font-size: 0.85em; }
.flash-aud { width: 100%; max-width: 320px; margin: 8px 0; }
button.media-btn { font-family: inherit; color: var(--text); }
.media-btn.media-rec.recording { background: #b3493f; color: #fff; border-color: #b3493f; }
.media-btn:disabled { opacity: 0.5; cursor: default; }

/* ---- Responsivo ---- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "sidebar" "content"; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .brand-mark { font-size: 1.05em; letter-spacing: 2px; }
  .top-search-wrap { max-width: none; }
  .top-actions { gap: 6px; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: none; border-bottom: 1px solid var(--border); padding: 8px 12px; position: static; height: auto; }
  nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .content { padding: 24px 16px; }
}

/* ===== Auth (Comunidade Fase 0): abas Entrar/Criar conta + perfil ===== */
.auth-tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.auth-tab {
  flex: 1; padding: 11px; min-height: 44px; border: 1px solid var(--border); background: transparent;
  color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 0.92em; font-family: inherit;
}
.auth-tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.auth-form { display: flex; flex-direction: column; }
.auth-form > input, .pw-field { margin-bottom: 10px; }
.auth-form input, #token-input {
  box-sizing: border-box; width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text); font-size: 0.95em; font-family: inherit;
}
.auth-form input:focus, #token-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.auth-form button[type="submit"] {
  padding: 12px; border: none; border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 0.96em; cursor: pointer; font-family: inherit; margin-top: 2px;
}
.auth-form button[type="submit"]:hover { opacity: 0.92; }
.auth-form button[type="submit"]:disabled { opacity: 0.5; cursor: default; }
/* mostrar/ocultar senha (olho) */
.pw-field { position: relative; display: block; }
.pw-field > input { margin-bottom: 0; padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: none; border: none; padding: 5px; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; border-radius: 6px;
  min-width: 40px; min-height: 40px;
}
.pw-toggle:hover { color: var(--text); }
.auth-token { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; text-align: left; }
.auth-token summary { cursor: pointer; color: var(--muted); font-size: 0.88em; }
.auth-token[open] summary { margin-bottom: 8px; }

.conta-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px 28px; max-width: 720px; display: flex; flex-direction: column; gap: 2px;
}
.conta-head { margin-bottom: 14px; }
.conta-head h2 { margin: 0 0 2px; font-size: 1.5em; }
.conta-head p { margin: 0; }
.conta-field { display: flex; flex-direction: column; gap: 5px; margin-top: 14px; font-size: 0.82em; color: var(--muted); }
.conta-field input, .conta-field textarea {
  box-sizing: border-box; width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text); font-size: 0.92rem; font-family: inherit;
}
.conta-field input:focus, .conta-field textarea:focus { outline: none; border-color: var(--accent); }
.conta-field textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.conta-card > button {
  margin-top: 22px; padding: 13px; border: none; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 0.96em; cursor: pointer; font-family: inherit;
}
.conta-check { display: flex; align-items: center; gap: 9px; margin-top: 20px; min-height: 44px; font-size: 0.9em; color: var(--text); }
.conta-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.conta-avatar-row { display: flex; align-items: center; gap: 18px; margin-bottom: 6px; }
.conta-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.file-btn { cursor: pointer; }
.muted.small { font-size: 0.82em; margin: 7px 0 0; }

/* Fase 0.5: recuperação de senha + verificação de email */
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.85em; padding: 4px 0; min-height: 44px; display: inline-flex; align-items: center; font-family: inherit; text-decoration: underline; }
.forgot-link-row { text-align: right; margin-top: 4px; }
#form-forgot #forgot-cancel { margin-top: 4px; }
.verify-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 16px; background: var(--bg); }
.verify-box button { margin-top: 8px; }
#verify-step { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
#verify-step input { width: 150px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 0.95em; font-family: inherit; box-sizing: border-box; }
.verify-ok { color: var(--accent); font-size: 0.88em; margin-top: 14px; font-weight: 600; }

/* Fase 1: comunidade + perfil público */
.comm-card { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; transition: box-shadow 0.15s, border-color 0.15s; }
.comm-card:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.comm-avatar { width: var(--av-lg); height: var(--av-lg); border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.comm-card .feed-avatar { width: var(--av-lg); height: var(--av-lg); }
.comm-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; align-items: flex-start; }
.comm-info .muted.small { margin: 2px 0 0; }
.comm-info .ghost-btn { align-self: flex-start; margin-top: 8px; }
.comm-name { font-weight: 600; line-height: 1.25; }
.comm-bio { color: var(--muted); font-size: 0.88em; margin-top: 4px; line-height: 1.45; }
.profile-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 8px; }
.profile-avatar { width: var(--av-xl); height: var(--av-xl); border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.profile-id h1 { margin: 0 0 2px; }
.profile-bio { white-space: pre-wrap; margin: 10px 0 6px; line-height: 1.5; }
.profile-bio-head { margin: 8px 0 10px; max-width: 460px; font-size: 0.95em; }
.profile-about { white-space: pre-wrap; line-height: 1.6; max-width: 640px; color: var(--text); }
.profile-links { display: flex; gap: 8px; font-size: 0.9em; }
.profile-links a { color: var(--accent); }
.profile-acervo-title { font-size: 1.1em; margin: 22px 0 12px; border-top: 1px solid var(--border); padding-top: 18px; }
.profile-head { align-items: flex-start; }
.profile-name-row { display: flex; align-items: center; gap: 10px; }
.profile-name-row h1 { margin: 0; }
.priv-badge { font-size: 0.58em; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 2px 9px; vertical-align: middle; }
.profile-mood { color: var(--accent); font-style: italic; margin: 6px 0; }
.profile-stats { display: flex; gap: 18px; margin: 10px 0 6px; font-size: 0.9em; color: var(--muted); flex-wrap: wrap; }
.profile-stats b { color: var(--text); }
.profile-stats .stat-link { cursor: pointer; }
.profile-stats .stat-link:hover { color: var(--accent); }
/* Modal de lista de pessoas (seguidores / seguindo) */
.lepo-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: flex-start; justify-content: center; z-index: 200; padding: 60px 16px; }
.lepo-modal.show { display: flex; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 420px; max-height: 70vh; display: flex; flex-direction: column; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-x { background: none; border: none; color: var(--muted); cursor: pointer; display: inline-flex; padding: 4px; }
.modal-x:hover { color: var(--text); }
.modal-body { overflow-y: auto; padding: 8px; }
.userlist-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.userlist-row:hover { background: var(--accent-soft); }
/* Fotos com legenda */
.foto-caption { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); max-width: 82%; text-align: center; padding: 6px 12px; border-radius: 10px; font-weight: 500; line-height: 1.3; white-space: pre-wrap; pointer-events: none; font-size: 1.4em; }
.lightbox-wrap { position: relative; display: inline-block; max-width: 100%; font-size: 16px; } /* base do 'em' da legenda no lightbox (grande) */
.lightbox-wrap img { max-width: 100%; max-height: 82vh; display: block; }
.lb-cap { pointer-events: auto; cursor: pointer; transition: opacity .15s; } /* clicar oculta/mostra */
.lb-cap.cap-hidden { opacity: 0; }
.foto-composer { max-width: 460px; }
.foto-prev { position: relative; border-radius: 10px; overflow: hidden; margin-bottom: 12px; background: var(--bg); }
.foto-prev img { width: 100%; display: block; max-height: 320px; object-fit: contain; }
.fc-input { width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.95em; margin-bottom: 10px; }
.fc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.fc-row label { display: inline-flex; align-items: center; gap: 4px; }
.fc-row input[type="color"] { width: 28px; height: 24px; border: 1px solid var(--border); border-radius: 4px; padding: 0; background: none; cursor: pointer; }
.fc-size { min-width: 30px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); cursor: pointer; font-size: 0.85em; font-weight: 600; }
.fc-size.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.fc-select { padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); font-family: inherit; cursor: pointer; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.profile-actions { margin-left: auto; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.profile-tabs { display: flex; gap: 18px; margin: 20px 0 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ptab { background: none; border: none; color: var(--muted); padding: 8px 2px; cursor: pointer; font-size: 0.95em; font-family: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ptab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.ptab:focus-visible, .nav-item:focus-visible, .ghost-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.recado-new { display: flex; gap: 8px; margin-bottom: 14px; }
.recado-new input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; }
.recado { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.feed-avatar.sm { width: var(--av-sm); height: var(--av-sm); }
.locked { color: var(--muted); background: var(--accent-soft); border-radius: 10px; padding: 16px; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 0.85em; background: var(--accent-soft); color: var(--accent); padding: 4px 12px; border-radius: 16px; }
/* Grid de fotos: auto-fill (espelha .media-grid) — mínimo px CONCRETO + min-width:0 = nunca estoura (sem scroll-x); escala de ~380px a 1240px */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; width: 100%; max-width: 680px; margin: 0; }
@media (max-width: 420px) { .fotos-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 5px; } }
.foto-ph { aspect-ratio: 1; min-width: 0; background: var(--accent-soft); border-radius: 8px; }
.sub-h { font-size: 1em; margin: 18px 0 10px; }

/* Leva 2: grupo + leitura + links */
a.rail-line { text-decoration: none; }
.rail-line:hover { color: var(--accent); }
.grp-card { text-decoration: none; color: var(--text); display: block; transition: border-color 0.15s; }
.grp-card:hover { border-color: var(--accent); }
.group-cover { height: 88px; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border-radius: 12px; margin: 8px 0 -28px; }
.group-head { display: flex; align-items: flex-end; gap: 14px; padding: 0 4px; margin-bottom: 14px; }
.group-ico { width: 56px; height: 56px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 0 0 3px var(--bg); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.group-id { flex: 1; }
.group-id h1 { margin: 0; font-size: 1.4em; }
.group-head .ghost-btn { align-self: center; }
.membros-row { display: flex; align-items: center; gap: 8px; }
.gmember { display: inline-block; cursor: pointer; transition: border-color 0.15s, transform 0.1s; }
.gmember:hover { border-color: var(--accent); transform: translateY(-1px); }
.read-author { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; }
.read-title { margin: 0 0 4px; }
.read-body { line-height: 1.7; max-width: 680px; }
.read-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.primary-btn { padding: 9px 18px; border: none; border-radius: 9px; background: var(--accent); color: #fff; font-size: 0.92em; cursor: pointer; font-family: inherit; }
.primary-btn:disabled, .acc[disabled], .acc:disabled { opacity: 0.55; cursor: not-allowed; }
.acc { font-size: 0.9em; padding: 8px 14px; border-radius: 9px; }
.acc-ro { background: var(--accent-soft); color: var(--muted); }

/* Login split (marca + form) — fiel ao wireframe */
.login-split { display: grid; grid-template-columns: 300px 1fr; max-width: 760px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.login-brand { background: var(--accent-soft); padding: 36px 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.login-brand .brand { font-weight: 700; letter-spacing: 4px; color: var(--accent); font-size: 1.6em; }
.login-brand .tagline { font-size: 0.78em; color: var(--muted); margin: 6px 0 0; }
.mascots { display: flex; gap: 14px; margin: 24px 0; }
.mascot { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.8em; color: var(--muted); }
.mascot-ph { width: 56px; height: 56px; border-radius: 50%; }
.mascot-lepo { background: var(--accent); }
.mascot-oculos { background: var(--border); }
.mascot-img { height: 76px; width: auto; max-width: 112px; object-fit: contain; }
.brand-tag { font-size: 0.95em; line-height: 1.6; color: var(--text); max-width: 200px; margin: 0; }
.login-form { padding: 30px 28px; }
@media (max-width: 640px) {
  .login-split { grid-template-columns: 1fr; max-width: 400px; }
  .login-brand { padding: 24px; }
  .mascots { margin: 16px 0; }
}

/* Ícones + botões com ícone */
.ic { vertical-align: -0.15em; flex-shrink: 0; }
.ghost-btn, .primary-btn { display: inline-flex; align-items: center; gap: 6px; }
a.ghost-btn { text-decoration: none; }
.primary-btn.sm { padding: 7px 14px; font-size: 0.88em; }
.ghost-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* Publicações (composer + posts) + fotos + toast + lightbox */
.composer { display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; background: var(--surface); }
.composer-body { flex: 1; min-width: 0; }
.composer-body textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); padding: 9px 11px; font-family: inherit; resize: vertical; }
.composer-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.composer-actions .primary-btn { margin-left: auto; }
.post { display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
.post-body { flex: 1; min-width: 0; }
.post-text { margin: 4px 0; line-height: 1.5; white-space: pre-wrap; }
.post-photo { width: 100%; max-width: 420px; border-radius: 10px; margin-top: 6px; cursor: pointer; display: block; }
.post-edit { margin: 6px 0; }
.post-edit-area { width: 100%; box-sizing: border-box; min-height: 64px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.95em; line-height: 1.5; resize: vertical; }
.post-edit-btns { display: flex; gap: 8px; margin: 8px 0 4px; }
.foto { display: block; width: 100%; height: 100%; min-width: 0; object-fit: cover; object-position: center; cursor: pointer; }
.lepo-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 0.9em; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100; }
.lepo-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.lepo-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.82); display: none; align-items: center; justify-content: center; z-index: 200; cursor: zoom-out; padding: 24px; }
.lepo-lightbox.show { display: flex; }
.lepo-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 12px; }
.post-prev { position: relative; display: inline-block; margin: 8px 0 2px; }
.post-prev img { max-width: 240px; max-height: 170px; border-radius: 8px; display: block; border: 1px solid var(--border); }
.prev-x { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.55); color: #fff; border: none; border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }

/* Gratidão + Comentar + comentários */
.act-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; font-size: 0.85em; color: var(--muted); cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 5px; }
.act-btn:hover { color: var(--text); border-color: var(--border); }
.act-btn.gr.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.comments { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.comment { font-size: 0.9em; padding: 5px 0; }
.comment .feed-author { margin-right: 5px; }
.comment-new { display: flex; gap: 8px; margin-top: 8px; }
.comment-new input { flex: 1; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: inherit; }

/* Excluir post/recado/foto próprios */
.post-del { margin-left: auto; align-self: center; background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; line-height: 1; }
.post-del:hover { color: #b3493f; }
/* Célula quadrada que recorta o thumbnail; font-size:10px = base do 'em' da legenda no thumb (ícones são SVG px-fixos, imunes a isso) */
.foto-wrap { position: relative; aspect-ratio: 1; min-width: 0; overflow: hidden; border-radius: 8px; font-size: 10px; background: var(--accent-soft); }
.foto-wrap .foto-caption { max-width: 90%; max-height: 84%; overflow: hidden; box-sizing: border-box; word-break: break-word; }
.foto-acts { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; z-index: 2; }
.foto-wrap:hover .foto-acts, .foto-acts:focus-within { opacity: 1; }
@media (hover: none) { .foto-acts { opacity: 1; } } /* touch: sem hover, botões sempre acessíveis */
.foto-act { background: rgba(0,0,0,0.5); color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.foto-act:hover { background: rgba(0,0,0,0.74); }
#doc-public-btn.is-public { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* Fase A: Início (feed da comunidade) */
.feed-title { font-size: 1.05em; font-weight: 600; margin: 22px 0 12px; }
.feed-title:first-child { margin-top: 8px; }
.dest-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 4px; }
.dest-card { display: block; text-decoration: none; color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.dest-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.dest-thumb { height: 52px; border-radius: 8px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; color: var(--accent); margin-bottom: 8px; font-size: 22px; }
.dest-title { font-size: 0.9em; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.feed-item { display: flex; gap: 12px; align-items: flex-start; text-decoration: none; color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); transition: border-color 0.15s; }
.feed-item:hover { border-color: var(--accent); }
.feed-avatar { width: var(--av-md); height: var(--av-md); border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.feed-avatar-ph { background: var(--accent-soft); }
.feed-author { font-weight: 600; }
.feed-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; line-height: 1.3; }
.feed-line .muted { font-size: 0.82em; }
.feed-doc { margin-top: 3px; font-size: 1.05em; font-weight: 600; line-height: 1.35; }

/* Reskin LEPO Social — demo + fidelidade */
.demo-pill { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 20px; padding: 4px 12px; font-size: 0.78em; cursor: pointer; }
.demo-pill.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.feed-avatar-ph { position: relative; }
.feed-avatar-ph.grp { display: flex; align-items: center; justify-content: center; font-size: 18px; }
.curadoria-tag { font-size: 0.6em; font-weight: 500; vertical-align: middle; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 10px; }
.badge-premium { display: inline-block; font-size: 0.62em; vertical-align: middle; color: #fff; background: #b9822e; padding: 2px 9px; border-radius: 10px; }
.badge-free { display: inline-block; font-size: 0.62em; color: #fff; background: var(--accent); padding: 2px 9px; border-radius: 10px; }
.dest-card .badge-premium, .dest-card .badge-free { font-size: 0.72em; margin: 2px 0 4px; }
.dest-thumb { font-size: 22px; }

.inicio-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.inicio-rail { display: flex; flex-direction: column; gap: 12px; }
.rail-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); }
.rail-head { font-size: 0.9em; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.rail-head2 { font-size: 0.9em; font-weight: 600; margin-bottom: 8px; }
.rail-label { margin-bottom: 6px; }
.rail-line { font-size: 0.88em; color: var(--muted); padding: 4px 0; }
.online-item { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; color: var(--text); text-decoration: none; }
.online-item:hover .feed-author { color: var(--accent); }
.online-item .feed-avatar { width: var(--av-sm); height: var(--av-sm); }
.online-info { min-width: 0; font-size: 0.85em; }
.online-info .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mood-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 0.85em; }
.mood-card { position: relative; }
.mood-edit { display: flex; align-items: center; gap: 6px; }
.mood-edit input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 0.88em; }
.mood-edit input:focus { outline: none; border-color: var(--accent); }
.mood-emoji-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex-shrink: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; }
.mood-emoji-btn:hover { color: var(--accent); border-color: var(--accent); }
.emoji-pop { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.emoji-opt { width: 32px; height: 32px; border: none; background: none; border-radius: 6px; font-size: 1.05em; cursor: pointer; line-height: 1; }
.emoji-opt:hover { background: var(--accent-soft); }
.act-link { color: var(--accent); cursor: pointer; }
.presence-dot.static { position: static; display: inline-block; vertical-align: middle; width: 9px; height: 9px; border: none; }

.feed-item-static { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
.feed-quote { font-style: italic; color: var(--muted); margin-top: 2px; }
.feed-actions { display: flex; gap: 16px; margin-top: 8px; font-size: 0.85em; color: var(--muted); }
.feed-body .tag { vertical-align: middle; }

.comm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.comm-card.static { display: flex; gap: 12px; align-items: flex-start; }
.ghost-btn.sm { font-size: 0.78em; padding: 4px 12px; margin-top: 7px; color: var(--accent); }
.grp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grp-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); text-align: center; }
.grp-ico { font-size: 22px; margin-bottom: 6px; }
.grp-name { font-size: 0.88em; font-weight: 600; }
.prem-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.prem-card { display: flex; gap: 12px; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); }
.prem-ico { font-size: 24px; flex-shrink: 0; }

@media (max-width: 720px) {
  .inicio-cols { grid-template-columns: 1fr; }
  .comm-grid, .grp-grid, .prem-grid { grid-template-columns: 1fr; }
  .dest-grid { grid-template-columns: 1fr; }
  .group-head { flex-wrap: wrap; }
  .group-head .ghost-btn { align-self: stretch; width: 100%; margin-top: 8px; justify-content: center; min-height: 44px; }
}
@media (max-width: 560px) {
  .profile-head { flex-direction: column; align-items: center; text-align: center; gap: 12px; }
  .profile-avatar { width: var(--av-lg); height: var(--av-lg); }
  .profile-actions { margin-left: 0; flex-direction: row; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; }
  .profile-actions .ghost-btn.sm { min-height: 44px; padding: 10px 16px; }
  .profile-stats { justify-content: center; }
  .doc-detail-head h1 { flex: 1 0 100%; }
  .doc-detail-head .ghost-btn { flex: 1; justify-content: center; min-height: 44px; }
}

/* Menu de exportação */
.export-opts { display: flex; gap: 10px; flex-wrap: wrap; }
.export-opts .ghost-btn { flex: 1; min-width: 96px; justify-content: center; }

/* Exportação PDF: imprime só o material, limpo (esconde shell/controles, força papel branco). */
@media print {
  /* Estrutura (vale p/ claro e escuro): esconde o shell e controles, formata a página. */
  .topbar, .sidebar, #doc-access-lbl, #doc-export-btn, #doc-edit-btn, #doc-del-btn,
  #acervo-back, #doc-note-compose, .lepo-modal, .lepo-toast, .demo-pill, #demo-toggle { display: none !important; }
  .app { display: block !important; }
  .content { padding: 0 !important; max-width: 100% !important; }
  #doc-content a { text-decoration: underline; }
  #doc-content blockquote { border-radius: 6px; padding: 0.5em 0.9em !important; }
  .doc-inline-fig, .media-fig, figure, img, blockquote, pre, table { break-inside: avoid; page-break-inside: avoid; }
  .doc-inline-img, .media-img { max-height: 360px; }
  .media-grid { max-width: 100% !important; }
  @page { margin: 1.6cm; }

  /* ===== Impressão TEMA CLARO (padrão; data-print ausente ou "light") ===== */
  html:not([data-print="dark"]) { --bg: #ffffff; --surface: #ffffff; --text: #20231f; --muted: #555b56; --border: #dfe3df; --accent: #41604f; --accent-soft: #eef2ef; }
  html:not([data-print="dark"]) body { background: #fff !important; }
  html:not([data-print="dark"]) #doc-read, html:not([data-print="dark"]) #doc-content,
  html:not([data-print="dark"]) #doc-content :not(pre):not(code):not(blockquote):not(pre *):not(blockquote *),
  html:not([data-print="dark"]) #doc-title, html:not([data-print="dark"]) #doc-meta, html:not([data-print="dark"]) #doc-notes { color: #20231f !important; }
  html:not([data-print="dark"]) #doc-content pre, html:not([data-print="dark"]) #doc-content code, html:not([data-print="dark"]) #doc-content blockquote {
    background: #eef2ef !important; color: #20231f !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html:not([data-print="dark"]) #doc-content pre *, html:not([data-print="dark"]) #doc-content blockquote * { color: #20231f !important; }
  html:not([data-print="dark"]) #doc-content blockquote { border-left: 3px solid #5a7d6f !important; }
  html:not([data-print="dark"]) #doc-content pre { border: 1px solid #d7ddd6 !important; }

  /* ===== Impressão TEMA ESCURO (data-print="dark") — fundo escuro impresso de fato (print-color-adjust: exact) ===== */
  html[data-print="dark"] { --bg: #161a18; --surface: #1f2522; --text: #e6e8e4; --muted: #9aa39d; --border: #2e3633; --accent: #7fa593; --accent-soft: #232b27; }
  html[data-print="dark"] body, html[data-print="dark"] .app, html[data-print="dark"] .content, html[data-print="dark"] #doc-read, html[data-print="dark"] #doc-content {
    background: #161a18 !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html[data-print="dark"] #doc-read, html[data-print="dark"] #doc-content,
  html[data-print="dark"] #doc-content :not(pre):not(code):not(blockquote):not(pre *):not(blockquote *),
  html[data-print="dark"] #doc-title, html[data-print="dark"] #doc-meta, html[data-print="dark"] #doc-notes { color: #e6e8e4 !important; }
  html[data-print="dark"] #doc-content pre, html[data-print="dark"] #doc-content code, html[data-print="dark"] #doc-content blockquote {
    background: #232b27 !important; color: #e6e8e4 !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html[data-print="dark"] #doc-content pre *, html[data-print="dark"] #doc-content blockquote * { color: #e6e8e4 !important; }
  html[data-print="dark"] #doc-content blockquote { border-left: 3px solid #7fa593 !important; }
  html[data-print="dark"] #doc-content pre { border: 1px solid #2e3633 !important; }
}
