/* TENIMPER v35 — integrated "Save chapter" control */

/*
 * Main placement: reader-account.js inserts this button into .bookmark-tools,
 * alongside the site's existing "Закладка" controls.
 */
.bookmark-tools .reader-bookmark--chapter-save{
  position:static!important;
  inset:auto!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:flex-start!important;
  gap:8px!important;
  min-height:42px!important;
  max-width:min(230px,calc(100vw - 28px))!important;
  margin:0!important;
  padding:0 12px 0 9px!important;
  border:1px solid rgba(196,160,103,.45)!important;
  border-radius:23px!important;
  background:rgba(23,20,16,.96)!important;
  box-shadow:0 9px 28px rgba(0,0,0,.32)!important;
  color:#e4cfaa!important;
  font-family:Lora,Georgia,serif!important;
  cursor:pointer!important;
  -webkit-tap-highlight-color:transparent!important;
  backdrop-filter:blur(10px)!important;
  transition:
    border-color .18s ease,
    color .18s ease,
    background .18s ease,
    transform .18s ease,
    opacity .18s ease!important;
}

.bookmark-tools .reader-bookmark--chapter-save:hover,
.bookmark-tools .reader-bookmark--chapter-save:focus-visible{
  border-color:var(--gold,#c4a067)!important;
  color:var(--gold,#d7b277)!important;
  outline:none!important;
  transform:translateY(-1px)!important;
}

.bookmark-tools .reader-bookmark--chapter-save b{
  display:block!important;
  overflow:hidden!important;
  max-width:165px!important;
  font:700 10px/1 Lora,Georgia,serif!important;
  letter-spacing:.075em!important;
  text-transform:uppercase!important;
  text-overflow:ellipsis!important;
  white-space:nowrap!important;
}

.reader-bookmark__mark{
  display:grid!important;
  place-items:center!important;
  flex:0 0 auto!important;
  width:25px!important;
  height:25px!important;
  border:1px solid rgba(196,160,103,.38)!important;
  color:#b9574d!important;
  font:600 13px/1 Georgia,serif!important;
  transition:.18s ease!important;
}

.bookmark-tools .reader-bookmark--chapter-save[aria-pressed="true"]{
  border-color:rgba(185,87,77,.82)!important;
  background:linear-gradient(135deg,rgba(67,29,25,.98),rgba(45,22,19,.98))!important;
  color:#fff0da!important;
}

.bookmark-tools .reader-bookmark--chapter-save[aria-pressed="true"] .reader-bookmark__mark{
  border-color:rgba(225,174,118,.55)!important;
  background:rgba(185,87,77,.2)!important;
  color:#ffd9bc!important;
}

.bookmark-tools .reader-bookmark--chapter-save.is-busy{
  opacity:.62!important;
  cursor:wait!important;
}

.bookmark-tools .reader-bookmark--chapter-save:disabled{
  pointer-events:none!important;
}

/* Light site theme */
html[data-theme="light"] .bookmark-tools .reader-bookmark--chapter-save{
  border-color:rgba(133,91,44,.32)!important;
  background:rgba(255,249,239,.97)!important;
  box-shadow:0 10px 24px rgba(91,58,33,.16)!important;
  color:#654529!important;
}

html[data-theme="light"] .bookmark-tools .reader-bookmark--chapter-save[aria-pressed="true"]{
  border-color:rgba(148,75,59,.52)!important;
  background:linear-gradient(135deg,#f7e2cf,#f1d5bf)!important;
  color:#6f3028!important;
}

/* Small thematic confirmation instead of changing page layout. */
.reader-save-toast{
  position:fixed!important;
  z-index:95!important;
  left:50%!important;
  bottom:34px!important;
  translate:-50% 0!important;
  width:max-content!important;
  max-width:calc(100vw - 30px)!important;
  padding:9px 13px!important;
  border:1px solid rgba(215,178,119,.55)!important;
  border-radius:18px!important;
  background:rgba(11,10,8,.97)!important;
  box-shadow:0 10px 28px rgba(0,0,0,.34)!important;
  color:#fff4df!important;
  font:600 11px/1.35 Lora,Georgia,serif!important;
  letter-spacing:.035em!important;
  text-align:center!important;
  pointer-events:none!important;
  animation:reader-save-toast-in .24s ease both!important;
}

.reader-save-toast[hidden]{
  display:none!important;
}

@keyframes reader-save-toast-in{
  from{opacity:0;transform:translateY(7px)}
  to{opacity:1;transform:translateY(0)}
}

/*
 * Fallback only: if a minimal reader page has no .bookmark-tools,
 * keep the save control above the Aa button instead of covering it.
 */
.reader-bookmark--chapter-save.reader-bookmark--fallback{
  position:fixed!important;
  right:18px!important;
  bottom:76px!important;
  z-index:34!important;
  display:inline-flex!important;
  align-items:center!important;
  gap:8px!important;
  min-height:42px!important;
  padding:0 12px 0 9px!important;
  border:1px solid rgba(196,160,103,.45)!important;
  border-radius:23px!important;
  background:rgba(23,20,16,.96)!important;
  box-shadow:0 9px 28px rgba(0,0,0,.32)!important;
  color:#e4cfaa!important;
  cursor:pointer!important;
}

.reader-bookmark--chapter-save.reader-bookmark--fallback b{
  font:700 10px/1 Lora,Georgia,serif!important;
  letter-spacing:.075em!important;
  text-transform:uppercase!important;
}

/* Mobile: same component, slightly tighter. No generic browser-looking pill. */
@media(max-width:600px){
  .bookmark-tools .reader-bookmark--chapter-save{
    min-height:40px!important;
    max-width:205px!important;
    padding-right:10px!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save b{
    max-width:145px!important;
    font-size:9px!important;
  }

  .reader-bookmark__mark{
    width:24px!important;
    height:24px!important;
  }

  .reader-bookmark--chapter-save.reader-bookmark--fallback{
    right:10px!important;
    bottom:66px!important;
  }

  .reader-save-toast{
    bottom:max(22px,calc(env(safe-area-inset-bottom) + 14px))!important;
  }
}


/* =========================================================
   TENIMPER v36 — mobile save control visibility
   ========================================================= */
@media (max-width:900px), (pointer:coarse){
  .reader-surface:not(.is-reader-panel-open) .bookmark-tools{
    opacity:1!important;
    visibility:visible!important;
    pointer-events:auto!important;
    z-index:92!important;
    overflow:visible!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save{
    display:inline-flex!important;
    visibility:visible!important;
    opacity:1!important;
    pointer-events:auto!important;
    touch-action:manipulation!important;
    min-height:40px!important;
    max-width:190px!important;
    padding:0 10px 0 8px!important;
    z-index:3!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save b{
    display:block!important;
    max-width:132px!important;
    font-size:9px!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save.is-guest{
    border-style:dashed!important;
    opacity:.92!important;
  }
}

@media (max-width:430px){
  .bookmark-tools{
    right:10px!important;
    bottom:66px!important;
    gap:6px!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save{
    max-width:166px!important;
    min-height:38px!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save b{
    max-width:112px!important;
    font-size:8.5px!important;
    letter-spacing:.055em!important;
  }
}


/* =========================================================
   TENIMPER v37 — compact mobile "Save chapter"
   Mobile only: same footprint as the other reader buttons.
   ========================================================= */
@media (max-width:900px), (pointer:coarse){
  .bookmark-tools .reader-bookmark--chapter-save{
    width:40px!important;
    height:40px!important;
    min-width:40px!important;
    min-height:40px!important;
    max-width:40px!important;
    padding:0!important;
    gap:0!important;
    border-radius:50%!important;
    justify-content:center!important;
    overflow:hidden!important;
    flex:0 0 40px!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save b{
    display:none!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save .reader-bookmark__mark{
    width:24px!important;
    height:24px!important;
    margin:0!important;
    border:0!important;
    background:transparent!important;
    font-size:13px!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save[aria-pressed="true"] .reader-bookmark__mark{
    background:transparent!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save.is-guest{
    border-style:solid!important;
  }

  /* Fallback also stays compact instead of covering chapter text. */
  .reader-bookmark--chapter-save.reader-bookmark--fallback{
    width:40px!important;
    height:40px!important;
    min-width:40px!important;
    min-height:40px!important;
    max-width:40px!important;
    padding:0!important;
    gap:0!important;
    border-radius:50%!important;
    justify-content:center!important;
    overflow:hidden!important;
  }

  .reader-bookmark--chapter-save.reader-bookmark--fallback b{
    display:none!important;
  }
}

@media (max-width:430px){
  .bookmark-tools .reader-bookmark--chapter-save,
  .reader-bookmark--chapter-save.reader-bookmark--fallback{
    width:38px!important;
    height:38px!important;
    min-width:38px!important;
    min-height:38px!important;
    max-width:38px!important;
    flex-basis:38px!important;
  }

  .bookmark-tools .reader-bookmark--chapter-save .reader-bookmark__mark{
    width:22px!important;
    height:22px!important;
    font-size:12px!important;
  }
}
