* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f8fa;
  color: #111827;
}

a {
  color: #0f3f8f;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.top {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 14px 28px;
  background: #ffffff;
  border-bottom: 1px solid #dfe3e8;
}

.brand {
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -.02em;
  color: #111827;
}

.top-search {
  flex: 1;
  display: flex;
  gap: 8px;
}

.top-search input,
.filter-panel input,
.filter-panel select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #cfd6df;
  border-radius: 0;
  background: #ffffff;
  color: #111827;
}

button {
  padding: 10px 14px;
  border: 1px solid #111827;
  border-radius: 0;
  background: #111827;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #000000;
}

.site-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 0;
  max-width: 1720px;
  margin: 0 auto;
  min-height: calc(100vh - 62px);
  border-left: 1px solid #e3e7ec;
  border-right: 1px solid #e3e7ec;
  background: #ffffff;
}

.left-panel,
.right-panel {
  position: sticky;
  top: 62px;
  align-self: start;
  height: calc(100vh - 62px);
  overflow: auto;
  background: #fbfcfd;
}

.left-panel {
  border-right: 1px solid #e3e7ec;
}

.right-panel {
  border-left: 1px solid #e3e7ec;
}

.main-panel {
  min-width: 0;
  padding: 26px 30px;
  background: #ffffff;
}

.filter-panel,
.ad-panel,
.hero,
.result-row,
.section-head,
.side-panel {
  border-radius: 0;
  box-shadow: none;
}

.filter-panel {
  padding: 18px;
}

.panel-title {
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #374151;
}

.filter-panel label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}

.filter-panel input,
.filter-panel select {
  margin-top: 6px;
  font-weight: 400;
}

.clear-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 14px;
  color: #6b7280;
}

.ad-panel {
  padding: 18px;
}

.ad-label {
  margin-bottom: 10px;
  color: #6b7280;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.adsense-placeholder {
  height: 600px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #9ca3af;
  background: #f7f8fa;
  border: 1px solid #e0e5eb;
  line-height: 1.5;
}

.hero {
  padding: 34px 0 26px;
  border-bottom: 1px solid #e3e7ec;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 38px;
  letter-spacing: -.035em;
}

.hero p {
  margin: 0;
  color: #6b7280;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 220px));
  margin-top: 26px;
  border: 1px solid #e3e7ec;
  width: fit-content;
}

.stats div {
  padding: 16px 18px;
  border-right: 1px solid #e3e7ec;
  background: #fbfcfd;
}

.stats div:last-child {
  border-right: 0;
}

.stats b {
  display: block;
  font-size: 27px;
}

.stats span {
  color: #6b7280;
  font-size: 13px;
}

.section-block {
  margin-top: 26px;
}

.section-block h2,
.section-head h1 {
  margin: 0 0 16px;
  letter-spacing: -.02em;
}

.section-head {
  padding-bottom: 16px;
  border-bottom: 1px solid #e3e7ec;
  margin-bottom: 0;
}

.results {
  display: grid;
}

.result-row {
  padding: 18px 0;
  border-bottom: 1px solid #e3e7ec;
}

.result-row h2,
.result-row h3 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.25;
}

.meta,
.muted,
.small {
  color: #6b7280;
}

.small {
  font-size: 14px;
}

.text-link {
  display: inline-block;
  margin-top: 8px;
  font-weight: 700;
}

.pager {
  display: flex;
  gap: 20px;
  padding-top: 20px;
}

.paper-page {
  background: #f7f8fa;
}

.integrated-top {
  height: 62px;
}

.paper-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  gap: 0;
  max-width: 1840px;
  margin: 0 auto;
  border-left: 1px solid #e3e7ec;
  border-right: 1px solid #e3e7ec;
  background: #ffffff;
}

.paper-side,
.paper-ad {
  position: sticky;
  top: 92px; /* 62px header + apie 30px language bar */
  align-self: start;
  height: calc(100vh - 92px);
  overflow: auto;
  background: #fbfcfd;
}

.paper-side {
  border-right: 1px solid #e3e7ec;
}

.paper-ad {
  border-left: 1px solid #e3e7ec;
}

.side-panel {
  padding: 18px;
  border-bottom: 1px solid #e3e7ec;
}

.side-title {
  font-weight: 750;
  line-height: 1.35;
  margin-bottom: 14px;
}

.side-meta {
  display: grid;
  gap: 11px;
  font-size: 14px;
  color: #374151;
}

.side-meta b {
  color: #111827;
}

.filter-check {
  display: block;
  margin: 10px 0;
  font-size: 14px;
  color: #374151;
}

.side-note {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

.paper-main {
  min-width: 0;
  background: #ffffff;
  padding: 22px;
}

.doc-shell {
  background: #ffffff;
  overflow: visible;
}

.doc-shell #page-container,
.doc-shell .pf,
.doc-shell .pc {
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (max-width: 1320px) {
  .site-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .right-panel {
    display: none;
  }
}

@media (max-width: 1320px) and (min-width: 1051px) {
  .paper-layout {
    grid-template-columns: 260px minmax(0, 1fr) 260px;
  }

  .paper-ad {
    display: block;
  }
}

@media (max-width: 900px) {
  .site-layout,
  .paper-layout {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .paper-side {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid #e3e7ec;
  }

  .top {
    flex-direction: column;
    align-items: stretch;
    position: static;
  }

  .main-panel,
  .paper-main {
    padding: 18px;
  }
}

.language-list {
  display: grid;
  border-top: 1px solid #e3e7ec;
}

.language-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e3e7ec;
  color: #111827;
}

.language-row:hover {
  text-decoration: none;
  background: #f7f8fa;
}

.language-row.active {
  font-weight: 800;
}

.language-row em {
  font-style: normal;
  font-size: 12px;
  color: #6b7280;
}

.translation-shell {
  max-width: 940px;
  margin: 0 auto;
  padding: 46px 54px;
  background: #ffffff;
  border-left: 1px solid #e3e7ec;
  border-right: 1px solid #e3e7ec;
  min-height: calc(100vh - 110px);
}

.translation-document {
  font-size: 18px;
  line-height: 1.75;
  color: #111827;
}

.translation-document h2 {
  margin: 34px 0 14px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.translation-document p {
  margin: 0 0 18px;
}

.translation-page-marker {
  margin: 34px 0 18px;
  padding-top: 12px;
  border-top: 1px solid #e3e7ec;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6b7280;
}

.translation-empty {
  max-width: 720px;
  margin: 90px auto;
  padding: 32px 0;
  border-top: 1px solid #e3e7ec;
  border-bottom: 1px solid #e3e7ec;
}

.translation-empty h2 {
  margin: 0 0 10px;
  font-size: 28px;
  letter-spacing: -.02em;
}

.translation-empty p {
  margin: 0;
  color: #6b7280;
}

.filter-panel summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #374151;
  padding: 18px;
  border-bottom: 1px solid #e3e7ec;
}

.filter-panel summary::-webkit-details-marker {
  display: none;
}

.filter-panel form {
  padding: 18px;
}

.marked-panel {
  border-top: 1px solid #e3e7ec;
  padding: 18px;
}

.marked-list {
  display: grid;
}

.marked-empty {
  color: #6b7280;
  font-size: 13px;
}

.marked-item {
  display: grid;
  grid-template-columns: 1fr 24px;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid #e3e7ec;
  font-size: 13px;
}

.marked-item button {
  padding: 0;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #6b7280;
}

.mark-button {
  width: 100%;
  margin-bottom: 16px;
  background: #ffffff;
  color: #111827;
  border: 1px solid #111827;
}

.language-topbar {
  position: sticky;
  top: 62px;
  z-index: 40;
  background: #fbfcfd;
  border-bottom: 1px solid #e3e7ec;
}

.language-topbar-inner {
  max-width: 1840px;
  margin: 0 auto;
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-left: 1px solid #e3e7ec;
  border-right: 1px solid #e3e7ec;
}

.lang-pill {
  border: 0;
  border-right: 1px solid #e3e7ec;
  background: #ffffff;
  color: #111827;
  padding: 10px 14px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.lang-pill:hover {
  text-decoration: none;
  background: #f1f4f8;
}

.lang-pill.active {
  background: #111827;
  color: #ffffff;
}

.lang-pill.unavailable {
  color: #9ca3af;
  background: #f7f8fa;
}

.lang-pill.queued {
  color: #374151;
  background: #eef2f7;
}

.full-height-side {
  display: flex;
  flex-direction: column;
}

.paper-marked-panel {
  flex: 1;
  min-height: 240px;
  overflow: auto;
}

.toast {
  position: fixed;
  top: 118px;
  right: 28px;
  z-index: 2147483647;
  max-width: 420px;
  padding: 14px 18px;
  background: #111827;
  color: #ffffff;
  border: 1px solid #111827;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
  font-size: 14px;
}


/* Final language selector + paper layout fixes */
.language-topbar {
  position: sticky;
  top: 62px;
  z-index: 40;
  background: #fbfcfd;
  border-bottom: 1px solid #e3e7ec;
  text-align: center;
}

.language-topbar-inner {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  overflow: visible;
  border-left: 1px solid #e3e7ec;
}

.lang-pill {
  flex: 0 0 auto;
  width: auto;
  min-width: 44px;
  max-width: none;
  border: 0;
  border-right: 1px solid #e3e7ec;
  background: #ffffff;
  color: #111827;
  padding: 5px 7px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
  text-transform: lowercase;
  cursor: pointer;
}

.lang-pill:hover {
  text-decoration: none;
  background: #f1f4f8;
}

.lang-pill.active {
  background: #111827;
  color: #ffffff;
  font-weight: 800;
}

.lang-pill.unavailable {
  color: #9ca3af;
  background: #f7f8fa;
}

.lang-pill.queued {
  color: #374151;
  background: #eef2f7;
}

.lang-origin {
  font-size: 10px;
  opacity: .75;
  text-transform: none;
}

/* Keep three columns while there is enough screen width */
@media (max-width: 1320px) and (min-width: 1051px) {
  .paper-layout {
    grid-template-columns: 260px minmax(0, 1fr) 260px;
  }

  .paper-ad {
    display: block;
  }

  .paper-main {
    min-width: 0;
    padding: 16px;
  }
}

/* Prevent the translated PDF/HTML from pushing the right column outside the grid */
.paper-main {
  min-width: 0;
  overflow-x: auto;
}

.doc-shell,
.translated-doc,
.translation-shell {
  max-width: 100%;
}



.paper-layout {
  width: 100%;
}

.paper-main {
  min-width: 0;
  overflow-x: auto;
}

.paper-layout {
  display: grid;
  grid-template-columns: clamp(240px, 18vw, 320px) minmax(0, 1fr) clamp(240px, 18vw, 320px);
  width: 100%;
  max-width: 1840px;
  margin: 0 auto;
  align-items: start;
}

.paper-side,
.paper-ad {
  position: sticky;
  top: 92px;
  height: calc(100vh - 92px);
  overflow: auto;
  align-self: start;
}

.paper-main {
  min-width: 0;
  overflow-x: auto;
}

.doc-shell,
.translated-doc,
.translation-shell {
  max-width: 100%;
}

@media (max-width: 900px) {
  .paper-layout {
    grid-template-columns: 1fr;
  }

  .paper-side,
  .paper-ad {
    position: static;
    height: auto;
  }

  .paper-ad {
    display: none;
  }
}

/* SCIPAPERS EMBEDDED PDF LAYOUT FIX */
body.paper-page .paper-layout {
  display: grid !important;
  grid-template-columns: 280px minmax(0, 1fr) 300px !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  align-items: start !important;
  background: #ffffff !important;
}

body.paper-page .paper-side {
  grid-column: 1 !important;
  display: block !important;
  position: sticky !important;
  top: 92px !important;
  height: calc(100vh - 92px) !important;
  overflow: auto !important;
  z-index: 20 !important;
  background: #fbfcfd !important;
  border-right: 1px solid #e3e7ec !important;
  border-bottom: 0 !important;
}

body.paper-page .paper-main {
  grid-column: 2 !important;
  min-width: 0 !important;
  padding: 18px !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  position: relative !important;
  z-index: 1 !important;
  background: #ffffff !important;
}

body.paper-page .paper-ad {
  grid-column: 3 !important;
  display: block !important;
  position: sticky !important;
  top: 92px !important;
  height: calc(100vh - 92px) !important;
  overflow: auto !important;
  z-index: 10 !important;
  background: #fbfcfd !important;
  border-left: 1px solid #e3e7ec !important;
}

body.paper-page .full-height-side {
  display: block !important;
}

body.paper-page .paper-marked-panel {
  flex: none !important;
  min-height: 0 !important;
  overflow: visible !important;
}

/* Svarbiausia dalis: įdėto PDF/HTML #page-container turi būti normalus blokas, ne fullscreen absolute viewport. */
body.paper-page .doc-shell {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  overflow: visible !important;
  background: #ffffff !important;
}

body.paper-page .doc-shell #page-container {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  width: max-content !important;
  min-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  margin: 0 auto !important;
  padding: 0 !important;
}

body.paper-page .doc-shell #sidebar,
body.paper-page .doc-shell .loading-indicator {
  display: none !important;
}

body.paper-page .doc-shell .pf,
body.paper-page .doc-shell .pc {
  max-width: none !important;
}

body.paper-page .doc-shell .pf {
  display: block !important;
  position: relative !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (max-width: 1180px) {
  body.paper-page .paper-layout {
    grid-template-columns: 260px minmax(0, 1fr) !important;
  }

  body.paper-page .paper-ad {
    display: none !important;
  }
}

@media (max-width: 760px) {
  body.paper-page .paper-layout {
    grid-template-columns: 1fr !important;
  }

  body.paper-page .paper-side,
  body.paper-page .paper-ad {
    position: static !important;
    height: auto !important;
  }
}
/* END SCIPAPERS EMBEDDED PDF LAYOUT FIX */

/* SCIPAPERS BOOKMARKS */
.bookmark-button {
  width: 100%;
  margin: -8px 0 16px;
  background: #111827;
  color: #ffffff;
  border: 1px solid #111827;
}

.bookmark-button.bookmark-mode-active {
  outline: 2px solid #0f3f8f;
  outline-offset: 2px;
}

.marked-subtitle {
  margin: 12px 0 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #6b7280;
}

.marked-item small {
  display: inline-block;
  margin-left: 4px;
  color: #6b7280;
  font-size: 11px;
}

.doc-shell,
.translation-shell {
  position: relative;
}

.doc-bookmarks-layer {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  min-height: 100%;
  pointer-events: none;
  z-index: 100000;
}

.doc-bookmark-marker {
  position: absolute;
  width: 28px;
  height: 28px;
  padding: 0;
  transform: translate(-50%, -100%);
  border: 0;
  background: transparent;
  color: #111827;
  font-size: 22px;
  line-height: 28px;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
}

.doc-bookmark-marker:hover,
.doc-bookmark-marker.active {
  transform: translate(-50%, -100%) scale(1.25);
}

body.bookmark-placement-mode .paper-main {
  cursor: crosshair;
}
/* END SCIPAPERS BOOKMARKS */

/* SCIPAPERS BOOKMARK RED MOVE FIX */
.doc-bookmark-marker,
.doc-bookmark-marker:hover,
.doc-bookmark-marker:focus,
.doc-bookmark-marker:active {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: #dc2626 !important;
  outline: none !important;
}

.doc-bookmark-marker {
  cursor: grab !important;
}

.doc-bookmark-marker:active {
  cursor: grabbing !important;
}

.doc-bookmark-marker:hover,
.doc-bookmark-marker.active {
  background: transparent !important;
  transform: translate(-50%, -100%) scale(1.25);
  filter: drop-shadow(0 2px 3px rgba(220,38,38,.35));
}
/* END SCIPAPERS BOOKMARK RED MOVE FIX */

/* SCIPAPERS BOOKMARK POINTER MOVE FIX */
.doc-bookmark-marker {
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
  cursor: grab !important;
}

.doc-bookmark-marker.dragging {
  cursor: grabbing !important;
  transform: translate(-50%, -100%) scale(1.25) !important;
  filter: drop-shadow(0 3px 5px rgba(220,38,38,.45)) !important;
}
/* END SCIPAPERS BOOKMARK POINTER MOVE FIX */

