/* ============================================================
   Sesions — hoja de estilos principal (v1.1.0)
   Diseño basado en la maqueta: crema + lima + tinta.
   ============================================================ */

:root {
  --ink: #17181a;
  --ink-soft: #3c3d38;
  --muted: #8a8a80;
  --muted-deep: #6d6e64;
  --paper: #f6f4ee;
  --paper-deep: #edeae1;
  --white: #fffffe;
  --card: #fcfbf8;
  --line: #e8e5db;
  --line-strong: #ddd9cc;
  --acid: #c8f158;
  --acid-soft: #eaf9c4;
  --acid-dark: #86b422;
  --acid-ink: #2e3d09;
  --coral: #f0653f;
  --blue: #3b82f6;
  --violet: #8b5cf6;
  --green: #22c55e;
  --amber: #f59e0b;
  --shadow: 0 16px 44px rgb(28 30 24 / 9%);
  --shadow-pop: 0 24px 64px rgb(20 22 16 / 18%), 0 4px 14px rgb(20 22 16 / 8%);
  --radius: 12px;
  --sidebar: 268px;
  --panel: 300px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { color-scheme: light; }

/* ---------- Scrollbars sutiles en toda la app ---------- */
* { scrollbar-width: thin; scrollbar-color: #cfcaba transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6d2c5; border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b9b4a4; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
/* Versión oscura dentro del editor de código */
.code-body textarea, .rich-editor pre, .update-log { scrollbar-color: #454944 transparent; }
.code-body textarea::-webkit-scrollbar-thumb, .rich-editor pre::-webkit-scrollbar-thumb, .update-log::-webkit-scrollbar-thumb { background: #454944; border: 3px solid transparent; background-clip: padding-box; }
.code-body textarea::-webkit-scrollbar-thumb:hover, .rich-editor pre::-webkit-scrollbar-thumb:hover, .update-log::-webkit-scrollbar-thumb:hover { background: #5a5f59; border: 3px solid transparent; background-clip: padding-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
svg.ic { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg.ic.sm { width: 15px; height: 15px; }
svg.ic.fill { fill: currentColor; stroke: none; }

.wordmark {
  color: var(--ink);
  text-decoration: none;
  font-size: 27px;
  line-height: 1;
  letter-spacing: -1.6px;
  font-weight: 800;
}
.kicker {
  display: block;
  color: var(--muted-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 18px;
  font-weight: 650;
  font-size: 14px;
  text-decoration: none;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #2b2c28; }
.btn-acid { background: var(--acid); color: var(--ink); }
.btn-acid:hover { background: #d3f775; box-shadow: 0 6px 18px rgb(148 197 44 / 25%); }
.btn-ghost { background: var(--white); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: #c7c3b4; }
.btn-wide { width: 100%; }
.btn-small { min-height: 36px; padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn-danger { background: #fbeae6; color: #9c2f1a; border-color: #efc4ba; }
.btn-danger:hover { background: #f8ded7; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted-deep);
  text-decoration: none;
  font-size: 17px;
}
.icon-btn:hover { background: var(--paper-deep); color: var(--ink); }
.text-button { padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.text-button:hover { color: var(--ink); }

.alert { margin: 16px 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); padding: 11px 14px; font-size: 13px; line-height: 1.5; }
.alert.error { color: #8f3025; border-color: #edb3ab; background: #fff3f1; }
.alert.success { color: #3d6500; border-color: #bedc83; background: #f6ffe8; }

/* ---------- Avatares ---------- */
.avatar {
  --avatar: var(--blue);
  position: relative;
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--avatar);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .02em;
  user-select: none;
}
.avatar.lite { color: var(--ink); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar { overflow: visible; }
.avatar .dot {
  z-index: 1;
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--green);
}
.avatar .dot.away { background: var(--amber); }

.privacy-badge { display: inline-flex; align-items: center; gap: 6px; width: max-content; border-radius: 100px; background: #efede5; padding: 5px 11px; color: #5b5c53; font-size: 11px; font-weight: 650; white-space: nowrap; }
.privacy-badge.public { background: var(--acid-soft); color: #46650b; }

/* ============================================================
   Autenticación
   ============================================================ */
.auth-page { min-height: 100vh; background: var(--white); }
.auth-shell { display: grid; grid-template-columns: minmax(360px, .86fr) 1.14fr; min-height: 100vh; }
.auth-brand-panel { display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; padding: 44px clamp(30px, 5vw, 74px); background: var(--paper); border-right: 1px solid var(--line); }
.auth-brand-panel::before { position: absolute; right: -140px; bottom: 7%; width: 420px; height: 420px; border: 90px solid var(--acid); border-radius: 50%; content: ""; opacity: .9; }
.auth-brand-panel::after { position: absolute; right: 20%; bottom: 23%; width: 110px; height: 110px; border-radius: 28px; background: var(--coral); transform: rotate(18deg); content: ""; box-shadow: 140px -130px 0 var(--blue); }
.auth-brand-panel > * { position: relative; z-index: 1; }
.auth-brand-panel h1 { max-width: 590px; margin: 16px 0; font-size: clamp(42px, 5.2vw, 72px); line-height: .99; letter-spacing: -3.5px; font-weight: 800; }
.auth-brand-panel p { max-width: 430px; color: #4c4e47; font-size: 17px; line-height: 1.55; }
.auth-brand-panel small { color: var(--muted); font-weight: 650; }
.auth-form-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(430px, 100%); }
.auth-card h2 { margin: 11px 0 6px; font-size: 34px; letter-spacing: -1.6px; font-weight: 750; }
.auth-card > label, .join-form label { display: flex; justify-content: space-between; margin: 17px 0 7px; font-size: 13px; font-weight: 650; }
.auth-card label small { color: var(--muted); font-weight: 450; }
.auth-card input, .join-form input { width: 100%; height: 48px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 14px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.auth-card input:focus, .join-form input:focus { border-color: var(--acid-dark); box-shadow: 0 0 0 3px rgb(200 241 88 / 30%); }
.auth-card .btn { margin-top: 24px; }
.auth-switch { margin-top: 25px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-switch a { color: var(--ink); font-weight: 700; }
.simple-message { width: min(680px, calc(100% - 40px)); margin: 16vh auto; }
.simple-message h1 { margin: 50px 0 10px; font-size: 50px; letter-spacing: -2.6px; }
.simple-message p { margin-bottom: 28px; color: var(--muted); }

/* ============================================================
   Sidebar compartida (dashboard + editor)
   ============================================================ */
.app-sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 24px 18px 0;
  background: var(--paper);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 0; }
.new-session { margin: 30px 0 16px; font-weight: 700; }
.new-session .plus { font-size: 18px; font-weight: 500; margin-top: -1px; }

.nav-group {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 5px;
  gap: 2px;
}
.nav-group a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
}
.nav-group a svg { color: var(--muted-deep); }
.nav-group a:hover { background: var(--paper); }
.nav-group a.active { background: var(--paper-deep); color: var(--ink); font-weight: 650; }
.nav-group a.active svg { color: var(--ink); }

.sidebar-label { display: block; margin: 26px 8px 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.recent-list { overflow-y: auto; min-height: 0; flex: 1; margin: 0 -6px; padding: 0 6px 14px; scrollbar-width: thin; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: none;
}
.recent-item:hover, .recent-item.active { background: var(--paper-deep); color: var(--ink); }
.recent-item svg { color: var(--muted); }
.recent-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .star { color: var(--acid-dark); }
.recent-item .who { color: var(--muted); }
.recent-item time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.recent-empty { padding: 6px 10px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 74px;
  margin: auto -18px 0;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}
.sidebar-profile > div { overflow: hidden; flex: 1; }
.sidebar-profile strong, .sidebar-profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile strong { font-size: 13px; font-weight: 650; }
.sidebar-profile small { margin-top: 2px; color: var(--muted); font-size: 11.5px; }

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.dashboard-main { min-width: 0; padding: clamp(28px, 4.6vw, 62px); background: var(--white); border-left: 1px solid var(--line); }
.dashboard-header { display: flex; align-items: end; justify-content: space-between; gap: 25px; margin-bottom: 38px; }
.dashboard-header h1 { margin: 10px 0 0; font-size: 46px; line-height: 1; letter-spacing: -2.4px; font-weight: 800; }
.search { display: flex; width: min(340px, 40vw); height: 44px; align-items: center; gap: 9px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 13px; background: #fff; }
.search svg { color: var(--muted); }
.search input { width: 100%; border: 0; outline: 0; font-size: 13.5px; background: none; }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.note-card { position: relative; display: flex; min-height: 216px; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: var(--card); color: inherit; text-decoration: none; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.note-card:hover { transform: translateY(-3px); border-color: #c9c5b6; box-shadow: var(--shadow); }
.note-card-top { display: flex; align-items: center; gap: 8px; }
.file-icon { display: inline-grid; width: 36px; height: 36px; place-items: center; border-radius: 9px; background: var(--paper); color: var(--muted-deep); }
.note-card .fav-toggle { margin-left: auto; border: 0; background: none; color: #c9c5b7; padding: 4px; border-radius: 7px; }
.note-card .fav-toggle:hover { background: var(--paper); color: var(--acid-dark); }
.note-card .fav-toggle.is-fav { color: var(--acid-dark); }
.note-card h2 { margin: 30px 0 6px; overflow-wrap: anywhere; font-size: 19px; line-height: 1.2; letter-spacing: -.5px; font-weight: 700; }
.note-card > p { margin: 0; color: var(--muted); font-size: 12.5px; }
.note-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; border-top: 1px solid var(--line); padding-top: 13px; color: var(--muted); font-size: 11.5px; }
.empty-state { display: grid; min-height: 420px; place-items: center; align-content: center; border: 1px dashed #cdc8ba; border-radius: 18px; text-align: center; }
.empty-mark { display: grid; width: 64px; height: 64px; place-items: center; border-radius: 20px; background: var(--acid); font-size: 26px; }
.empty-state h2 { margin: 20px 0 5px; font-size: 27px; letter-spacing: -1.2px; }
.empty-state p { max-width: 440px; margin: 0 0 22px; color: var(--muted); }

/* ============================================================
   Página de invitado (unirse)
   ============================================================ */
.join-page { min-height: 100vh; padding: 32px; background: var(--paper); }
.join-shell { width: min(1040px, 100%); margin: 0 auto; }
.join-card { display: grid; grid-template-columns: 1.1fr .9fr; overflow: hidden; min-height: 590px; margin-top: 34px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
.session-preview { display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; padding: clamp(40px, 7vw, 80px); background: var(--ink); color: #fff; }
.session-preview::after { position: absolute; right: -100px; bottom: -100px; width: 340px; height: 340px; border: 70px solid var(--acid); border-radius: 50%; content: ""; opacity: .85; }
.session-preview > * { position: relative; z-index: 1; }
.session-preview .file-icon { color: var(--ink); background: var(--acid); }
.session-preview .privacy-badge { margin-top: 80px; color: #d5d6cf; background: #2c2d29; }
.session-preview h1 { max-width: 590px; margin: 18px 0 8px; font-size: clamp(40px, 5.6vw, 62px); line-height: .99; letter-spacing: -3px; font-weight: 800; }
.session-preview p { color: #b9bab2; }
.join-form { display: flex; flex-direction: column; justify-content: center; padding: clamp(38px, 6vw, 72px); }
.join-form h2 { margin: 12px 0 7px; font-size: 33px; line-height: 1.05; letter-spacing: -1.6px; font-weight: 750; }
.join-form > p { color: var(--muted); line-height: 1.55; }
.join-form .btn { margin-top: 18px; }
.privacy-note { text-align: center; font-size: 12px; color: var(--muted); }
.signed-as { padding: 9px 12px; border-radius: 8px; background: var(--paper); font-size: 13px; }

/* ============================================================
   Editor
   ============================================================ */
.editor-page { overflow: hidden; background: var(--white); }
.editor-app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; }
.editor-main { min-height: 0; }
.editor-sidebar { position: relative; z-index: 30; height: 100vh; height: 100dvh; }
.sidebar-close { display: none; }
.editor-main { display: grid; min-width: 0; grid-template-rows: 64px 52px minmax(0, 1fr); background: var(--white); border-left: 1px solid var(--line); }
.editor-main.mode-code { grid-template-rows: 64px 0 minmax(0, 1fr); }
.editor-main.mode-code .format-toolbar { visibility: hidden; height: 0; padding: 0; border: 0; overflow: hidden; }
/* En modo código el lienzo ocupa TODA el área central, sin scroll de página:
   el título vive en la barra oscura y el código tiene su propio scroll interno. */
.editor-main.mode-code .document-scroll { overflow: hidden; }
.editor-main.mode-code .document-shell { display: flex; flex-direction: column; width: 100%; max-width: none; height: 100%; padding: 20px 24px 24px; }
.editor-main.mode-code .code-editor { flex: 1; min-height: 0; margin-top: 0; display: grid; grid-template-rows: 50px minmax(0, 1fr); }

/* Topbar */
.editor-topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; border-bottom: 1px solid var(--line); padding: 0 18px 0 26px; background: var(--white); }
.topbar-left, .topbar-actions { display: flex; min-width: 0; align-items: center; gap: 10px; }
.menu-toggle { display: none; }
.breadcrumb { display: flex; min-width: 0; align-items: center; gap: 9px; font-size: 13.5px; }
.breadcrumb > a, .breadcrumb > span { color: var(--muted); text-decoration: none; white-space: nowrap; }
.breadcrumb > a:hover { color: var(--ink); }
.breadcrumb i { color: #c4c1b5; font-style: normal; }
.breadcrumb-title {
  min-width: 40px;
  max-width: 360px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 9px;
  margin-left: -3px;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.25px;
  color: var(--ink);
  outline: none;
  cursor: text;
  text-overflow: ellipsis;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.breadcrumb-title:hover:not([readonly]):not(:focus) { background: rgb(23 24 26 / 4%); }
.breadcrumb-title:focus { background: #fff; border-color: var(--line-strong); box-shadow: 0 1px 3px rgb(23 24 26 / 8%), 0 0 0 3px rgb(200 241 88 / 30%); max-width: 480px; }
.breadcrumb-title[readonly] { cursor: default; }
.breadcrumb-title::placeholder { color: #bdbaad; font-weight: 500; }
.mode-switch { display: inline-flex; border-radius: 11px; padding: 3px; background: var(--paper-deep); }
.mode-switch button { min-width: 78px; height: 36px; border: 0; border-radius: 8px; background: transparent; font-size: 13.5px; font-weight: 550; color: var(--ink-soft); }
.mode-switch button.active { background: #fff; box-shadow: 0 2px 8px rgb(25 27 20 / 10%); font-weight: 650; color: var(--ink); }
.topbar-actions { justify-content: flex-end; }
.panel-toggle { display: none; }
.save-status { display: flex; align-items: center; gap: 7px; color: var(--muted-deep); font-size: 12.5px; white-space: nowrap; font-weight: 550; }
.save-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.save-status.saving i { background: var(--amber); animation: pulse 1s infinite; }
.save-status.error i { background: #dc2626; }
@keyframes pulse { 50% { opacity: .35; } }
.avatar-stack { display: flex; flex-direction: row-reverse; align-items: center; padding-left: 10px; }
.avatar-stack .avatar { width: 30px; height: 30px; flex-basis: 30px; margin-left: -9px; font-size: 10px; border: 2px solid #fff; }
.avatar-stack .more { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-left: -9px; border: 2px solid #fff; border-radius: 50%; background: var(--paper-deep); color: var(--muted-deep); font-size: 10px; font-weight: 700; z-index: 1; }

.privacy-btn { gap: 7px; font-weight: 600; }
.privacy-btn .chev { color: var(--muted); }

/* Popovers (compartir / privacidad) */
.pop-anchor { position: relative; }
.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 70;
  width: 320px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-pop);
  padding: 10px;
  animation: pop-in .14s ease;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-5px); } }
.pop-option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 13px;
  border: 0;
  border-radius: 11px;
  background: none;
  padding: 12px;
  text-align: left;
}
.pop-option:hover { background: var(--paper); }
.pop-option.selected { background: var(--acid-soft); }
.pop-option.selected .pop-ic { background: var(--acid); color: var(--ink); }
.pop-ic { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px; background: var(--paper); color: var(--ink-soft); }
.pop-option strong { display: block; font-size: 13.5px; font-weight: 650; }
.pop-option small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.pop-sep { height: 1px; margin: 8px 4px; background: var(--line); border: 0; }
.pop-section { padding: 8px 12px 10px; }
.pop-section h4 { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--muted-deep); letter-spacing: .04em; text-transform: uppercase; }
.pop-section .share-link-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.pop-section input, .pop-section select { min-width: 0; height: 38px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 0 10px; background: #fff; outline: 0; font-size: 12.5px; }
.pop-section input:focus { border-color: var(--acid-dark); }
.invite-row { display: grid; grid-template-columns: 1fr 96px auto; gap: 7px; }
.collaborator-list { display: grid; margin-top: 6px; }
.collaborator-list > div { display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); padding: 9px 0; }
.collaborator-list .avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 10px; }
.collaborator-list span:nth-child(2) { min-width: 0; flex: 1; }
.collaborator-list strong, .collaborator-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collaborator-list strong { font-size: 12.5px; }
.collaborator-list small { color: var(--muted); font-size: 11px; }

/* Toolbar de formato */
.format-toolbar { display: flex; align-items: center; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); padding: 0 22px; background: var(--white); scrollbar-width: none; }
.format-toolbar::-webkit-scrollbar { display: none; }
.format-toolbar button { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 14px; }
.format-toolbar button:hover { background: var(--paper); }
.format-toolbar button.active { background: var(--paper-deep); color: var(--ink); }
.format-toolbar button:disabled { opacity: .35; cursor: not-allowed; }
.format-toolbar .block-select { position: relative; }
.format-toolbar .block-select button { min-width: 58px; font-weight: 700; font-size: 14.5px; }
.block-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; width: 190px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-pop); padding: 6px; animation: pop-in .12s ease; }
.block-menu button { display: flex; width: 100%; align-items: center; gap: 10px; height: 38px; border-radius: 8px; padding: 0 10px; font-size: 13.5px; justify-content: flex-start; }
.block-menu button b { width: 30px; font-size: 14px; }
.toolbar-sep { width: 1px; height: 20px; flex: 0 0 1px; margin: 0 8px; background: var(--line); }

/* Área de trabajo */
.editor-workspace { display: grid; min-width: 0; min-height: 0; grid-template-columns: minmax(0, 1fr) var(--panel); grid-template-rows: minmax(0, 1fr); }
.document-scroll { min-height: 0; overflow-y: auto; min-width: 0; scroll-behavior: smooth; }
/* Lienzo alineado a la izquierda con un ancho de lectura cómodo:
   aprovecha el espacio sin dispersar el texto en el centro. */
.document-shell { position: relative; width: 100%; max-width: 900px; margin: 0; padding: 40px clamp(28px, 5vw, 72px) 140px; }

.rich-editor { min-height: 560px; outline: 0; color: #2a2b28; font-size: 16.5px; line-height: 1.72; caret-color: var(--ink); overflow-wrap: break-word; }
.rich-editor > *:first-child { margin-top: 0; }
.rich-editor h1, .rich-editor h2, .rich-editor h3, .rich-editor h4 { color: var(--ink); letter-spacing: -.025em; font-weight: 750; }
.rich-editor h1 { margin: 1.1em 0 .35em; font-size: 30px; line-height: 1.2; }
.rich-editor h2 { margin: 1.5em 0 .5em; font-size: 23px; line-height: 1.25; }
.rich-editor h3 { margin: 1.4em 0 .4em; font-size: 18.5px; line-height: 1.3; }
.rich-editor p { margin: .75em 0; }
.rich-editor ul, .rich-editor ol { padding-left: 1.55em; margin: .7em 0; }
.rich-editor li { margin: .3em 0; padding-left: .2em; }
.rich-editor ol li::marker { font-weight: 600; color: var(--ink); }
.rich-editor blockquote { margin: 1.4em 0; border-left: 3px solid var(--acid); padding: 4px 0 4px 20px; color: #5c5e55; font-size: 17px; }
.rich-editor a { color: #2563eb; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.rich-editor hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }
.rich-editor img { max-width: 100%; border-radius: 12px; }
.rich-editor[contenteditable="false"] { cursor: default; }
.rich-editor:empty::before { color: #b9b6a9; content: "Empieza a escribir…"; pointer-events: none; }

/* Checklist */
.rich-editor ul.checklist { padding-left: 0; list-style: none; }
.rich-editor ul.checklist li { position: relative; margin: .45em 0; padding-left: 34px; list-style: none; }
.rich-editor ul.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .18em;
  width: 19px;
  height: 19px;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.rich-editor ul.checklist li[data-checked="true"]::before {
  border-color: var(--acid-dark);
  background: var(--acid) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%231e2a05" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>') center/12px no-repeat;
}
.rich-editor ul.checklist li[data-checked="true"] { color: var(--muted); }

/* Bloque de código dentro del texto */
.rich-editor pre {
  overflow-x: auto;
  border-radius: 14px;
  padding: 20px 24px;
  margin: 1.3em 0;
  background: #191b18;
  color: #e8eedb;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
}
.rich-editor code { font-family: var(--mono); font-size: .92em; background: var(--paper-deep); border-radius: 5px; padding: 2px 6px; }
.rich-editor pre code { background: none; padding: 0; }

/* Editor de código (modo Código) */
.code-editor { overflow: hidden; margin-top: 26px; border-radius: 16px; background: #16181a; box-shadow: 0 22px 54px rgb(15 17 14 / 22%); }
.code-head { display: flex; height: 50px; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid #2a2d2b; padding: 0 16px; }
.code-head > div { display: flex; gap: 7px; align-items: center; }
.code-dot { width: 11px; height: 11px; border-radius: 50%; }
.code-dot.red { background: #f4655a; }
.code-dot.yellow { background: #f6be4f; }
.code-dot.green { background: #61c554; }
.code-head select, .code-copy { border: 1px solid #383b38; border-radius: 7px; background: #232624; color: #cdd1c8; padding: 6px 10px; font-size: 12px; }
.code-copy:hover { background: #2d302d; }
.code-title { flex: 1; min-width: 0; margin: 0 14px; border: 0; outline: 0; background: transparent; color: #eceee6; text-align: center; font-size: 14px; font-weight: 650; letter-spacing: -.2px; }
.code-title::placeholder { color: #6c7069; }
.code-title:focus { color: #fff; }
.code-body { position: relative; display: grid; min-height: 0; height: 100%; grid-template-columns: 54px minmax(0, 1fr); overflow: hidden; }
.line-numbers { overflow: hidden; margin: 0; height: 100%; border-right: 1px solid #262927; padding: 18px 14px; color: #5b6058; background: #131513; text-align: right; font-family: var(--mono); font-size: 13px; line-height: 1.75; user-select: none; }
.code-body textarea { width: 100%; height: 100%; min-height: 0; resize: none; border: 0; outline: 0; padding: 18px; background: #16181a; color: #e4ead9; caret-color: var(--acid); tab-size: 2; white-space: pre; overflow: auto; font-family: var(--mono); font-size: 13px; line-height: 1.75; scrollbar-color: #3a3d3a #16181a; }
.code-cursor-layer { position: absolute; top: 0; bottom: 0; left: 54px; right: 0; overflow: hidden; pointer-events: none; z-index: 5; }
#codeCursorInner { position: absolute; inset: 0; will-change: transform; }

/* Cursores remotos */
.cursor-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.remote-sel { position: absolute; border-radius: 3px; background: var(--flag, var(--blue)); opacity: .22; transition: top .35s ease, left .35s ease, width .35s ease; }
.cursor-flag { position: absolute; transform: translate(-2px, -4px); transition: top .35s ease, left .35s ease; }
.cursor-flag .pointer {
  width: 0; height: 0;
  border-left: 7px solid var(--flag, var(--blue));
  border-bottom: 7px solid transparent;
  margin-left: 1px;
}
.cursor-flag .tag {
  display: inline-block;
  margin-top: -1px;
  border-radius: 5px;
  border-top-left-radius: 0;
  background: var(--flag, var(--blue));
  color: #fff;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgb(0 0 0 / 18%);
}
.cursor-flag.lite .tag { color: var(--ink); }

/* Panel derecho */
.collab-panel { display: grid; min-height: 0; grid-template-rows: auto minmax(140px, 1fr) auto; border-left: 1px solid var(--line); background: var(--white); }
.collab-panel > section { min-height: 0; border-bottom: 1px solid var(--line); padding: 20px 18px; }
.collab-panel > section:last-of-type { border-bottom: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.panel-title .icon-btn { width: 28px; height: 28px; }
.participants { display: grid; gap: 13px; }
.participant { display: flex; align-items: center; gap: 11px; }
.participant .avatar { width: 36px; height: 36px; flex-basis: 36px; font-size: 11px; }
.participant > div { min-width: 0; }
.participant strong, .participant small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant strong { font-size: 13px; font-weight: 650; }
.participant small { margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.panel-loading, .panel-empty { color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.feed-section { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.feed-tabs { display: flex; gap: 4px; }
.feed-tabs button { border: 0; background: none; border-radius: 7px; padding: 5px 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.feed-tabs button.active { background: var(--paper-deep); color: var(--ink); }
.feed { overflow-y: auto; display: flex; flex-direction: column; gap: 15px; padding-right: 4px; scrollbar-width: thin; }
.feed-item { display: flex; align-items: flex-start; gap: 10px; position: relative; }
.feed-item .avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 9.5px; }
.feed-item .type-dot { position: absolute; left: -1px; top: -1px; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid #fff; z-index: 1; }
.feed-item > div { min-width: 0; flex: 1; }
.feed-item p { margin: 0; color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.feed-item p strong { font-weight: 650; color: var(--ink); }
.feed-item p em { font-style: italic; }
.feed-item time { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.comment-form { margin: 12px 14px 14px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 10px 8px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.comment-form:focus-within { border-color: var(--acid-dark); box-shadow: 0 0 0 3px rgb(200 241 88 / 22%); }
.comment-form textarea { width: 100%; min-height: 22px; max-height: 120px; resize: none; border: 0; outline: 0; font-size: 13px; background: none; font-family: var(--font); }
.comment-form > div { display: flex; align-items: center; justify-content: space-between; }
.comment-form .hints { display: flex; gap: 2px; color: var(--muted); }
.comment-form .hints .icon-btn { width: 28px; height: 28px; font-size: 15px; }
.send-button { display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 8px; background: var(--ink); color: #fff; }
.send-button:hover { background: #2c2d29; }
.send-button:disabled { opacity: .4; }

/* Conflicto de versiones */
.conflict-bar {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid #3a3c37;
  border-radius: 14px;
  background: #1f211d;
  color: #fff;
  padding: 13px 18px;
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  animation: toast-in .2s ease;
}
.conflict-bar .btn { min-height: 34px; padding: 6px 13px; font-size: 12.5px; }

/* Menú contextual (clic derecho) */
.ctx-menu { position: fixed; z-index: 220; min-width: 215px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-pop); padding: 6px; animation: pop-in .1s ease; }
.ctx-item { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; border-radius: 8px; padding: 9px 11px; font-size: 13.5px; font-weight: 550; text-align: left; color: var(--ink-soft); }
.ctx-item:hover { background: var(--paper); color: var(--ink); }
.ctx-item.danger { color: #9c2f1a; }
.ctx-item.danger:hover { background: #fbeae6; }
.ctx-ic { width: 20px; text-align: center; flex: 0 0 20px; }
.ctx-chev { margin-left: auto; color: var(--muted); }
.ctx-sep { height: 1px; margin: 5px 6px; background: var(--line); }
.ctx-sub { max-height: 300px; overflow-y: auto; }

/* Carpetas en la sidebar */
.folder-list { display: grid; margin: 0 -6px 4px; padding: 0 6px; max-height: 180px; overflow-y: auto; }

/* Selector de emojis */
.emoji-pop { position: fixed; z-index: 210; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; width: 264px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow-pop); padding: 10px; animation: pop-in .12s ease; }
.emoji-pop button { border: 0; background: none; border-radius: 7px; padding: 4px 0; font-size: 19px; line-height: 1.3; }
.emoji-pop button:hover { background: var(--paper-deep); }
.mention-pop { position: fixed; z-index: 210; min-width: 200px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-pop); padding: 6px; animation: pop-in .12s ease; }
.mention-pop button { display: flex; width: 100%; align-items: center; gap: 9px; border: 0; background: none; border-radius: 8px; padding: 7px 9px; font-size: 13px; text-align: left; }
.mention-pop button:hover { background: var(--paper); }
.mention-pop .avatar { width: 26px; height: 26px; flex-basis: 26px; font-size: 9px; }

/* Modal propio (alert / confirm / prompt) */
.ui-modal-backdrop { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px; background: rgb(20 21 18 / 46%); backdrop-filter: blur(3px); opacity: 0; transition: opacity .15s ease; }
.ui-modal-backdrop.open { opacity: 1; }
.ui-modal { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow-pop); padding: 24px; transform: translateY(8px) scale(.98); transition: transform .16s ease; }
.ui-modal-backdrop.open .ui-modal { transform: none; }
.ui-modal-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; letter-spacing: -.4px; }
.ui-modal-msg { margin: 0 0 16px; color: var(--muted-deep); font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.ui-modal-input { width: 100%; height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 13px; background: #fff; outline: none; font-size: 14px; margin-bottom: 18px; transition: border-color .15s, box-shadow .15s; }
.ui-modal-input:focus { border-color: var(--acid-dark); box-shadow: 0 0 0 3px rgb(200 241 88 / 28%); }
.ui-modal-input.shake { animation: ui-shake .32s; border-color: #dc2626; }
@keyframes ui-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.ui-modal-actions { display: flex; justify-content: flex-end; gap: 9px; }

/* Toasts */
.toast-region { display: grid; position: fixed; z-index: 320; right: 20px; bottom: 20px; gap: 8px; pointer-events: none; }
.toast { transition: opacity .2s ease, transform .2s ease; }
.toast { min-width: 240px; border: 1px solid #353731; border-radius: 12px; padding: 12px 15px; background: #20221e; color: #fff; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease; }
.toast.error { border-color: #ce4f42; background: #7a2922; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ============================================================
   Admin
   ============================================================ */
.admin-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.admin-main { min-width: 0; padding: clamp(26px, 4vw, 52px); background: var(--white); border-left: 1px solid var(--line); }
.admin-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 34px; }
.admin-header h1 { margin: 10px 0 0; font-size: 40px; line-height: 1; letter-spacing: -2px; font-weight: 800; }
.admin-badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 100px; background: var(--ink); color: var(--acid); padding: 4px 12px; font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 34px; }
.stat-card { border: 1px solid var(--line); border-radius: 14px; padding: 20px; background: var(--card); }
.stat-card .num { display: block; font-size: 36px; font-weight: 800; letter-spacing: -1.8px; line-height: 1; }
.stat-card .lbl { display: block; margin-top: 8px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat-card.accent { background: var(--ink); border-color: var(--ink); color: #fff; }
.stat-card.accent .num { color: var(--acid); }
.stat-card.accent .lbl { color: #a5a79e; }

.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { padding: 13px 16px; text-align: left; color: var(--muted-deep); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border-bottom: 1px solid var(--line); background: var(--card); white-space: nowrap; }
.admin-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: #fbfaf6; }
.admin-table .cell-user { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.admin-table .cell-user strong { display: block; font-size: 13px; }
.admin-table .cell-user small { color: var(--muted); font-size: 11.5px; }
.admin-table .actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 100px; padding: 3px 10px; font-size: 11px; font-weight: 650; background: var(--paper-deep); color: var(--muted-deep); white-space: nowrap; }
.chip.ok { background: var(--acid-soft); color: #46650b; }
.chip.warn { background: #fdeeda; color: #92580b; }
.chip.bad { background: #fbe5e0; color: #9c2f1a; }
.chip.info { background: #e3ecfd; color: #1d4fb8; }

.admin-card { border: 1px solid var(--line); border-radius: 16px; background: var(--card); padding: 26px; margin-bottom: 22px; }
.admin-card h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.6px; }
.admin-card > p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.admin-form { display: grid; gap: 14px; max-width: 560px; }
.admin-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-form label { display: block; font-size: 12.5px; font-weight: 650; margin-bottom: 6px; }
.admin-form input, .admin-form select { width: 100%; height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 12px; background: #fff; outline: none; font-size: 13.5px; }
.admin-form input:focus, .admin-form select:focus { border-color: var(--acid-dark); box-shadow: 0 0 0 3px rgb(200 241 88 / 25%); }
.admin-form .check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 550; }
.admin-form .check input { width: 17px; height: 17px; accent-color: var(--acid-dark); }

.upload-zone { display: grid; place-items: center; gap: 8px; border: 1.5px dashed var(--line-strong); border-radius: 14px; padding: 40px 20px; text-align: center; background: #fff; transition: border-color .15s, background .15s; }
.upload-zone.drag { border-color: var(--acid-dark); background: var(--acid-soft); }
.upload-zone strong { font-size: 14.5px; }
.upload-zone small { color: var(--muted); }
.update-log { margin-top: 18px; border-radius: 12px; background: #191b18; color: #d9e0cb; padding: 18px 20px; font-family: var(--mono); font-size: 12.5px; line-height: 1.8; overflow-x: auto; }
.update-log .ok { color: #a3e635; }
.update-log .err { color: #f87171; }

.note-view { border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: clamp(24px, 4vw, 44px); }
.note-view h1 { font-size: 34px; letter-spacing: -1.6px; margin: 0 0 18px; }

.pagination { display: flex; gap: 6px; margin-top: 18px; justify-content: flex-end; }
.pagination a, .pagination span { display: inline-grid; place-items: center; min-width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; font-size: 13px; text-decoration: none; }
.pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1240px) {
  :root { --sidebar: 240px; --panel: 268px; }
}

@media (max-width: 1100px) {
  .topbar-actions .privacy-btn span.lbl { display: none; }
  .document-shell { padding-inline: 34px; }
}

@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
  .dashboard-shell, .admin-shell { grid-template-columns: 1fr; }
  .dashboard-shell > .app-sidebar, .admin-shell > .app-sidebar { display: none; }
  .editor-app { grid-template-columns: 1fr; }
  .editor-sidebar { position: fixed; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-105%); box-shadow: 20px 0 55px rgb(0 0 0 / 18%); transition: transform .22s ease; }
  .editor-sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-toggle { display: inline-grid; }
  .editor-topbar { grid-template-columns: auto 1fr auto; padding: 0 12px; }
  /* En móvil se conserva el título, se oculta solo el rastro "Sesiones /" */
  .breadcrumb > a, .breadcrumb > span, .breadcrumb i { display: none; }
  .breadcrumb-title { max-width: 42vw; }
  .mode-switch { justify-self: center; }
  .save-status { display: none; }
  .editor-workspace { grid-template-columns: minmax(0, 1fr); }
  .collab-panel { position: fixed; z-index: 50; right: 0; top: 64px; bottom: 0; width: min(320px, 90vw); transform: translateX(105%); transition: transform .22s ease; box-shadow: -20px 0 50px rgb(0 0 0 / 16%); }
  .collab-panel.open { transform: translateX(0); }
  .panel-toggle { display: inline-grid; }
}

@media (max-width: 700px) {
  .dashboard-main { padding: 24px 18px; }
  .dashboard-header { align-items: stretch; flex-direction: column; margin-bottom: 24px; }
  .dashboard-header h1 { font-size: 38px; }
  .search { width: 100%; }
  .join-page { padding: 16px; }
  .join-card { grid-template-columns: 1fr; margin-top: 18px; }
  .session-preview { min-height: 240px; padding: 32px; }
  .session-preview .privacy-badge { margin-top: 40px; }
  .session-preview h1 { font-size: 38px; letter-spacing: -2px; }
  .join-form { padding: 32px 24px; }
  .mode-switch button { min-width: 62px; }
  .format-toolbar { padding-inline: 10px; }
  .document-shell { padding: 34px 22px 110px; }
  .avatar-stack { display: none; }
  .popover { position: fixed; left: 12px; right: 12px; top: auto; bottom: 14px; width: auto; }
  .admin-form .row2 { grid-template-columns: 1fr; }
}
