/* =========================================================
   Variáveis globais de cor e tipografia
   ========================================================= */
:root {
  --ink: #17112f;
  --ink-deep: #100b24;
  --brand-blue: #2c7fc2;
  --brand-purple: #5c068c;
  --brand-magenta: #e71b7e;
  --blue: var(--brand-blue);
  --cyan: #69c5e6;
  --text: #24212f;
  --muted: #746d83;
  --line: #e7e1f0;
  --card: #ffffff;
  --soft: #faf8fd;
  --danger: #bd2d52;
  --success: #16815e;
  --shadow: rgba(23, 17, 47, .08);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

/* =========================================================
   Reset básico e corpo da página
   ========================================================= */
* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 92% 2%, rgba(231, 27, 126, .08), transparent 24rem),
    linear-gradient(135deg, #fbfaff 0%, #f4f8fc 52%, #fff7fb 100%);
  color: var(--text);
  font: 15px/1.55 "Poppins", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

/* =========================================================
   Sidebar (menu lateral)
   ========================================================= */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 248px;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .1);
  background:
    radial-gradient(circle at 12% 4%, rgba(44, 127, 194, .3), transparent 14rem),
    radial-gradient(circle at 80% 35%, rgba(231, 27, 126, .16), transparent 15rem),
    linear-gradient(180deg, #1b123a 0%, #17102f 100%);
  color: #fff;
  padding: 22px 12px 18px;
  box-shadow: 12px 0 36px rgba(16, 11, 36, .12);
}
.brand {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 2px 8px 28px;
}
.brand-logo {
  display: block;
  width: min(100%, 198px);
  padding: 8px 0 4px;
}
.brand-logo img {
  display: block;
  width: 100%;
  height: auto;
}
.brand-copy { display: block; padding-left: 2px; }
.brand strong, .brand small { display: block; }
.brand strong { color: #fff; font-family: "Roboto", Arial, sans-serif; font-size: 14px; letter-spacing: .01em; }
.brand small, .sidebar-user small { color: rgba(255, 255, 255, .58); font-size: 11px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav a {
  border: 1px solid transparent;
  border-radius: 13px;
  color: rgba(255, 255, 255, .7);
  padding: 11px 13px;
  font-weight: 600;
  transition: .18s background var(--ease-out), .18s color var(--ease-out), .18s transform var(--ease-out);
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; transform: translateX(2px); }
.sidebar nav a.active {
  border-color: rgba(255, 255, 255, .15);
  background: linear-gradient(105deg, rgba(44, 127, 194, .9), rgba(92, 6, 140, .95));
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 8, 42, .24);
}
.sidebar-user {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 9px;
  align-items: center;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, .12);
  padding: 18px 8px 4px;
}
.sidebar-user strong, .sidebar-user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { color: #fff; font-size: 13px; }
.sidebar-user > a { grid-column: 2; color: #ff8abe; font-size: 12px; font-weight: 700; }
.sidebar-user > a:hover { color: #fff; }
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brand-blue), var(--brand-purple));
  color: #fff;
  font-weight: 700;
}

/* =========================================================
   Área principal e topbar mobile
   ========================================================= */
.app-main { min-height: 100vh; margin-left: 248px; padding: 28px 34px 50px; }
.mobile-topbar { display: none; }
.mobile-brand { display: flex; align-items: center; gap: 9px; color: #fff; font-family: "Roboto", Arial, sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.mobile-brand img { display: block; width: 112px; height: auto; }

/* =========================================================
   Hero / Banner da página inicial
   ========================================================= */
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 31px;
  background:
    radial-gradient(circle at 92% 2%, rgba(231, 27, 126, .42), transparent 25%),
    radial-gradient(circle at 68% 92%, rgba(44, 127, 194, .55), transparent 32%),
    linear-gradient(120deg, #17102f 0%, #2b0f50 58%, #421067 100%);
  color: #fff;
  padding: 48px 42px;
  box-shadow: 0 20px 45px rgba(23, 17, 47, .18);
}
.hero::before {
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 50%;
  content: "";
}
.hero::after {
  position: absolute;
  right: -70px;
  bottom: -110px;
  width: 270px;
  height: 270px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 50%;
  content: "";
}
.eyebrow { display: block; color: var(--brand-purple); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hero .eyebrow { color: #f7d9ed; }
.pill { display: inline-block; border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; background: rgba(255, 255, 255, .08); padding: 4px 10px; }
.hero h1 { position: relative; z-index: 1; margin: 13px 0 12px; font-family: "Roboto", Arial, sans-serif; font-size: clamp(34px, 5vw, 53px); line-height: 1.04; letter-spacing: -.055em; }
.hero h1 em { color: #ff79b8; font-style: normal; }
.hero > p { position: relative; z-index: 1; max-width: 640px; margin: 0; color: rgba(255, 255, 255, .76); font-size: 15px; }
.hero-search { position: relative; z-index: 1; display: flex; max-width: 900px; gap: 12px; margin-top: 29px; }
.hero-search input {
  width: 100%;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, .19);
  border-radius: 15px;
  outline: none;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  padding: 0 16px 0 45px;
  transition: .18s border-color var(--ease-out), .18s box-shadow var(--ease-out);
}
.hero-search input:focus { border-color: rgba(255, 255, 255, .6); box-shadow: 0 0 0 4px rgba(255, 255, 255, .1); }
.hero-search input::placeholder { color: rgba(255, 255, 255, .56); }
.search-icon { position: absolute; top: 11px; left: 16px; color: rgba(255, 255, 255, .78); font-size: 23px; }

/* =========================================================
   Botões
   ========================================================= */
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: .16s transform var(--ease-out), .18s box-shadow var(--ease-out), .18s background var(--ease-out), .18s border-color var(--ease-out);
}
.button:active, .send-button:active { transform: scale(.97); }
.button.primary { background: linear-gradient(105deg, var(--brand-purple), var(--brand-magenta)); color: #fff; box-shadow: 0 8px 18px rgba(92, 6, 140, .22); }
.button.primary:hover { box-shadow: 0 11px 23px rgba(231, 27, 126, .27); transform: translateY(-1px); }
.button.bright { background: linear-gradient(105deg, #ff5ba9, var(--brand-magenta)); color: #fff; box-shadow: 0 8px 18px rgba(231, 27, 126, .26); }
.button.bright:hover { box-shadow: 0 11px 24px rgba(231, 27, 126, .34); transform: translateY(-1px); }
.button.secondary { border-color: #ded8ea; background: #fff; color: var(--text); }
.button.secondary:hover { border-color: rgba(92, 6, 140, .35); background: #faf7fd; color: var(--brand-purple); }
.button.danger { border-color: #f0c7d3; background: #fff; color: var(--danger); }
.button.danger:hover { background: #fff4f6; }

/* =========================================================
   Cards de estatísticas
   ========================================================= */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 20px 0 30px; }
.stat-card { display: flex; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .86); padding: 18px; box-shadow: 0 5px 15px var(--shadow); }
.stat-card strong, .stat-card small { display: block; }
.stat-card strong { font-family: "Roboto", Arial, sans-serif; font-size: 25px; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); }
.stat-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 19px; }
.blue { background: #e6f2fb; color: var(--brand-blue); }
.purple { background: #f1e6f7; color: var(--brand-purple); }
.green { background: #e5f7ef; color: var(--success); }

/* =========================================================
   Layout da biblioteca + painel da IA
   ========================================================= */
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 24px; }
.section-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 13px; }
.section-head h2 { margin: 2px 0 0; font-family: "Roboto", Arial, sans-serif; font-size: 25px; letter-spacing: -.035em; }
.text-link { color: var(--brand-purple); font-size: 13px; font-weight: 700; }
.text-link:hover { color: var(--brand-magenta); }
.posts-list { display: grid; gap: 10px; }
.post-row { display: flex; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255, 255, 255, .92); padding: 18px 20px; transition: .18s box-shadow var(--ease-out), .18s transform var(--ease-out), .18s border-color var(--ease-out); }
.post-row:hover { border-color: rgba(92, 6, 140, .32); box-shadow: 0 12px 26px rgba(23, 17, 47, .1); transform: translateY(-2px); }
.post-row h3 { margin: 8px 0 2px; font-family: "Roboto", Arial, sans-serif; font-size: 17px; letter-spacing: -.02em; }
.post-row p { margin: 0; color: var(--muted); font-size: 14px; }
.post-row small { display: block; margin-top: 12px; color: var(--muted); font-size: 12px; }
.row-arrow { color: var(--brand-purple); font-size: 21px; }
.status, .media-tag { display: inline-block; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.status.published { background: #e5f7ef; color: var(--success); }
.status.draft { background: #fff0dc; color: #9a6017; }
.media-tag { margin-left: 5px; background: #f1e8f7; color: var(--brand-purple); }
.empty-state { border: 1px dashed #d5cbe2; border-radius: 17px; background: rgba(255, 255, 255, .76); padding: 54px 20px; text-align: center; }
.empty-state > span { color: var(--brand-purple); font-size: 37px; }
.empty-state h3 { margin: 7px 0 2px; font-family: "Roboto", Arial, sans-serif; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }

/* =========================================================
   Painel do assistente de IA
   ========================================================= */
.ai-panel { align-self: start; position: sticky; top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: rgba(255, 255, 255, .92); box-shadow: 0 7px 24px rgba(23, 17, 47, .08); }
.ai-head { display: flex; align-items: center; gap: 10px; background: linear-gradient(105deg, #eef7fc, #f5eafa); padding: 16px; }
.ai-head strong, .ai-head small { display: block; }
.ai-head strong { font-family: "Roboto", Arial, sans-serif; }
.ai-head small { color: var(--muted); font-size: 12px; }
.ai-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(145deg, var(--brand-blue), var(--brand-purple)); color: #fff; }
.ai-messages { display: flex; min-height: 250px; max-height: 365px; flex-direction: column; gap: 10px; overflow: auto; padding: 18px; }
.ai-empty { width: 100%; margin: auto; color: var(--muted); text-align: center; }
.ai-empty > span { display: block; color: var(--brand-magenta); font-size: 39px; }
.prompt-list { display: grid; gap: 8px; margin-top: 15px; }
.prompt-list button { border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #5f5771; padding: 8px; font-size: 12px; transition: .18s border-color var(--ease-out), .18s color var(--ease-out), .18s background var(--ease-out); }
.prompt-list button:hover { border-color: rgba(231, 27, 126, .35); background: #fff8fc; color: var(--brand-purple); }
.message { max-width: 89%; border-radius: 14px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; }
.message.user { align-self: end; background: linear-gradient(105deg, var(--brand-purple), var(--brand-magenta)); color: #fff; }
.message.assistant { background: #f4f0f8; }
.message.loading { color: var(--muted); font-style: italic; }
.ai-form { display: flex; align-items: end; gap: 8px; border-top: 1px solid var(--line); padding: 12px; }
.ai-form textarea { width: 100%; min-height: 42px; max-height: 90px; resize: vertical; border: 1px solid #ded8ea; border-radius: 12px; outline: none; padding: 10px; }
.ai-form textarea:focus { border-color: rgba(92, 6, 140, .5); box-shadow: 0 0 0 3px rgba(92, 6, 140, .1); }
.send-button { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: linear-gradient(145deg, var(--brand-blue), var(--brand-purple)); color: #fff; transition: .16s transform var(--ease-out), .18s box-shadow var(--ease-out); }
.send-button:hover { box-shadow: 0 8px 16px rgba(92, 6, 140, .2); }
.ai-sources { border-top: 1px solid var(--line); padding: 12px; }
.ai-sources strong { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.ai-sources div { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-sources a { border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 11px; }
.ai-sources a:hover { border-color: var(--brand-magenta); color: var(--brand-purple); }

/* =========================================================
   Página de post e editor
   ========================================================= */
.editor-shell, .post-page { max-width: 920px; margin: 0 auto; }
.editor-top, .post-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 5px 0 18px; }
.editor-top p { margin: 0; color: var(--muted); font-size: 13px; }
.back-link { color: var(--brand-purple); font-size: 14px; font-weight: 700; }
.back-link:hover { color: var(--brand-magenta); }
.editor-card, .post-header, .post-content { border: 1px solid var(--line); border-radius: 28px; background: rgba(255, 255, 255, .94); padding: 35px; box-shadow: 0 7px 20px rgba(23, 17, 47, .06); }
.editor-card header { margin-bottom: 25px; border-bottom: 1px solid var(--line); padding-bottom: 22px; }
.editor-card h1 { margin: 3px 0 7px; font-family: "Roboto", Arial, sans-serif; font-size: 32px; letter-spacing: -.04em; }
.editor-card header p { margin: 0; color: var(--muted); }
.field { margin-top: 19px; }
.field label { display: block; margin-bottom: 7px; font-weight: 700; }
.field label small { color: var(--muted); font-weight: 400; }
.field input, .field textarea { width: 100%; resize: vertical; border: 1px solid #ded8ea; border-radius: 13px; outline: none; padding: 12px 13px; background: #fff; }
.field input:focus, .field textarea:focus, .editor-area:focus { border-color: rgba(92, 6, 140, .55); box-shadow: 0 0 0 3px rgba(92, 6, 140, .1); }

.rich-editor { overflow: hidden; border: 1px solid #ded8ea; border-radius: 15px; background: #fff; }

/* Barra de ferramentas do editor */
.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #fbf8fd;
  padding: 8px;
}

.editor-tools button,
.editor-tools select {
  min-width: 34px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-purple);
  font-size: 13px;
  font-weight: 700;
  padding: 0 8px;
  cursor: pointer;
  line-height: 1;
}

.editor-tools button:hover,
.editor-tools select:hover {
  background: #f1e6f7;
}

.editor-tools button:active {
  background: #e8d9f3;
}

.editor-tools select {
  min-width: 96px;
  border: 1px solid #e5dff0;
  background: #fff;
  color: var(--text);
  font-weight: 600;
}

.tool-separator {
  width: 1px;
  height: 22px;
  background: #e2dae8;
  margin: 0 4px;
}

.editor-area {
  min-height: 250px;
  outline: 0;
  padding: 15px;
  line-height: 1.75;
}

.editor-area:empty::before {
  color: #9c95a8;
  content: attr(data-placeholder);
}

/* Títulos dentro do editor */
.editor-area h1 {
  font-size: 1.8em;
  margin: 0.6em 0 0.3em;
  font-family: "Roboto", Arial, sans-serif;
}

.editor-area h2 {
  font-size: 1.45em;
  margin: 0.55em 0 0.25em;
  font-family: "Roboto", Arial, sans-serif;
}

.editor-area h3 {
  font-size: 1.2em;
  margin: 0.5em 0 0.2em;
  font-family: "Roboto", Arial, sans-serif;
}

.editor-area p {
  margin: 0.4em 0;
}

/* Tamanhos de fonte gerados pelo execCommand('fontSize') */
.editor-area font[size="1"] { font-size: 0.85em; }
.editor-area font[size="3"] { font-size: 1em; }
.editor-area font[size="5"] { font-size: 1.25em; }
.editor-area font[size="7"] { font-size: 1.6em; }

.upload-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 15px;
  margin-top: 21px;
  border: 1px dashed #d5cbe2;
  border-radius: 16px;
  background: #fcf9fd;
  padding: 15px;
}

.upload-zone > div:first-child { flex: 1; }
.upload-zone strong, .upload-zone small { display: block; }
.upload-zone strong { color: var(--brand-purple); }
.upload-zone small { color: var(--muted); font-size: 12px; }

.file-list { display: grid; width: 100%; gap: 5px; }
.file-list span { border-radius: 8px; background: #f6f0f9; padding: 5px 8px; font-size: 12px; }
.file-list small { display: inline; color: var(--muted); }

.editor-card footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.post-header { padding: 36px 40px; }
.post-header h1 {
  margin: 13px 0 10px;
  font-family: "Roboto", Arial, sans-serif;
  font-size: 46px;
  line-height: 1.08;
  letter-spacing: -.055em;
}
.post-header > p {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}
.post-id { margin-left: 8px; color: var(--muted); }

.audit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 27px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.audit-grid div { display: flex; gap: 8px; color: var(--brand-purple); }
.audit-grid p { margin: 0; color: var(--muted); font-size: 13px; }
.audit-grid strong { display: block; color: var(--text); }

/* =========================================================
   Grade de anexos na página do post
   ========================================================= */
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 20px 0;
}
.media-grid figure {
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 15px rgba(23, 17, 47, .05);
}
.media-grid img,
.media-grid video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--ink-deep);
}
.media-grid figcaption {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
}

/* Itens clicáveis da grade (lightbox) */
.media-item {
  cursor: zoom-in;
  position: relative;
  overflow: hidden;
}
.media-item img,
.media-item video {
  transition: transform .25s ease;
}
.media-item:hover img,
.media-item:hover video {
  transform: scale(1.03);
}
.media-item .play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  color: #fff;
  background: rgba(0, 0, 0, .35);
  pointer-events: none;
  border-radius: inherit;
}

.post-content {
  margin-top: 20px;
  font-size: 16px;
  line-height: 1.85;
}
.post-content h1,
.post-content h2,
.post-content h3 {
  font-family: "Roboto", Arial, sans-serif;
  line-height: 1.2;
  letter-spacing: -.025em;
}
.post-content img,
.post-content video {
  max-width: 100%;
  border-radius: 14px;
}
.post-content a {
  color: var(--brand-purple);
  text-decoration: underline;
  text-decoration-color: rgba(231, 27, 126, .45);
  text-underline-offset: 3px;
}

.revision-note {
  margin-top: 17px;
  border: 1px dashed #d5cbe2;
  border-radius: 14px;
  background: rgba(255, 255, 255, .6);
  color: var(--muted);
  padding: 14px 16px;
  font-size: 13px;
}
/* =========================================================
   Página de login
   ========================================================= */
.auth-main { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: radial-gradient(circle at 4% 12%, rgba(44, 127, 194, .18), transparent 25rem), radial-gradient(circle at 93% 86%, rgba(231, 27, 126, .16), transparent 25rem), linear-gradient(135deg, #f8fbff, #f5edfa); }
.auth-card { width: min(100%, 470px); border: 1px solid rgba(255, 255, 255, .85); border-radius: 30px; background: rgba(255, 255, 255, .9); padding: 39px; box-shadow: 0 24px 60px rgba(23, 17, 47, .14); backdrop-filter: blur(12px); }
.auth-brand { margin-bottom: 24px; }
.auth-logo { display: block; width: 100%; border-radius: 18px; background: linear-gradient(120deg, #17102f, #421067); padding: 17px 19px; box-shadow: 0 13px 28px rgba(92, 6, 140, .2); }
.auth-logo img { display: block; width: 100%; height: auto; }
.auth-brand .eyebrow { margin-top: 14px; }
.auth-card h1 { margin: 5px 0; font-family: "Roboto", Arial, sans-serif; font-size: 30px; line-height: 1.1; letter-spacing: -.04em; }
.auth-card > p { color: var(--muted); }
.form-stack { display: grid; gap: 15px; margin-top: 23px; }
.form-stack label { display: grid; gap: 6px; font-weight: 700; }
.form-stack input { border: 1px solid #ded8ea; border-radius: 12px; outline: none; padding: 12px; background: #fff; }
.form-stack input:focus { border-color: rgba(92, 6, 140, .55); box-shadow: 0 0 0 3px rgba(92, 6, 140, .1); }
.alert, .toast { border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.alert.error, .toast.error { background: #fff0f4; color: #a3264d; }
.alert.success, .toast.success { background: #e6f7ef; color: #147450; }
.toast { margin-bottom: 15px; }

/* =========================================================
   Dialogs genéricos (exclusão etc.)
   ========================================================= */
dialog { width: min(95vw, 450px); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 22px 65px rgba(16, 11, 36, .28); }
dialog::backdrop { background: rgba(16, 11, 36, .62); }
dialog form { padding: 25px; }
dialog h2 { margin: 0; font-family: "Roboto", Arial, sans-serif; font-size: 24px; letter-spacing: -.03em; }
dialog p { color: var(--muted); }
dialog menu { display: flex; justify-content: flex-end; gap: 9px; margin: 22px 0 0; padding: 0; }

/* =========================================================
   Lightbox de mídia (imagem / vídeo) com fade
   ========================================================= */
.media-dialog {
  width: min(96vw, 1100px);
  max-height: 92vh;
  padding: 0;
  border: none;
  border-radius: 18px;
  background: #0f0b1a;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .45);
  overflow: hidden;

  /* Estado inicial (invisível) */
  opacity: 0;
  transform: scale(0.96);
  transition: opacity .28s ease, transform .28s ease, display .28s allow-discrete;
}

/* Quando o dialog está aberto */
.media-dialog[open] {
  opacity: 1;
  transform: scale(1);
}

/* Animação de saída (quando fecha) */
@starting-style {
  .media-dialog[open] {
    opacity: 0;
    transform: scale(0.96);
  }
}

.media-dialog::backdrop {
  background: rgba(12, 8, 24, .78);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .28s ease, display .28s allow-discrete;
}

.media-dialog[open]::backdrop {
  opacity: 1;
}

@starting-style {
  .media-dialog[open]::backdrop {
    opacity: 0;
  }
}

.media-dialog-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  max-height: 92vh;
  padding: 12px;
}

.media-dialog-body img,
.media-dialog-body video {
  max-width: 100%;
  max-height: calc(92vh - 24px);
  width: auto;
  height: auto;
  border-radius: 10px;
  object-fit: contain;
  background: #000;

  /* Fade + leve zoom no conteúdo */
  opacity: 0;
  transform: scale(0.97);
  transition: opacity .32s ease .05s, transform .32s ease .05s;
}

.media-dialog[open] .media-dialog-body img,
.media-dialog[open] .media-dialog-body video {
  opacity: 1;
  transform: scale(1);
}

.media-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background .2s, transform .2s, opacity .25s ease;
  opacity: 0;
}

.media-dialog[open] .media-close {
  opacity: 1;
}

.media-close:hover {
  background: rgba(255, 255, 255, .22);
  transform: scale(1.06);
}

/* Mobile */
@media (max-width: 640px) {
  .media-dialog {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .media-dialog-body {
    max-height: 100vh;
    padding: 8px;
  }

  .media-dialog-body img,
  .media-dialog-body video {
    max-height: calc(100vh - 16px);
  }
}
/* =========================================================
   Responsividade
   ========================================================= */
@media (max-width: 900px) {
  .sidebar { width: 210px; }
  .app-main { margin-left: 210px; padding: 20px; }
  .content-grid { grid-template-columns: 1fr; }
  .ai-panel { position: static; }
  .hero-search { max-width: none; }
  .post-header h1 { font-size: 38px; }
}
@media (max-width: 680px) {
  .sidebar { display: none; }
  .mobile-topbar { position: sticky; top: 0; z-index: 30; display: flex; height: 60px; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255, 255, 255, .12); background: linear-gradient(105deg, #17102f, #321052); padding: 0 15px; box-shadow: 0 8px 20px rgba(16, 11, 36, .16); }
  .icon-button { border: 0; background: transparent; color: #fff; font-size: 20px; }
  .icon-button:hover { color: #ff79b8; }
  .menu-open .sidebar { display: flex; width: 248px; box-shadow: 18px 0 40px rgba(16, 11, 36, .27); }
  .app-main { margin-left: 0; padding: 14px; }
  .hero { border-radius: 25px; padding: 28px 20px; }
  .hero h1 { font-size: 35px; }
  .hero > p { font-size: 14px; }
  .hero-search { display: grid; }
  .hero-search .button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; margin: 15px 0 24px; }
  .section-head { align-items: center; }
  .section-head h2 { font-size: 22px; }
  .text-link { font-size: 11px; }
  .post-row { padding: 16px; }
  .content-grid { gap: 20px; }
  .editor-top { margin: 4px 3px 14px; }
  .editor-top p { display: none; }
  .editor-card, .post-header, .post-content { border-radius: 23px; padding: 22px; }
  .editor-card h1 { font-size: 28px; }
  .editor-card footer { flex-direction: column-reverse; }
  .editor-card footer .button { width: 100%; }
  .post-actions { align-items: flex-start; }
  .post-actions > span { display: grid; gap: 6px; }
  .post-header h1 { font-size: 34px; }
  .audit-grid, .media-grid { grid-template-columns: 1fr; }
  .post-header > p { font-size: 15px; }
  .auth-card { padding: 28px 22px; }
  .auth-logo { padding: 13px 14px; }
  .upload-zone { align-items: flex-start; }
  .upload-zone .button { width: 100%; }

  /* Lightbox em mobile ocupa a tela toda */
  .media-dialog {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .media-dialog-body {
    max-height: 100vh;
    padding: 8px;
  }
  .media-dialog-body img,
  .media-dialog-body video {
    max-height: calc(100vh - 16px);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* =========================================================
   Gestão de anexos (edição de post) e administração
   ========================================================= */
.media-manager { margin-top: 27px; border-top: 1px solid var(--line); padding-top: 24px; }
.media-manager .section-head { margin-bottom: 14px; }
.media-manager h2 { margin: 3px 0 5px; font-family: "Roboto", Arial, sans-serif; font-size: 22px; letter-spacing: -.035em; }
.media-manager p { margin: 0; color: var(--muted); font-size: 13px; }
.existing-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.existing-media-item { position: relative; display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; transition: .18s border-color var(--ease-out), .18s box-shadow var(--ease-out), .18s transform var(--ease-out); }
.existing-media-item:hover { border-color: rgba(189, 45, 82, .45); box-shadow: 0 8px 18px rgba(23, 17, 47, .08); transform: translateY(-1px); }
.existing-media-item:has(input:checked) { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(189, 45, 82, .13); }
.existing-media-item > input { position: absolute; top: 10px; right: 10px; z-index: 2; width: 18px; height: 18px; accent-color: var(--danger); }
.existing-media-preview { display: grid; place-items: center; height: 130px; overflow: hidden; background: #f6f1f8; }
.existing-media-preview img, .existing-media-preview video { width: 100%; height: 100%; object-fit: cover; }
.existing-media-meta { display: grid; gap: 3px; padding: 10px; }
.existing-media-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.existing-media-meta small, .existing-media-meta em { color: var(--muted); font-size: 11px; font-style: normal; }
.existing-media-item:has(input:checked) .existing-media-meta em { color: var(--danger); font-weight: 700; }
.empty-state.compact { min-height: 130px; padding: 20px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 18px; }
.admin-card { border: 1px solid var(--line); border-radius: 22px; background: rgba(255, 255, 255, .94); padding: 24px; box-shadow: 0 7px 20px rgba(23, 17, 47, .06); }
.admin-card h2 { margin: 0 0 5px; font-family: "Roboto", Arial, sans-serif; letter-spacing: -.035em; }
.admin-card > p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.admin-card .field:first-of-type { margin-top: 0; }
.admin-card textarea { min-height: 240px; }
.admin-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; border-top: 1px solid var(--line); padding-top: 17px; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: 12px 9px; text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.admin-table td strong, .admin-table td small { display: block; }
.admin-table td small { color: var(--muted); }
.admin-table .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.admin-table .button { min-height: 34px; padding: 7px 10px; font-size: 12px; }
.role-badge, .state-badge { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 700; }
.role-badge { background: #f1e6f7; color: var(--brand-purple); }
.state-badge.active { background: #e6f7ef; color: var(--success); }
.state-badge.inactive { background: #fff0f4; color: var(--danger); }
.secret-note { border-radius: 10px; background: #fff8ed; color: #8a5d1e; padding: 10px 12px; font-size: 12px; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .existing-media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .admin-card { padding: 18px; } .admin-actions { flex-direction: column; } .admin-actions .button { width: 100%; } }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-heading h1 { margin: 4px 0 7px; font-family: "Roboto", Arial, sans-serif; font-size: 37px; letter-spacing: -.05em; }
.page-heading p { margin: 0; color: var(--muted); }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-card select { width: 100%; border: 1px solid #ded8ea; border-radius: 13px; outline: none; padding: 12px 13px; background: #fff; }
.admin-card select:focus { border-color: rgba(92, 6, 140, .55); box-shadow: 0 0 0 3px rgba(92, 6, 140, .1); }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 15px; color: var(--muted); font-size: 13px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--brand-purple); }
.admin-card code { border-radius: 5px; background: #f3eef7; padding: 2px 5px; color: var(--brand-purple); font-size: .9em; }
.admin-table form { margin: 0; }
@media (max-width: 680px) {
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .page-heading h1 { font-size: 31px; }
  .admin-form-grid { grid-template-columns: 1fr; }
}