/* =====================================================================
   OLVASÓ – megosztás, visszajelzés
   A meglévő témaváltozókból dolgozik (common.css), így mindhárom témában
   és mobilon is illeszkedik. A reader.css után töltődik be.
   ===================================================================== */

/* ===== Kijelölési menü: helyi menü (1.31.0) =====
   Világos felület, egymás alatti, ikonos elemek – mint a @ utáni névajánló. */
.selection-menu {
  min-width: 200px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .12);
  color-scheme: normal;
}

.selection-menu:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: selection-menu-in .12s ease-out;
}

@keyframes selection-menu-in { from { opacity: 0; transform: translateY(-3px); } }

.selection-menu .selection-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 14px 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.selection-menu .selection-menu-item[hidden] { display: none; }

.selection-menu .selection-menu-item:hover,
.selection-menu .selection-menu-item:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: none;
  outline: none;
}

.selection-menu .selection-menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.selection-menu-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}

/* Két elem között vékony elválasztó, hogy a két művelet ne folyjon össze. */
.selection-menu .selection-menu-item:not([hidden]) ~ .selection-menu-item:not([hidden]) {
  position: relative;
  margin-top: 3px;
}

.selection-menu .selection-menu-item:not([hidden]) ~ .selection-menu-item:not([hidden])::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: -3px;
  height: 1px;
  background: var(--border);
}

@media (pointer: coarse) {
  .selection-menu { min-width: 220px; }
  .selection-menu .selection-menu-item { min-height: 46px; font-size: 15.5px; padding: 10px 16px 10px 12px; }
}

/* ===== Megosztott idézet kiemelése ===== */
.shared-quote-highlight {
  mix-blend-mode: var(--note-blend);
  filter: var(--note-filter);
}

.shared-quote-highlight > rect {
  fill: var(--accent);
  fill-opacity: .28;
  stroke: none;
  animation: shared-pulse 1.6s ease-out 1;
}

@keyframes shared-pulse {
  0% { fill-opacity: .55; }
  100% { fill-opacity: .28; }
}

.reader-share-nav { border-left: 4px solid var(--toast-accent); }
.reader-share-nav .btn[hidden] { display: none; }

/* ===== Közös: alsó lap mobilon ===== */
.share-dialog, .feedback-dialog {
  width: min(560px, calc(100vw - 28px));
}

@media (max-width: 560px) {
  .share-dialog, .feedback-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 94vh;
    max-height: 94dvh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    animation: sheet-in .24s ease-out;
  }

  .share-dialog .note-editor-actions,
  .feedback-dialog .note-editor-actions {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

@keyframes sheet-in { from { transform: translateY(24px); opacity: .4; } }

@media (prefers-reduced-motion: reduce) {
  .share-dialog, .feedback-dialog, .shared-quote-highlight > rect { animation: none; }
}

/* ===== Megosztás ===== */
.share-preview {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  width: min(100%, 340px);
  aspect-ratio: 4 / 5;
  max-height: 46vh;
  max-height: 46dvh;
  border-radius: 14px;
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
}

.share-preview-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.share-preview-img:not([src]) { visibility: hidden; }

.share-preview-spinner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
  opacity: 0;
  transition: opacity .2s;
}

.share-preview[aria-busy="true"] .share-preview-spinner { opacity: 1; }

.share-styles {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.share-style {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 14px 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.share-style[aria-checked="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  font-weight: 600;
}

.share-style-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chip-a), var(--chip-b));
  box-shadow: inset 0 0 0 2px var(--chip-ink), 0 0 0 1px var(--border);
}

.share-link {
  display: flex;
  gap: 8px;
}

.share-link-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.share-link-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.share-link .btn { min-height: 42px; }

.share-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.share-actions .btn[hidden] { display: none; }

.share-facebook[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
}

@media (max-width: 560px) {
  .share-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .share-actions .btn {
    justify-content: center;
    min-height: 46px;
  }

  .share-actions .btn-primary { grid-column: 1 / -1; }
}

@media (max-width: 400px) {
  .share-style { padding: 5px 12px 5px 6px; font-size: 13px; gap: 6px; }
}

@media (max-height: 640px) and (max-width: 560px) {
  .share-preview { width: min(100%, 220px); }
}

/* ===== Visszajelzés ===== */
.feedback-intro {
  margin: 0 0 18px;
  line-height: 1.55;
  color: var(--muted);
}

.feedback-reactions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.feedback-reaction {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 74px;
  padding: 8px 2px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  line-height: 1.2;
  text-align: center;
  hyphens: manual;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}

.feedback-reaction:hover { border-color: var(--border-strong); }

.feedback-reaction:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.feedback-reaction[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
  transform: translateY(-2px);
}

.feedback-emoji {
  font-size: 28px;
  line-height: 1;
}

.feedback-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.feedback-form input[type="text"],
.feedback-form input[type="email"] {
  width: 100%;
  height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.feedback-form input[type="text"]:focus,
.feedback-form input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.feedback-form textarea { min-height: 104px; }

.feedback-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.feedback-privacy {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.feedback-thanks {
  text-align: center;
  padding-top: 32px;
  padding-bottom: 32px;
}

.feedback-thanks-mark {
  font-size: 34px;
  color: var(--accent);
}

.feedback-thanks-title {
  margin: 8px 0 6px;
  font-size: 22px;
  font-weight: 600;
}

.feedback-thanks p { margin: 0 0 6px; color: var(--muted); }
.feedback-signature { margin-top: 14px !important; font-style: italic; color: var(--text) !important; }

.feedback-dialog .note-editor-actions .btn[hidden] { display: none; }

@media (max-width: 560px) {
  .feedback-pair { grid-template-columns: 1fr; gap: 0; }
  .feedback-reactions { gap: 4px; }
  .feedback-reaction { min-height: 70px; font-size: 10.5px; border-radius: 12px; }
  .feedback-emoji { font-size: 26px; }
}

/* A könyvadatok ablakában a visszajelzés gombja */
.info-actions .btn .icon { flex-shrink: 0; }

/* ===== Lektori jelzés / szerzői kommentár, Elvégezve (1.26.0) ===== */
.note-kind {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.note-kind legend { padding: 0; margin-bottom: 8px; }

.note-kind-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}

.note-kind-option + .note-kind-option { margin-top: 8px; }

.note-kind-option input {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.note-kind-option span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.note-kind-option b { font-size: 15px; }
.note-kind-option small { font-size: 13px; line-height: 1.4; color: var(--muted); }

.note-kind-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.note-kind-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.note-kind-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--danger);
}

#note-save:disabled { cursor: not-allowed; }

@media (pointer: coarse) {
  .note-kind-option { padding: 14px; }
}

.note-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.note-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.note-badge-editor { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.note-badge-author { background: color-mix(in srgb, #C49732 16%, var(--surface)); color: color-mix(in srgb, #8a6420 80%, var(--text)); border-color: color-mix(in srgb, #C49732 45%, var(--border)); }
.note-badge-done { background: var(--surface-3); color: var(--text); }

.saved-note.is-done .note-quote { border-left-color: #9A9DA3; }
.saved-note.is-done .saved-note-text { color: var(--muted); }

.note-admin-actions .note-done { order: -1; }
.note-manager tr.is-done td { color: var(--muted); }

/* ===== Válaszok a megjegyzés alatt (1.27.0) ===== */
.note-thread {
  margin-top: 16px;
}

.note-thread:empty { display: none; }

.note-thread-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.note-replies {
  margin: 0 0 12px;
  padding: 0 0 0 14px;
  list-style: none;
  border-left: 2px solid var(--border-strong);
}

.note-reply + .note-reply {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.note-reply-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-bottom: 4px;
  font-size: 14px;
}

.note-reply-time { font-size: 12px; color: var(--muted); }
.note-reply-text { font-size: 15px; }

.note-reply-tools {
  display: flex;
  gap: 14px;
  margin-top: 4px;
}

.note-reply-link {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.note-reply-link:hover { text-decoration: underline; }
.note-reply-link:disabled { opacity: .5; cursor: wait; }

.note-reply-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-reply-form textarea {
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
}

.note-reply-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.note-reply-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.note-reply-form-actions .btn:disabled { opacity: .55; cursor: not-allowed; }

.note-reply-error {
  margin: 0;
  font-size: 13px;
  color: var(--danger);
}

@media (max-width: 480px) {
  .note-reply-form-actions .btn { flex: 1 1 0; min-height: 44px; }
}

@media (max-width: 480px) {
  .saved-note .note-admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .saved-note .note-admin-actions .note-done,
  .saved-note .note-admin-actions .note-reopen { grid-column: 1 / -1; }
  .saved-note .note-admin-actions .btn { justify-content: center; min-height: 44px; }
}

/* ===== Háttér: értesítés új rétegről (1.28.0) ===== */
.hatter-toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 20px);
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--toast-border);
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .38);
  font-size: 14px;
  animation: bar-in .25s ease-out;
}

.hatter-toast-mark { color: var(--toast-accent); font-size: 18px; }
.hatter-toast .btn-primary { background: var(--toast-accent); border-color: var(--toast-accent); color: var(--toast-accent-contrast); flex-shrink: 0; }
.hatter-toast .icon-btn { color: var(--toast-muted); flex-shrink: 0; }

@media (max-width: 520px) {
  .hatter-toast { flex-wrap: wrap; justify-content: center; text-align: center; width: calc(100vw - 20px); }
}

/* ===== Válaszlista: asztali nézetben saját görgetés (1.28.1) =====
   Mobilon (a többi olvasóelemhez igazodva: ≤ 720 px széles vagy ≤ 500 px magas) marad a teljes ablakos görgetés. */
@media (min-width: 721px) and (min-height: 501px) {
  .note-replies {
    max-height: min(32vh, 320px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }

  .note-replies::-webkit-scrollbar { width: 8px; }
  .note-replies::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
  .note-replies::-webkit-scrollbar-track { background: transparent; }
}

/* ===== @Név megemlítések (1.29.0) ===== */
.note-mention {
  display: inline;
  font-weight: 600;
  white-space: nowrap;
}

.note-mention .note-author-dot { margin-left: .1em; margin-right: .32em; }
.mention-option .note-mention { display: inline-flex; align-items: center; }

.mention-suggest {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
  max-width: calc(100vw - 16px);
  max-height: 232px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .12);
  animation: mention-in .12s ease-out;
}

.mention-suggest[hidden] { display: none; }

@keyframes mention-in { from { opacity: 0; transform: translateY(-3px); } }

.mention-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.mention-option.is-active,
.mention-option:hover {
  background: var(--accent-soft);
}

@media (pointer: coarse) {
  .mention-option { min-height: 42px; padding: 6px 14px; }
}

/* ===== Szerzői kommentár (1.32.0) =====
   Arany kiemelés soronkénti aláhúzással; a szerkesztőben csak a szerző választhat típust. */
.note-kind[hidden] { display: none; }
.note-kind-author:has(input:checked) {
  border-color: #C49732;
  background: color-mix(in srgb, #C49732 10%, var(--surface));
  box-shadow: 0 0 0 1px #C49732;
}
.author-note-highlight.is-author > rect { fill-opacity: 1; }
.author-note-star {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  margin-right: .45em;
  vertical-align: -.16em;
  color: #C49732;
}
#note-viewer-heading.is-author-note,
.note-author.is-author-note { color: var(--text); }
.saved-note.is-author-note .saved-note-text { font-family: "Noto Serif", "Times New Roman", serif; }

/* ===== „Mi történt idáig?” ablak ===== */
.recap-dialog #recap-heading:focus { outline: none; }
.recap-chapter {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text);
}
.recap-chapter strong { font-weight: 700; }
.recap-chapter em { font-style: italic; }
.recap-text {
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--gold);
  font-family: "Noto Serif", "Times New Roman", serif;
  font-size: 15.5px;
  line-height: 1.65;
}
.recap-text p { margin: 0 0 .85em; }
/* Vendégnek: tájékoztatás az összefoglaló helyén (a második sor a felület betűjével, halványabban). */
.recap-locked .recap-locked-hint {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.recap-text p:last-child { margin-bottom: 0; }

.recap-text h2, .recap-text h3, .recap-text h4 { font-size: 1em; margin: 1em 0 .4em; }
.recap-text ul { margin: 0 0 .85em; padding-left: 1.2em; }
.recap-text blockquote { margin: 0 0 .85em; padding-left: .9em; border-left: 2px solid var(--border); font-style: italic; }
.recap-text img { max-width: 100%; height: auto; border-radius: 8px; }
.recap-text figure { margin: 0 0 .85em; }

/* Szerzői ellenőrzés a tartalomjegyzék tetején */
.recap-report {
  margin: 4px 4px 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
}
.recap-report.has-errors { border-color: var(--danger); }
.recap-report summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.recap-report summary::-webkit-details-marker { display: none; }
.recap-report summary .icon { width: 16px; height: 16px; color: var(--gold); flex: 0 0 auto; }
.recap-report h3 { margin: 10px 0 4px; font-size: 12.5px; }
.recap-report ul { margin: 0; padding-left: 1.1em; color: var(--danger); }
.recap-report li { margin: 2px 0; }
.recap-report-file { margin: 8px 0 0; color: var(--muted); overflow-wrap: anywhere; }

/* ===== Félig zárt szerzői kommentár (vendégnek): tájékoztatás a szöveg helyén ===== */
.note-locked p {
  margin: 0 0 8px;
  font-size: 14.5px;
  line-height: 1.5;
}
.note-locked p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}
