:root {
  --mapas-study-width: 620px;
  --mapas-study-blue: #5b75f7;
  --mapas-study-ink: #242936;
  --mapas-study-border: #dde2ec;
  --mapas-study-soft: #f5f7fb;
}

.mapas-study-launcher {
  position: fixed;
  z-index: 190;
  left: 24px;
  bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 17px;
  border: 1px solid rgba(91, 117, 247, .26);
  border-radius: 15px;
  background: rgba(255, 255, 255, .96);
  color: var(--mapas-study-ink);
  box-shadow: 0 12px 34px rgba(33, 43, 79, .16);
  font: 600 14px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.mapas-study-launcher > span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #7088ff, #546cee);
  color: white;
  font-size: 17px;
}

.mapas-study-launcher:hover,
.mapas-study-launcher.is-open {
  transform: translateY(-1px);
  border-color: rgba(91, 117, 247, .6);
}

.mapas-study-panel,
.mapas-study-panel * {
  box-sizing: border-box;
}

.mapas-study-panel {
  position: fixed;
  z-index: 180;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  width: var(--mapas-study-width);
  max-width: calc(100vw - 320px);
  background: #f7f8fb;
  color: var(--mapas-study-ink);
  border-left: 1px solid var(--mapas-study-border);
  box-shadow: -18px 0 44px rgba(25, 32, 55, .13);
  transform: translateX(calc(100% + 30px));
  visibility: hidden;
  transition: transform .24s ease, visibility .24s;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mapas-study-panel.is-open:not([data-mode="map"]) {
  transform: translateX(0);
  visibility: visible;
}

.mapas-study-resizer {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  left: -6px;
  width: 12px;
  cursor: ew-resize;
  touch-action: none;
}

.mapas-study-resizer::after {
  content: "";
  position: absolute;
  top: 45%;
  bottom: 45%;
  left: 5px;
  width: 2px;
  min-height: 40px;
  border-radius: 2px;
  background: transparent;
}

.mapas-study-resizer:hover::after {
  background: var(--mapas-study-blue);
}

.mapas-study-header {
  min-height: 70px;
  padding: 12px 14px 11px 18px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--mapas-study-border);
}

.mapas-study-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mapas-study-brand > span {
  display: grid;
  flex: 0 0 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: linear-gradient(135deg, #7088ff, #536bec);
  font-size: 22px;
}

.mapas-study-brand div {
  min-width: 0;
}

.mapas-study-brand strong,
.mapas-study-brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapas-study-brand strong { font-size: 17px; }
.mapas-study-brand small { margin-top: 3px; color: #778093; font-size: 11px; }

.mapas-study-modes {
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: 11px;
  background: #f0f2f7;
}

.mapas-study-modes button,
.mapas-study-close,
.mapas-study-toolbar button,
.mapas-study-actions button,
.mapas-study-docbar button,
.mapas-study-comments button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.mapas-study-modes button {
  min-width: 60px;
  height: 34px;
  padding: 0 9px;
  border-radius: 8px;
  background: transparent;
  color: #717a8c;
  font-size: 12px;
}

.mapas-study-modes button span { margin-left: 4px; }
.mapas-study-modes button.is-active { background: white; color: #405bd8; box-shadow: 0 2px 8px rgba(42, 55, 94, .1); }

.mapas-study-close {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: transparent;
  color: #687184;
  font-size: 27px;
}

.mapas-study-close:hover { background: #f0f2f7; color: #252b38; }

.mapas-study-docbar {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto auto minmax(74px, auto);
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding: 8px 16px;
  background: white;
  border-bottom: 1px solid var(--mapas-study-border);
}

.mapas-study-docselect,
.mapas-study-docbar button,
.mapas-study-toolbar select {
  height: 36px;
  border: 1px solid #d8deea;
  border-radius: 9px;
  background: white;
  color: #333a49;
}

.mapas-study-docselect { min-width: 0; padding: 0 30px 0 11px; font-weight: 650; }
.mapas-study-docbar button { padding: 0 11px; }
.mapas-study-newdoc { font-size: 19px !important; }
.mapas-study-docbar button:hover { border-color: #98a8f8; background: #f6f7ff; }
.mapas-study-docbar button:disabled,
.mapas-study-actions button:disabled { opacity: .45; cursor: not-allowed; }
.mapas-study-panel.is-readonly .mapas-study-toolbar,
.mapas-study-panel.is-readonly .mapas-study-actions .mapas-study-action-group:first-child { display: none; }

.mapas-study-status {
  justify-self: end;
  color: #7a8496;
  font-size: 11px;
  white-space: nowrap;
}
.mapas-study-status[data-state="saved"] { color: #278760; }
.mapas-study-status[data-state="error"] { color: #c6424e; white-space: normal; text-align: right; }

.mapas-study-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 45px;
  padding: 6px 16px;
  background: white;
  border-bottom: 1px solid var(--mapas-study-border);
}

.mapas-study-toolbar button {
  min-width: 31px;
  height: 31px;
  padding: 0 8px;
  border-radius: 7px;
  background: transparent;
  color: #4e5666;
  font-size: 13px;
}

.mapas-study-toolbar button:hover,
.mapas-study-toolbar button.is-active { background: #edf0ff; color: #405bd8; }
.mapas-study-toolbar select { height: 31px; padding: 0 24px 0 8px; font-size: 12px; }
.mapas-study-toolbar input[type="color"] { width: 31px; height: 31px; padding: 5px; border: 0; border-radius: 7px; background: transparent; }
.mapas-study-separator { width: 1px; height: 24px; margin: 0 3px; background: #e1e5ee; }

.mapas-study-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 7px 16px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--mapas-study-border);
}

.mapas-study-action-group { display: flex; flex-wrap: wrap; gap: 5px; }
.mapas-study-actions button {
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid #dbe0eb;
  border-radius: 8px;
  background: white;
  color: #495365;
  font-size: 11px;
  font-weight: 650;
}
.mapas-study-actions button:hover { border-color: #91a2fa; color: #405bd8; background: #f7f8ff; }

.mapas-study-main {
  position: relative;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.mapas-study-paper {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  padding: 26px clamp(18px, 4vw, 46px) 80px;
  background: #eef1f6;
}

.mapas-study-editor {
  width: min(100%, 820px);
  min-height: calc(100vh - 270px);
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px) clamp(32px, 8vw, 84px);
  background: white;
  border: 1px solid #e1e5ed;
  border-radius: 3px;
  box-shadow: 0 8px 30px rgba(40, 48, 70, .08);
}

.mapas-study-prosemirror {
  min-height: calc(100vh - 410px);
  outline: none;
  color: #202432;
  font: 16px/1.65 Georgia, "Times New Roman", serif;
  word-break: break-word;
}

.mapas-study-prosemirror > :first-child { margin-top: 0; }
.mapas-study-prosemirror h1,
.mapas-study-prosemirror h2,
.mapas-study-prosemirror h3 { color: #1f2738; font-family: system-ui, sans-serif; line-height: 1.25; }
.mapas-study-prosemirror h1 { margin: 0 0 1.1em; font-size: 2em; }
.mapas-study-prosemirror h2 { margin: 1.7em 0 .6em; font-size: 1.45em; }
.mapas-study-prosemirror h3 { margin: 1.4em 0 .45em; font-size: 1.16em; }
.mapas-study-prosemirror p { margin: .65em 0; }
.mapas-study-prosemirror a { color: #405bd8; text-decoration: underline; text-underline-offset: 2px; }
.mapas-study-prosemirror a[href^="#nodo/"]::before { content: "◉ "; font-family: system-ui, sans-serif; font-size: .78em; }
.mapas-study-prosemirror img { display: block; max-width: 100%; height: auto; margin: 20px auto; border-radius: 10px; }
.mapas-study-prosemirror blockquote { margin: 1em 0; padding: 5px 0 5px 18px; border-left: 3px solid #91a2fa; color: #5c6576; }
.mapas-study-prosemirror pre { overflow: auto; padding: 14px; border-radius: 8px; background: #202432; color: #f4f6fb; }
.mapas-study-prosemirror table { width: 100%; margin: 18px 0; border-collapse: collapse; table-layout: fixed; }
.mapas-study-prosemirror th,
.mapas-study-prosemirror td { min-width: 70px; padding: 8px 10px; border: 1px solid #ccd3df; vertical-align: top; }
.mapas-study-prosemirror th { background: #f1f3f8; font-family: system-ui, sans-serif; text-align: left; }
.mapas-study-prosemirror ul[data-type="taskList"] { padding-left: 0; list-style: none; }
.mapas-study-prosemirror ul[data-type="taskList"] li { display: flex; gap: 8px; }
.mapas-study-prosemirror ul[data-type="taskList"] li > div { flex: 1; }
.mapas-study-prosemirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); float: left; height: 0; color: #9ca5b5; pointer-events: none; }

.mapas-study-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 36px;
  padding: 0 17px;
  border-top: 1px solid var(--mapas-study-border);
  background: white;
  color: #7c8494;
  font-size: 11px;
}

.mapas-study-comments {
  flex: 0 0 0;
  width: 0;
  overflow: hidden;
  background: white;
  border-left: 0 solid var(--mapas-study-border);
  transition: flex-basis .2s ease, width .2s ease;
}
.mapas-study-panel.comments-open .mapas-study-comments { flex-basis: min(330px, 44%); width: min(330px, 44%); overflow-y: auto; border-left-width: 1px; }
.mapas-study-comments > header { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; min-height: 55px; padding: 0 14px; background: white; border-bottom: 1px solid var(--mapas-study-border); }
.mapas-study-comments > header button { width: 32px; height: 32px; border-radius: 8px; background: transparent; font-size: 22px; }
.mapas-study-add-comment { margin: 12px; padding: 9px 11px; border-radius: 8px; background: #edf0ff; color: #405bd8; font-size: 12px !important; font-weight: 650 !important; }
.mapas-study-comments-list { padding: 0 12px 28px; }
.mapas-study-comment { margin: 10px 0; padding: 12px; border: 1px solid #e0e4ed; border-radius: 11px; background: #fafbfe; font-size: 12px; }
.mapas-study-comment header { display: flex; justify-content: space-between; gap: 8px; }
.mapas-study-comment time { color: #8b94a4; font-size: 10px; }
.mapas-study-comment blockquote { margin: 9px 0; padding: 7px 9px; border-left: 2px solid #8fa1fa; background: white; color: #667084; }
.mapas-study-comment p { white-space: pre-wrap; }
.mapas-study-comment button { padding: 6px 8px; border-radius: 6px; background: white; color: #405bd8; }
.mapas-study-comment.is-resolved { opacity: .62; }
.mapas-study-comments-empty { padding: 20px 8px; color: #818a9a; text-align: center; font-size: 12px; }

.mapas-study-linked-focus { animation: mapasStudyFocus 1.8s ease !important; }
@keyframes mapasStudyFocus { 0%, 100% { filter: none; } 25%, 70% { filter: drop-shadow(0 0 10px #ff9e2f); } }

body.mapas-study-split > #root {
  width: calc(100vw - var(--mapas-study-width)) !important;
  max-width: calc(100vw - var(--mapas-study-width)) !important;
  transition: width .24s ease, max-width .24s ease;
}

body.mapas-study-document-only > #root { visibility: hidden; pointer-events: none; }
body.mapas-study-document-only .mapas-study-panel { width: 100vw; max-width: none; }
body.mapas-study-document-only .mapas-study-resizer { display: none; }
body.mapas-study-document-only .mapas-study-launcher,
body.mapas-study-split .mapas-study-launcher { display: none; }

@media (max-width: 960px) {
  .mapas-study-panel,
  body.mapas-study-split .mapas-study-panel { width: 100vw; max-width: none; }
  body.mapas-study-split > #root { visibility: hidden; width: 100vw !important; max-width: none !important; pointer-events: none; }
  .mapas-study-resizer { display: none; }
  .mapas-study-header { grid-template-columns: minmax(130px, 1fr) auto auto; }
  .mapas-study-modes button { min-width: 40px; }
  .mapas-study-modes button span { display: none; }
  .mapas-study-docbar { grid-template-columns: minmax(120px, 1fr) auto auto auto; }
  .mapas-study-status { grid-column: 1 / -1; justify-self: start; }
  .mapas-study-paper { padding: 12px 10px 60px; }
  .mapas-study-editor { padding: 34px 24px; border-radius: 0; }
}

@media print {
  body > #root,
  .mapas-study-header,
  .mapas-study-docbar,
  .mapas-study-toolbar,
  .mapas-study-actions,
  .mapas-study-comments,
  .mapas-study-footer,
  .mapas-study-launcher { display: none !important; }
  .mapas-study-panel,
  .mapas-study-panel.is-open { position: static !important; display: block !important; width: auto !important; max-width: none !important; transform: none !important; visibility: visible !important; border: 0 !important; box-shadow: none !important; }
  .mapas-study-main,
  .mapas-study-paper { display: block !important; overflow: visible !important; padding: 0 !important; background: white !important; }
  .mapas-study-editor { width: auto !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; }
}
