/* ClipShelf – knižnica (web aj rozšírenie) */

.shell {
  width: min(880px, calc(100% - 32px));
  margin-inline: auto;
}

html[data-view="settings"] .shell {
  width: min(1040px, calc(100% - 32px));
}

/* ---------- horná lišta ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--bar-line);
  background: var(--bar-bg);
  color: var(--bar-ink);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.topbar .btn {
  border-color: var(--bar-line);
  background: transparent;
  color: var(--bar-ink);
  box-shadow: none;
}

.topbar .btn .icon {
  color: var(--bar-muted);
}

.topbar .btn:hover:not(:disabled) {
  border-color: var(--bar-line);
  background: var(--bar-field-hover);
}

.topbar .btn-primary {
  border-color: var(--brand-accent);
  background: var(--brand-accent);
  background-image: none;
  color: var(--brand-base);
  box-shadow: 0 8px 20px -10px var(--accent-glow);
}

.topbar .btn-primary .icon {
  color: inherit;
}

.topbar .btn-primary:hover:not(:disabled) {
  border-color: var(--brand-accent-hover);
  background: var(--brand-accent-hover);
}

.topbar .icon-btn {
  color: var(--bar-muted);
}

.topbar .icon-btn:hover:not(:disabled) {
  background: var(--bar-field-hover);
  color: var(--bar-ink);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
}

.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-name {
  font-family: var(--font-read);
  font-size: 20px;
  font-weight: 560;
  font-variant-caps: small-caps;
  letter-spacing: 0.035em;
}

.bar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.btn.needs-backup::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-inline-start: 1px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 22%, transparent);
}

/* Nastavenia: lišta bez hľadania a pridávania, obsah je samostatná stránka. */
html[data-view="settings"] .search,
html[data-view="settings"] #add-btn,
html[data-view="settings"] main {
  display: none;
}

html[data-view="settings"] .bar-actions {
  margin-inline-start: auto;
}

/* ---------- vyhľadávanie ---------- */

.search {
  position: relative;
  flex: 1;
  max-width: 440px;
  margin-inline-start: auto;
}

.search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 11px;
  color: var(--bar-muted);
  font-size: 15px;
  transform: translateY(-50%);
  pointer-events: none;
}

#search {
  display: block;
  width: 100%;
  height: 36px;
  padding-block: 0;
  padding-inline: 34px 40px;
  border: 1px solid var(--bar-line);
  border-radius: 999px;
  background: var(--bar-field);
  color: var(--bar-ink);
  font: 450 14px var(--font-ui);
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}

#search::placeholder {
  color: var(--bar-muted);
}

#search::-webkit-search-cancel-button {
  display: none;
}

#search:hover {
  background: var(--bar-field-hover);
}

#search:focus {
  border-color: var(--brand-accent);
  outline: none;
  background: var(--bar-field-hover);
  box-shadow: 0 0 0 3px var(--bar-ring);
}

.kbd {
  position: absolute;
  top: 50%;
  inset-inline-end: 9px;
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--bar-line);
  border-radius: 5px;
  background: transparent;
  color: var(--bar-muted);
  font: 500 11.5px/1.5 var(--font-ui);
  text-align: center;
  transform: translateY(-50%);
  pointer-events: none;
  transition: opacity 0.12s;
}

.search:focus-within .kbd,
.search.has-value .kbd {
  opacity: 0;
}

#search-clear {
  color: var(--bar-muted);
  position: absolute;
  top: 50%;
  inset-inline-end: 3px;
  display: none;
  width: 30px;
  height: 30px;
  font-size: 14px;
  transform: translateY(-50%);
}

.search.has-value #search-clear {
  display: inline-grid;
}

/* ---------- stránka nastavení ---------- */

.panel {
  display: none;
}

html[data-view="settings"] .panel,
.panel.open {
  display: block;
}

/* Spodné odsadenie je vyššie ako tráva (96 px, .grass), aby neprekryla posledný obsah. */
.panel-body {
  padding: 36px 0 calc(120px + env(safe-area-inset-bottom, 0px));
}

.page-head {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 3px double var(--line-strong);
}

.page-title,
.list-title {
  display: inline;
  padding: 0 0.08em;
  background: var(--title-mark);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.page-title {
  margin: 0;
  font-family: var(--font-read);
  font-size: 36px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-lead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* Nastavenia: navigácia sekcií vľavo, stĺpec sekcií vpravo. */
.settings {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 2px;
}

.settings-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.settings-link .icon {
  color: var(--faint);
  font-size: 16px;
  transition: color 0.15s;
}

.settings-link:hover {
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
  color: var(--ink);
}

.settings-link.is-active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  box-shadow: inset 3px 0 0 var(--brand-ink);
}

.settings-link.is-active .icon {
  color: inherit;
}

.settings-link-danger {
  margin-top: 10px;
}

.settings-link-danger.is-active {
  background: var(--danger-soft);
  color: var(--danger);
}

.settings-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.settings-section {
  scroll-margin-top: 88px;
}

.card,
.language-setting,
.danger-zone {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--surface-glow), var(--shadow-sm);
}

.card {
  padding: 26px 28px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-badge {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--badge-bg);
  color: var(--badge-ink);
}

.card-badge svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.language-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
}

.language-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.language-description {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

select.field-input {
  padding-inline-end: 32px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

[dir="rtl"] select.field-input {
  background-position: left 12px center, left 17px center;
}

.usage-setting {
  flex-wrap: wrap;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.usage-note {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* --- prihlásenie --- */

.auth-card {
  position: relative;
  overflow: hidden;
  padding: 0;
  box-shadow: var(--surface-glow), var(--shadow-md);
}

/* Jemný teplý odlesk v hlavičke karty. */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 200px;
  background: radial-gradient(90% 100% at 50% 0%, var(--accent-soft), transparent 72%);
  pointer-events: none;
}

.auth-card > * {
  position: relative;
}

.auth-head {
  padding: 32px 28px 4px;
  text-align: center;
}

.auth-mark {
  display: inline-grid;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.auth-mark .logo {
  width: 40px;
  height: 40px;
  border-radius: 9px;
}

.auth-title {
  margin: 0;
  font-family: var(--font-read);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.auth-subtitle {
  max-width: 38ch;
  margin: 6px auto 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.auth-subtitle:empty {
  display: none;
}

.auth-subtitle.is-error {
  max-width: none;
  margin-top: 14px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  text-align: start;
}

.auth-form,
.auth-card .session-actions {
  width: min(440px, 100%);
  margin-inline: auto;
  padding: 22px 28px 28px;
}

.auth-form .field-input {
  min-height: 40px;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.link-subtle {
  padding: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.link-strong {
  padding: 0;
  color: var(--ink);
  font-weight: 600;
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-resend {
  display: block;
  margin: 12px auto 0;
}

.auth-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-secure svg {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 15px 28px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
  color: var(--muted);
  font-size: 13px;
}

#sync-form[hidden] ~ .auth-foot {
  display: none;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-accent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), var(--shadow-xs);
  color: var(--brand-base);
  font-size: 16px;
  font-weight: 650;
}

.profile-text {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.profile-email {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
}

.session-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.session-buttons #sync-now {
  grid-column: 1 / -1;
  min-height: 40px;
}

.sync-form[hidden] {
  display: none;
}

.field {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
}

.field-label {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 550;
}

.field-input {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  font: 450 14px var(--font-ui);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.field-input::placeholder {
  color: var(--faint);
}

.field-input:hover:not(:disabled):not(:focus) {
  border-color: color-mix(in srgb, var(--line-strong) 60%, var(--muted));
}

.field-input:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.field-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field-input:user-invalid {
  border-color: var(--danger);
}

.field-area {
  min-height: 132px;
  padding: 10px 12px;
  font-family: var(--font-read);
  font-size: 17px;
  line-height: 1.55;
  resize: vertical;
}

.password-field {
  position: relative;
}

.password-field .field-input {
  padding-inline-end: 78px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  inset-inline-end: 5px;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: 550 12px var(--font-ui);
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.field-hint {
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.form-actions .btn-primary {
  flex: 1;
  min-height: 38px;
}

.form-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 16px;
  margin-top: 10px;
}

.link-btn {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 13px var(--font-ui);
  cursor: pointer;
  transition: color 0.12s;
}

.link-btn:hover:not(:disabled) {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.account-privacy {
  margin: 14px 0 0;
  font-size: 12.5px;
  text-align: center;
}

.account-privacy a,
.usage-note a {
  color: var(--muted);
  text-underline-offset: 3px;
}

.link-danger {
  justify-self: start;
  margin-top: 6px;
  color: var(--danger);
}

.link-danger:hover:not(:disabled) {
  color: var(--danger);
}

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

/* --- záloha a export --- */

.backup-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 18px;
}

.backup-info {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent);
}

.data-actions {
  display: grid;
  gap: 8px;
}

.data-actions .btn {
  justify-content: flex-start;
  min-height: 40px;
  padding-block: 8px;
  line-height: 1.3;
  text-align: start;
  white-space: normal;
}

.backup .data-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.privacy-note {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.panel-extra {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.panel-extra p {
  margin: 0;
}

.panel-extra p:empty {
  display: none;
}

.panel-extra .btn {
  justify-self: start;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  border-color: color-mix(in srgb, var(--danger) 26%, var(--line));
  background: linear-gradient(180deg, var(--danger-soft), transparent 140%), var(--surface);
}

.danger-zone strong {
  display: block;
  margin-bottom: 2px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.danger-zone span {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- zoznam úryvkov ---------- */

main.shell {
  padding: 32px 0 calc(120px + env(safe-area-inset-bottom, 0px));
}

.list-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 22px;
}

.list-title {
  margin: 0;
  font-family: var(--font-read);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.status {
  color: var(--muted);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.group + .group {
  margin-top: 32px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 560;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
}

.group-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  letter-spacing: 0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.clips {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.clip {
  transition: opacity 0.25s, transform 0.28s var(--ease);
}

/* Úryvok vybraný klávesnicou (J/K, šípky); pod lištou zostane celý viditeľný. */
.clip {
  scroll-margin-block: 96px 24px;
}

.clip:focus {
  outline: none;
}

.clip:focus-visible .clip-fold {
  border-color: var(--line-strong);
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.clip.leaving {
  opacity: 0;
  transform: translateY(-4px) scale(0.99);
}

.clip-fold {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--surface-glow), var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}

.clip-fold:hover,
.clip-fold:focus-within {
  border-color: var(--line-strong);
  box-shadow: var(--surface-glow), var(--shadow-md);
}

/* Posun karty pri hover vytvorí vlastnú vrstvu; otvorená ponuka (Citovať) by inak
   skončila pod nasledujúcou kartou. Karta s ponukou alebo zameraním ide navrch. */
.clip-fold:focus-within,
.clip-fold:has(.cite-menu) {
  z-index: 3;
}

@media (hover: hover) {
  .clip-fold:hover {
    transform: translateY(-1px);
  }
}

.clip-body {
  padding: 24px 26px 14px;
  border-radius: inherit;
}

@keyframes fresh-flash {
  from {
    background-color: var(--accent-soft);
  }
  to {
    background-color: transparent;
  }
}

.clip.fresh .clip-body {
  animation: fresh-flash 1.8s var(--ease);
}

.quote {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: var(--font-read);
  font-size: 19.5px;
  font-weight: 420;
  line-height: 1.6;
  letter-spacing: -0.003em;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.note-wrap {
  position: relative;
  margin: 0 -8px;
}

.note {
  display: block;
  width: 100%;
  min-height: 34px;
  max-height: 260px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-2);
  font: 450 13.5px/1.5 var(--font-ui);
  resize: none;
  field-sizing: content;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.note::placeholder {
  color: var(--faint);
}

.note:hover {
  background: var(--surface-2);
}

.note:focus {
  border-color: var(--focus);
  outline: none;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--ring);
}

.note-state {
  position: absolute;
  inset-inline-end: 10px;
  bottom: 7px;
  color: var(--muted);
  font-size: 11.5px;
  pointer-events: none;
}

.clip-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--ink-2);
  font-weight: 550;
  text-decoration: none;
}

.source .icon {
  color: var(--faint);
  font-size: 13px;
}

.source-title {
  overflow: hidden;
  max-width: 36ch;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.source:hover {
  color: var(--ink);
}

a.source:hover .source-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.time-chip {
  flex: none;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: 600 12px/1.4 var(--font-ui);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.time-chip:hover {
  border-color: var(--brand-accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.host {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host:not(:empty)::before {
  content: "·";
  margin-inline-end: 8px;
  color: var(--faint);
}

.when {
  margin-inline-start: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.delete {
  width: 28px;
  height: 28px;
  margin-block: -4px;
  margin-inline: 0 -6px;
  font-size: 14px;
}

@media (hover: hover) {
  .delete {
    opacity: 0;
  }

  .clip:hover .delete,
  .clip:focus-within .delete,
  .delete:focus-visible {
    opacity: 1;
  }
}

.delete:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- prázdny stav ---------- */

.empty {
  padding: 64px 24px 48px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  text-align: center;
}

.empty-title {
  margin: 0 0 8px;
  font-family: var(--font-read);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.empty-lead {
  max-width: 50ch;
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.how {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 36px;
  align-items: center;
  max-width: 600px;
  margin: 32px auto 0;
  text-align: start;
}

.steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  color: var(--ink-2);
  font-size: 14px;
  list-style: none;
  counter-reset: step;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.menu-mock {
  width: 232px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  user-select: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
}

.menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--line);
}

.menu-hit {
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 600;
}

.menu-hit img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.empty.compact {
  padding: 48px 24px 40px;
}

.empty.compact .empty-title {
  font-size: 17px;
}

.empty.compact .empty-lead {
  margin-bottom: 18px;
  font-size: 14px;
}

/* ---------- oznamy ---------- */

.toasts {
  position: fixed;
  inset: auto 0 calc(20px + env(safe-area-inset-bottom, 0px)) 0;
  z-index: 60;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

@keyframes toast-timer {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  min-width: min(340px, calc(100vw - 32px));
  max-width: min(520px, calc(100vw - 32px));
  padding-block: 9px 10px;
  padding-inline: 16px 8px;
  border: 1px solid var(--toast-line);
  border-radius: 10px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toast-in 0.28s var(--ease);
}

.toast.out {
  animation: toast-out 0.22s var(--ease) forwards;
}

.toast.error {
  border-color: transparent;
  background: var(--danger-solid);
  color: #ffffff;
}

.toast-text {
  flex: 1;
  line-height: 1.4;
}

.toast-action {
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent);
  font: 600 13px var(--font-ui);
  cursor: pointer;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.18);
}

.toast .icon-btn {
  width: 28px;
  height: 28px;
  color: inherit;
  font-size: 14px;
  opacity: 0.6;
}

.toast .icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  opacity: 1;
}

.toast-timer {
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.8;
  transform-origin: left;
  animation: toast-timer linear forwards;
}

[dir="rtl"] .toast-timer {
  transform-origin: right;
}

.toast.error .toast-timer {
  background: rgba(255, 255, 255, 0.7);
}

/* ---------- dialógy ---------- */

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

.dialog {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.dialog[open] {
  animation: dialog-in 0.22s var(--ease);
}

.dialog::backdrop {
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dialog form {
  display: grid;
  padding: 24px 24px 0;
}

.dialog h2 {
  margin: 0 0 6px;
  font-family: var(--font-read);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.dialog-text {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.dialog .field-hint {
  margin: 0 0 14px;
}

.optional {
  color: var(--muted);
  font-weight: 450;
}

.field-error {
  min-height: 18px;
  margin: 0 0 6px;
  color: var(--danger);
  font-size: 13px;
}

.field-error:empty {
  display: none;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 10px -24px 0;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  background: var(--surface-2);
}

#clear-dialog .field-input:focus,
#delete-account-dialog .field-input:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}

/* ---------- štítky ---------- */

.clip-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.clip-tags[hidden],
.tag-bar[hidden] {
  display: none;
}

.clip-tag-list {
  display: contents;
}

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -8px 0 22px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: 500 12.5px/1 var(--font-ui);
  transition: border-color 0.15s, background-color 0.15s;
}

.tag-chip.is-active {
  border-color: var(--brand-accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.tag-filter,
.tag-remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.tag-remove {
  margin-inline-start: -6px;
  padding: 0 8px 0 4px;
  color: var(--muted);
}

.tag-remove .icon {
  width: 12px;
  height: 12px;
}

.tag-filter:hover,
.tag-remove:hover {
  color: var(--ink);
}

.tag-count {
  color: var(--muted);
  font-size: 11.5px;
}

.tag-input {
  width: 160px;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 500 12.5px var(--font-ui);
}

.tag-input:focus {
  border-color: var(--brand-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--bar-ring);
}

/* ---------- klávesové skratky ---------- */

/* Spoločná mriežka (subgrid): stĺpec kláves má šírku najdlhšej kombinácie vo všetkých riadkoch. */
.shortcuts {
  display: grid;
  grid-template-columns: minmax(96px, max-content) 1fr;
  gap: 2px 0;
  margin: 8px 0 6px;
}

.shortcut-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.shortcut-row:last-child {
  border-bottom: 0;
}

.shortcut-row dt,
.shortcut-row dd {
  margin: 0;
}

.shortcut-row dd {
  color: var(--ink);
  font-size: 14.5px;
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.shortcut-keys kbd {
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: 500 12.5px/1.4 var(--font-ui);
  text-align: center;
}

.shortcut-sep,
.shortcut-unset {
  color: var(--muted);
  font-size: 13px;
}

.shortcut-change {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- úzke obrazovky ---------- */

@media (max-width: 860px) {
  .settings {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  /* Navigácia sekcií ako vodorovný pás čipov. */
  .settings-nav {
    position: static;
    display: flex;
    min-width: 0;
    gap: 6px;
    margin-inline: -16px;
    padding: 2px 16px 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-link {
    flex: none;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13px;
  }

  .settings-link-danger {
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .backup .data-actions {
    grid-template-columns: 1fr;
  }

  .how {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .danger-zone,
  .language-setting {
    flex-direction: column;
    align-items: stretch;
  }

  /* V stĺpci by zalamovanie s flex-basis: 100 % roztiahlo poznámku na šírku textu. */
  .usage-setting {
    flex-wrap: nowrap;
  }

  .usage-note {
    flex-basis: auto;
  }
}

@media (max-width: 640px) {
  .bar-row {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
  }

  .brand {
    margin-inline-end: auto;
  }

  .search {
    order: 9;
    flex-basis: 100%;
    max-width: none;
    margin: 0;
  }

  .kbd {
    display: none;
  }

  .bar-actions .btn-label {
    display: none;
  }

  .bar-actions .btn {
    width: 34px;
    padding: 0;
  }

  main.shell {
    padding-top: 22px;
  }

  .panel-body {
    padding-top: 24px;
  }

  .clip-body {
    padding: 18px 18px 12px;
  }

  .quote {
    font-size: 18px;
  }

  .page-title {
    font-size: 30px;
  }

  .list-title {
    font-size: 27px;
  }

  .card {
    padding: 22px 20px;
  }

  .language-setting,
  .danger-zone {
    padding: 18px 20px;
  }

  .source-title {
    max-width: 22ch;
  }

  .host {
    display: none;
  }

  .empty {
    padding: 44px 18px 36px;
  }
}

/* ---------- citovanie a zdroj (Fáza 1) ---------- */

.clip-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.clip-actions .btn {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.clip-actions .btn .icon {
  font-size: 14px;
}

.cite-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  color: color-mix(in srgb, var(--warn) 70%, var(--ink));
  font: 600 11.5px var(--font-ui);
  cursor: pointer;
}

.cite-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.cite-badge:hover {
  background: color-mix(in srgb, var(--warn) 20%, transparent);
}

.cite-menu {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-start: 0;
  z-index: 20;
  display: grid;
  gap: 4px;
  width: min(420px, calc(100vw - 48px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.cite-style {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.cite-select {
  flex: 1;
  min-height: 32px;
  font-size: 13px;
}

.cite-profile {
  flex: 0 0 96px;
}

.cite-preview {
  margin: 2px 0 4px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-2);
  font: 450 12.5px/1.5 var(--font-ui);
  overflow-wrap: anywhere;
}

.cite-warning {
  margin: 0 0 4px;
  color: color-mix(in srgb, var(--warn) 70%, var(--ink));
  font-size: 12.5px;
}

.cite-action {
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: 550 13.5px var(--font-ui);
  text-align: start;
  cursor: pointer;
}

.cite-action:hover,
.cite-action:focus-visible {
  background: var(--surface-2);
}

.cite-action-subtle {
  color: var(--muted);
  font-weight: 500;
}

.source-slot:empty {
  display: none;
}

.source-editor {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.source-editor .field {
  margin-bottom: 10px;
}

.source-editor .field-input {
  min-height: 34px;
  font-size: 13.5px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.field-wide {
  grid-column: 1 / -1;
}

.authors-field {
  min-width: 0;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}

.authors-list {
  display: grid;
  gap: 6px;
}

.author-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
}

.author-row .author-literal {
  grid-column: span 2;
}

.author-row .author-remove {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.author-add {
  justify-self: start;
  margin-top: 4px;
  font-size: 12.5px;
}

.source-lookup {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.source-lookup .btn {
  min-height: 30px;
  font-size: 12.5px;
}

.source-apply-all {
  margin-bottom: 8px;
  font-size: 13px;
}

.source-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 640px) {
  .source-grid {
    grid-template-columns: 1fr;
  }

  .author-row {
    grid-template-columns: minmax(0, 1fr) 28px;
  }

  .author-row .author-kind,
  .author-row .author-family,
  .author-row .author-given,
  .author-row .author-literal {
    grid-column: 1;
  }

  .author-row .author-remove {
    grid-column: 2;
    grid-row: 1;
  }
}

/* --- zoznam literatúry --- */

.list-head .list-bib {
  align-self: center;
  margin-inline-start: auto;
  min-height: 30px;
  font-size: 12.5px;
}

.dialog-wide {
  width: min(680px, calc(100% - 32px));
}

.bib-list {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 480px);
  margin: 12px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.bib-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.bib-item.is-incomplete {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
}

.bib-text {
  margin: 0;
  color: var(--ink);
  font: 450 13.5px/1.55 var(--font-ui);
  overflow-wrap: anywhere;
}

.bib-item .cite-warning {
  margin: 6px 0 0;
}

.list-head .list-draft {
  margin-inline-start: 0;
}

.draft-area {
  min-height: 180px;
}

.draft-results {
  display: grid;
  gap: 8px;
  max-height: min(40vh, 380px);
  margin-top: 12px;
  overflow-y: auto;
}

.draft-summary,
.draft-hint {
  margin: 0;
  color: var(--faint);
  font: 500 12.5px/1.5 var(--font-ui);
}

.draft-warning {
  margin: 0;
  color: var(--warn);
  font: 550 13px/1.5 var(--font-ui);
}

.draft-ok {
  margin: 0;
  color: var(--ink);
  font: 600 13.5px/1.5 var(--font-ui);
}

.draft-heading {
  margin: 8px 0 0;
  color: var(--ink);
  font: 650 13.5px/1.4 var(--font-ui);
}

.draft-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.draft-item {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.draft-item-text,
.draft-suggestion-text {
  margin: 0;
  color: var(--ink);
  font: 450 13px/1.5 var(--font-ui);
  overflow-wrap: anywhere;
}

.draft-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.draft-suggestion-text {
  flex: 1;
  min-width: 0;
}

.trash-list {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 480px);
  margin: 12px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.trash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.trash-body {
  flex: 1;
  min-width: 0;
}

.trash-text {
  margin: 0;
  color: var(--ink);
  font: 450 13.5px/1.5 var(--font-ui);
  overflow-wrap: anywhere;
}

.trash-meta {
  margin: 3px 0 0;
  color: var(--faint);
  font: 500 12px/1.4 var(--font-ui);
}

.storage-info.is-warning {
  color: var(--warn);
  font-weight: 600;
}

/* ---------- pripnutie, výber, hromadné akcie, uložené hľadania ---------- */

.list-head .list-view + .list-bib {
  margin-inline-start: 0;
}

.pin {
  width: 28px;
  height: 28px;
  margin-block: -4px;
  font-size: 14px;
}

.pin[aria-pressed="true"] {
  color: var(--brand-accent);
}

@media (hover: hover) {
  .pin[aria-pressed="false"] {
    opacity: 0;
  }

  .clip:hover .pin,
  .clip:focus-within .pin,
  .pin:focus-visible {
    opacity: 1;
  }
}

.group-pinned .group-title {
  color: var(--brand-accent);
}

.group-pinned .group-title .icon {
  font-size: 14px;
}

.clip {
  position: relative;
}

.select-box {
  position: absolute;
  top: 14px;
  inset-inline-start: -30px;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand-accent);
  cursor: pointer;
}

@media (hover: hover) {
  .select-box:not(:checked) {
    opacity: 0;
  }

  .clip:hover .select-box,
  .clip:focus-within .select-box,
  .has-selection .select-box,
  .select-box:focus-visible {
    opacity: 1;
  }
}

@media (max-width: 760px) {
  .select-box {
    inset-inline-start: 6px;
    top: 6px;
  }
}

.clip.is-selected .clip-fold {
  border-color: var(--brand-accent);
  background: var(--accent-soft);
}

.select-bar {
  position: fixed;
  inset-inline: 16px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 880px;
  margin-inline: auto;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl, 14px);
  background: var(--surface);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}

.select-bar[hidden] {
  display: none;
}

.select-count {
  margin-inline-end: auto;
  color: var(--ink);
  font: 650 13.5px/1 var(--font-ui);
}

.select-tag {
  width: 180px;
  min-height: 34px;
}

.saved-bar {
  margin-top: -14px;
}

.save-search {
  min-height: 26px;
  padding-block: 0;
  font-size: 12.5px;
}

.tag-hints {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-inline-start: 6px;
}

.tag-hint {
  min-height: 24px;
  padding: 0 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: 500 12px/1 var(--font-ui);
  cursor: pointer;
}

.tag-hint:hover {
  border-style: solid;
  border-color: var(--brand-accent);
  background: var(--accent-soft);
}

.empty-hint {
  margin: 14px 0 0;
  color: var(--faint);
  font: 500 12.5px/1.4 var(--font-ui);
}

/* Panel, ktorý sa objaví nad označenou časťou citátu. */
.hl-pop {
  position: fixed;
  z-index: 60;
}

.hl-pop[hidden] {
  display: none;
}

/* ---------- farby a štítky zvýraznení ---------- */

.hl[data-color="yellow"],
.hl-dot[data-color="yellow"],
.hl-label[data-color="yellow"] {
  --mark-a: rgba(255, 214, 64, 0.82);
  --mark-b: rgba(255, 226, 110, 0.7);
  --mark-ink: #1b1a17;
}

.hl[data-color="green"],
.hl-dot[data-color="green"],
.hl-label[data-color="green"] {
  --mark-a: rgba(120, 214, 140, 0.8);
  --mark-b: rgba(150, 226, 165, 0.68);
  --mark-ink: #1b1a17;
}

.hl[data-color="blue"],
.hl-dot[data-color="blue"],
.hl-label[data-color="blue"] {
  --mark-a: rgba(110, 170, 255, 0.82);
  --mark-b: rgba(140, 190, 255, 0.72);
  --mark-ink: #1b1a17;
}

.hl[data-color="pink"],
.hl-dot[data-color="pink"],
.hl-label[data-color="pink"] {
  --mark-a: rgba(255, 143, 184, 0.78);
  --mark-b: rgba(255, 160, 196, 0.66);
  --mark-ink: #1b1a17;
}

.hl[data-color="orange"],
.hl-dot[data-color="orange"],
.hl-label[data-color="orange"] {
  --mark-a: rgba(255, 170, 90, 0.82);
  --mark-b: rgba(255, 190, 120, 0.7);
  --mark-ink: #1b1a17;
}

.hl[data-label]::after {
  content: attr(data-label);
  margin-inline-start: 0.4em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mark-a) 55%, var(--surface));
  color: var(--mark-ink);
  font: 650 0.58em/1.6 var(--font-ui);
  letter-spacing: 0.02em;
  vertical-align: 0.28em;
  white-space: nowrap;
}

.hl-pop {
  display: grid;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 8px 22px rgb(0 0 0 / 0.25);
}

.hl-pop:has(.hl-extra:not([hidden])) {
  padding: 8px;
  border-radius: 14px;
  background: var(--surface);
}

.hl-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.hl-main,
.hl-more {
  border: 0;
  background: transparent;
  color: var(--surface);
  font: 650 13px/1 var(--font-ui);
  cursor: pointer;
}

.hl-main {
  padding: 8px 12px;
  border-radius: 999px;
}

.hl-more {
  padding: 8px 9px;
  border-radius: 999px;
  opacity: 0.8;
}

.hl-main:hover,
.hl-more:hover {
  background: rgb(255 255 255 / 0.16);
}

.hl-pop:has(.hl-extra:not([hidden])) .hl-main,
.hl-pop:has(.hl-extra:not([hidden])) .hl-more {
  color: var(--ink);
}

.hl-pop:has(.hl-extra:not([hidden])) .hl-main:hover,
.hl-pop:has(.hl-extra:not([hidden])) .hl-more:hover {
  background: var(--accent-soft);
}

.hl-extra {
  display: grid;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.hl-extra[hidden] {
  display: none;
}

.hl-colors,
.hl-labels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.hl-dot {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--mark-a);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}

.hl-dot:hover {
  transform: scale(1.12);
}

.hl-label {
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--mark-a);
  color: var(--mark-ink);
  font: 600 12px/1.3 var(--font-ui);
  cursor: pointer;
}

/* ---------- režim čítania zdroja ---------- */

.group-read {
  margin-inline-start: auto;
  min-height: 26px;
  padding-block: 0;
  font-size: 12.5px;
  font-variant-caps: normal;
  letter-spacing: 0;
}

.reading-list {
  display: grid;
  gap: 14px;
  max-height: min(52vh, 520px);
  margin: 12px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.reading-item {
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}

.reading-quote {
  margin: 0 0 6px;
  font-size: 17px;
}

.reading-where {
  display: inline-block;
  margin-inline-end: 8px;
  padding: 1px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-2);
  font: 600 12px/1.5 var(--font-ui);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.reading-note {
  margin: 6px 0 0;
  color: var(--ink-2);
  font: 450 13.5px/1.55 var(--font-ui);
  white-space: pre-line;
}

.reading-filter {
  margin: 8px 0 0;
}

/* ---------- PDF: chip so stranou a čistenie textu ---------- */

.page-slot {
  display: inline-flex;
  flex: none;
}

.page-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: 600 12px/1.4 var(--font-ui);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  cursor: pointer;
}

.page-chip.is-empty {
  border-style: dashed;
  color: var(--faint);
}

.page-chip:hover {
  border-color: var(--brand-accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.page-input {
  width: 72px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--brand-accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 12px/1.4 var(--font-ui);
}

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

.dup-list {
  display: grid;
  gap: 12px;
  max-height: min(58vh, 540px);
  margin: 12px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.dup-group {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.dup-kind {
  margin: 0 0 8px;
  color: var(--faint);
  font: 600 12px/1.3 var(--font-ui);
  letter-spacing: 0.02em;
}

.dup-rows {
  display: grid;
  gap: 6px;
}

.dup-clip {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.dup-clip:has(input:checked) {
  border-color: var(--brand-accent);
  background: var(--accent-soft);
}

.dup-clip input {
  flex: none;
  margin-top: 3px;
}

.dup-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dup-text {
  color: var(--ink);
  font: 450 13.5px/1.5 var(--font-ui);
  overflow-wrap: anywhere;
}

.dup-meta {
  color: var(--faint);
  font: 500 12px/1.4 var(--font-ui);
  overflow-wrap: anywhere;
}

.dup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.bib-actions {
  flex-wrap: wrap;
}

.bib-spacer {
  flex: 1;
}

.authors-field legend {
  padding: 0;
}

@media (max-width: 640px) {
  .list-head .list-bib .btn-label {
    display: none;
  }

  .bib-spacer {
    display: none;
  }
}

.vault-lead {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.mirror {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-2) 60%, var(--surface));
}

.mirror .privacy-note {
  margin-top: 16px;
}

.mirror-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.mirror .vault-lead {
  margin-top: 6px;
}

/* ---------- inteligentné funkcie (Fáza 3) ---------- */

.smart-status {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.smart-progress {
  display: block;
  width: 100%;
  height: 6px;
  margin: -4px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  accent-color: var(--accent);
  overflow: hidden;
}

.smart-progress::-webkit-progress-bar {
  background: var(--surface-3);
}

.smart-progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

.smart .data-actions .btn {
  justify-content: center;
}

/* Prepínač Podľa významu / Presne pri nadpise knižnice. */
.search-mode {
  display: inline-flex;
  align-self: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.search-mode button {
  min-height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 550 12.5px var(--font-ui);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.search-mode button:hover {
  color: var(--ink);
}

.search-mode button.is-active {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.list-head .search-mode:not([hidden]) + .list-bib {
  margin-inline-start: 8px;
}

.list-head .search-mode {
  margin-inline-start: auto;
}

/* Podobné úryvky – tlačidlo len so zapnutými inteligentnými funkciami. */
.similar-btn {
  display: none;
}

html[data-smart="on"] .similar-btn {
  display: inline-flex;
}

.similar-slot:empty {
  display: none;
}

.similar {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
}

.similar-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.similar-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.similar-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}

.similar-item:hover,
.similar-item:focus-visible {
  background: var(--surface);
}

.similar-quote {
  font-family: var(--font-read);
  font-size: 15px;
  line-height: 1.45;
}

.similar-source {
  color: var(--muted);
  font-size: 12px;
}

.similar-source:empty {
  display: none;
}

.similar-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@keyframes clip-flash {
  from {
    box-shadow: 0 0 0 3px var(--ring), var(--shadow-md);
  }
  to {
    box-shadow: var(--surface-glow), var(--shadow-sm);
  }
}

.clip.flash .clip-fold {
  animation: clip-flash 1.6s var(--ease);
}

/* ---------- knižná sadzba a pohyb ---------- */

.list-head {
  padding-bottom: 14px;
  border-bottom: 3px double var(--line-strong);
}

.list-title,
.page-title {
  font-weight: 450;
  letter-spacing: -0.01em;
}

.quote {
  hanging-punctuation: first;
  text-wrap: pretty;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.topbar {
  animation: fade 0.6s var(--ease) backwards;
}

.list-head,
.page-head {
  animation: rise 0.8s var(--ease) backwards;
  animation-delay: 80ms;
}

/* Úryvky pri prvom načítaní vystúpia postupne, jeden za druhým. */
.clip.sweep {
  animation: rise 0.7s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 70ms + 160ms);
}

.empty {
  animation: rise 0.8s var(--ease) backwards;
}

/* Lišta pri posúvaní získa jemný tieň (animácia riadená posúvaním stránky). */
@supports (animation-timeline: scroll()) {
  @keyframes bar-lift {
    to {
      box-shadow: 0 10px 30px -18px rgba(15, 40, 32, 0.45);
    }
  }

  .topbar {
    animation: fade 0.6s var(--ease) backwards, bar-lift linear both;
    animation-timeline: auto, scroll(root);
    animation-range: normal, 0 120px;
  }
}

/* Arriving with the camera move (theme.js), the page is already there: the top bar does not fade
   in and the heading and clips do not rise on top of the move. */
html[data-arrived] :is(.topbar, .list-head, .page-head, .clip.sweep, .empty) {
  animation: none;
}

@supports (animation-timeline: scroll()) {
  html[data-arrived] .topbar {
    animation: bar-lift linear both;
    animation-timeline: scroll(root);
    animation-range: 0 120px;
  }
}

.btn,
.icon-btn {
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.25s var(--ease),
    transform 0.18s var(--ease);
}

.btn:active:not(:disabled),
.icon-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.brand .logo {
  transition: transform 0.6s var(--ease);
}

.brand:hover .logo {
  transform: rotate(-8deg) scale(1.06);
}

/* ---------- tráva vo vetre (grass.js) ---------- */

.grass {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  width: 100%;
  /* Spodná polovica je tráva (priehľadnosť v grass.js), nad ňu trčia slnečnice. */
  height: 96px;
  pointer-events: none;
  animation: grass-grow 1.4s var(--ease) backwards;
  animation-delay: 0.3s;
}

@keyframes grass-grow {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* Posledný úryvok sa dá vždy vytiahnuť nad trávu. */
body {
  padding-bottom: 60px;
}

@media (max-width: 640px) {
  .grass {
    height: 72px;
  }

  body {
    padding-bottom: 44px;
  }
}

/* ---------- oblaky v pozadí (clouds.js) ---------- */

/* Pozadie sa presunie z <body> na <html>, aby oblaky (z-index -1) boli nad ním,
   ale pod celým obsahom stránky. */
html {
  background-color: var(--bg);
  background-image: var(--sky, none);
  background-repeat: no-repeat;
  background-size: 100% 200vh;
  /* Knižnica = spodná polovica vysokej oblohy (theme.css --sky). */
  background-position: 0 100%;
  background-attachment: fixed;
}

body {
  background: none;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* Oblak = niekoľko prekrývajúcich sa rozmazaných elips; takmer neviditeľný. */
.cloud {
  position: absolute;
  top: var(--top);
  left: 0;
  width: var(--size);
  aspect-ratio: 2.6;
  background:
    radial-gradient(closest-side, var(--cloud), transparent) 8% 70% / 46% 62% no-repeat,
    radial-gradient(closest-side, var(--cloud), transparent) 38% 30% / 44% 80% no-repeat,
    radial-gradient(closest-side, var(--cloud), transparent) 70% 55% / 48% 70% no-repeat,
    radial-gradient(closest-side, var(--cloud), transparent) 92% 75% / 30% 46% no-repeat;
  filter: blur(4px);
  opacity: var(--alpha);
  animation: drift var(--time) linear infinite;
  animation-delay: var(--delay);
  will-change: transform;
  contain: layout paint style;
}

/* Slnko za kurzorom: teplá mäkká žiara, takže slnečnice sa otáčajú „za slnkom“. */
.sun {
  position: absolute;
  top: 0;
  left: 0;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--sun-core), var(--sun-halo) 38%, transparent);
  opacity: 0;
  transform: translate3d(var(--sun-x, 50vw), var(--sun-y, -300px), 0);
  transition: transform 0.9s var(--ease), opacity 1.2s var(--ease);
  will-change: transform;
}

.sky.sun-up .sun {
  opacity: 1;
}

/* Mesiac v noci: spln s morami rozloženými ako na skutočnom Mesiaci (Oceán búrok vľavo,
   More dažďov hore, More pokoja vpravo, Kŕčové more pri pravom okraji, svetlý kráter Tycho dole).
   Mäkké okraje, mierne rozmazanie a žiara vo vzduchu – ako pri pohľade cez atmosféru. */
.moon {
  position: absolute;
  top: max(96px, 11vh);
  right: 12vw;
  width: 72px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 9% 7% at 47% 85%, rgba(255, 255, 250, 0.7), transparent),
    radial-gradient(ellipse 30% 44% at 26% 50%, rgba(112, 118, 124, 0.42), transparent),
    radial-gradient(ellipse 22% 17% at 38% 30%, rgba(105, 111, 118, 0.48), transparent),
    radial-gradient(ellipse 13% 12% at 58% 31%, rgba(108, 114, 120, 0.44), transparent),
    radial-gradient(ellipse 16% 14% at 64% 47%, rgba(110, 116, 122, 0.42), transparent),
    radial-gradient(ellipse 7% 9% at 82% 37%, rgba(100, 106, 112, 0.5), transparent),
    radial-gradient(ellipse 9% 8% at 75% 60%, rgba(116, 122, 128, 0.32), transparent),
    radial-gradient(ellipse 14% 10% at 43% 70%, rgba(124, 130, 136, 0.28), transparent),
    radial-gradient(circle at 46% 42%, #f6f4ec, #e3e0d6 62%, #cbc8bd);
  box-shadow:
    inset 0 0 10px rgba(30, 36, 44, 0.22),
    0 0 22px 4px rgba(225, 232, 240, 0.2),
    0 0 120px 40px rgba(200, 214, 230, 0.08);
  filter: blur(0.7px);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.4s var(--ease), transform 1.6s var(--ease);
}

:root[data-theme="dark"] .moon {
  opacity: 0.92;
  transform: none;
}

@keyframes drift {
  from {
    transform: translate3d(-40vw, 0, 0);
  }
  50% {
    transform: translate3d(35vw, -14px, 0);
  }
  to {
    transform: translate3d(110vw, 0, 0);
  }
}

/* Peľ cez deň a svätojánske mušky v noci (ambient.js) – za obsahom ako oblaky. */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Bez pohybu: oblaky, slnko za kurzorom, peľ a mušky zmiznú; mesiac (stojí na mieste) ostane. */
@media (prefers-reduced-motion: reduce) {
  .cloud,
  .sun,
  .ambient {
    display: none;
  }
}

html[data-motion="off"] .cloud,
html[data-motion="off"] .sun,
html[data-motion="off"] .ambient {
  display: none;
}

/* Blikanie hviezd je tiež pohyb. */
html[data-motion="off"] .stars::after {
  animation: none;
}

@media print {
  .grass,
  .ambient,
  .sky {
    display: none;
  }
}

/* ---------- prechod do nastavení: výstup do vesmíru ----------
   Nastavenia sú samostatné načítanie stránky (?view=settings), preto prechod medzi
   dokumentmi (View Transitions). Pôsobí ako jazda kamery hore: celá scéna (obloha, oblaky,
   lúka, knižnica) sa posunie o výšku okna dole a nastavenia prídu presne zhora, rovnakou
   rýchlosťou a bez prelínania – ako jeden vysoký obraz. Spodok neba nastavení má tú istú
   farbu ako vrch neba knižnice, takže šev nevidno. Horná lišta ostáva na mieste.
   Smer (ascend/descend) nastaví theme.js pri udalosti pagereveal. */
@view-transition {
  navigation: auto;
}

.topbar {
  view-transition-name: topbar;
}

::view-transition-group(topbar) {
  animation: none;
}

/* The top bar is swapped at once instead of cross-fading: a cross-fade showed the old and the new
   buttons (Add, Settings and Back to clips) on top of each other for a moment. */
::view-transition-old(topbar) {
  display: none;
}

::view-transition-new(topbar) {
  animation: none;
}

html[data-view="settings"] #data-toggle .toggle-to-settings,
html:not([data-view="settings"]) #data-toggle .toggle-to-library {
  display: none;
}

::view-transition-old(root),
::view-transition-new(root) {
  mix-blend-mode: normal;
}

@keyframes camera-up-old {
  to {
    transform: translateY(100vh);
  }
}

@keyframes camera-up-new {
  from {
    transform: translateY(-100vh);
  }
}

@keyframes camera-down-old {
  to {
    transform: translateY(-100vh);
  }
}

@keyframes camera-down-new {
  from {
    transform: translateY(100vh);
  }
}

:root:active-view-transition-type(ascend)::view-transition-old(root) {
  animation: camera-up-old 1.2s cubic-bezier(0.7, 0, 0.3, 1) both;
}

:root:active-view-transition-type(ascend)::view-transition-new(root) {
  animation: camera-up-new 1.2s cubic-bezier(0.7, 0, 0.3, 1) both;
}

:root:active-view-transition-type(descend)::view-transition-old(root) {
  animation: camera-down-old 1.1s cubic-bezier(0.7, 0, 0.3, 1) both;
}

:root:active-view-transition-type(descend)::view-transition-new(root) {
  animation: camera-down-new 1.1s cubic-bezier(0.7, 0, 0.3, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

/* The same move without cross-document view transitions (Firefox; theme.js): the page leaves
   with the first half of the move and the next page arrives with the second, at the speed the
   first half ended with. theme.js moves the page with Web Animations; here the sky (the <html>
   background) moves with it while leaving, and an arriving page waits where the move starts
   until it is parsed. */
@keyframes sky-leave {
  to {
    background-position: 0 50%;
  }
}

html[data-camera^="leave"] {
  animation: sky-leave 0.5s cubic-bezier(0.5, 0, 0.75, 0.5) forwards;
}

html[data-camera^="enter"] {
  background-position: 0 50%;
}

html[data-camera="enter-ascend"] :is(.sky, .grass, .ambient, #data-panel, main.shell) {
  translate: 0 -50vh;
}

html[data-camera="enter-descend"] :is(.sky, .grass, .ambient, #data-panel, main.shell) {
  translate: 0 50vh;
}

/* ---------- Settings → Show the meadow off (meadow-setting.js) ---------- */

/* A plain page: no sky, clouds, grass, pollen or streak; the stored meadow stays for later. */
html[data-meadow="off"] {
  background-image: none;
}

html[data-meadow="off"] .sky,
html[data-meadow="off"] .grass,
html[data-meadow="off"] .ambient,
html[data-meadow="off"] .garden-chip {
  display: none;
}

html[data-meadow="off"] body {
  padding-bottom: 0;
}

.garden-checks {
  display: grid;
  gap: 8px;
}

.garden-checks .check:has(input:disabled) {
  opacity: 0.55;
}

/* ---------- nastavenia: nad oblakmi, na okraji vesmíru ---------- */

/* Hore nie je tráva, oblaky, peľ ani mušky. */
html[data-view="settings"] .grass,
html[data-view="settings"] .cloud,
html[data-view="settings"] .ambient {
  display: none;
}

html[data-view="settings"] body {
  padding-bottom: 0;
}

/* Nastavenia = horná polovica tej istej vysokej oblohy: vesmír prechádzajúci do modrej,
   ktorá na spodku plynule nadväzuje na vrch neba knižnice. */
html[data-view="settings"] {
  background-position: 0 0;
}

/* Pri odchode zo stránky zhasne žiara za kurzorom, aby ju snímka prechodu neorezala
   pri hornom okraji (kurzor je vtedy na tlačidle v lište). */
html.leaving .sun {
  opacity: 0 !important;
  transition: none;
}

/* Hviezdy: drobné body v dlaždiciach, vidno ich len hore v tme (maska) a jemne blikajú. */
.stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image:
    radial-gradient(1px 1px at 23px 41px, #fff, transparent),
    radial-gradient(1px 1px at 141px 87px, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1.4px 1.4px at 211px 18px, #fff, transparent),
    radial-gradient(1px 1px at 77px 163px, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.2px 1.2px at 178px 201px, #fff, transparent),
    radial-gradient(1px 1px at 252px 129px, rgba(255, 255, 255, 0.75), transparent);
  background-size: 271px 233px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 22%, transparent 58%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 22%, transparent 58%);
  transition: opacity 1s var(--ease);
}

.stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 61px 23px, #fff, transparent),
    radial-gradient(1px 1px at 189px 151px, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(1.3px 1.3px at 103px 211px, #fff, transparent);
  background-size: 307px 269px;
  animation: twinkle 4.6s ease-in-out infinite alternate;
  will-change: opacity;
}

@keyframes twinkle {
  from {
    opacity: 0.25;
  }
  to {
    opacity: 1;
  }
}

html[data-view="settings"] .stars {
  opacity: 0.9;
}

/* V noci aj nad lúkou je pár hviezd, len slabšie. */
:root[data-theme="dark"][data-view="library"] .stars {
  opacity: 0.35;
}

/* Text priamo na oblohe: na tmavom vesmíre svetlý; ponuka sekcií na matnom skle. */
:root[data-theme="light"][data-view="settings"] .page-title {
  color: #f4f6fc;
}

:root[data-theme="light"][data-view="settings"] .page-lead {
  color: rgba(228, 235, 248, 0.86);
}

html[data-view="settings"] .page-head {
  border-bottom-color: rgba(255, 255, 255, 0.28);
}

html[data-view="settings"] .settings-nav {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

/* ---------- sadzba ako v knihe ---------- */

.quote,
.reading-note,
.dialog-text {
  text-wrap: pretty;
}

.quote {
  font-feature-settings: "kern", "liga", "onum", "calt";
}

/* ---------- meadow and streak (garden-ui.js) ---------- */

/* Streak chip in the top bar: a sprout and the number of days in a row. */
.garden-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 11px 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: 600 14px/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.18s var(--ease);
}

/* Before the streak has loaded, the count keeps the width of one digit (no shift of the bar). */
.garden-chip > span:last-child:empty::before {
  content: "0";
  visibility: hidden;
}

.garden-chip .icon {
  font-size: 17px;
  color: var(--muted);
}

.garden-chip:hover {
  background: var(--surface-2);
}

.garden-chip:active {
  transform: scale(0.96);
}

/* Today is saved: the sprout is green and the chip glows softly. */
.garden-chip.done {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line-strong));
  background: color-mix(in srgb, var(--ok) 10%, var(--surface));
  color: var(--ink);
}

.garden-chip.done .icon {
  color: var(--ok);
}

/* The streak ends at midnight unless a quote is saved today: a pink pulse asks for it. */
.garden-chip.at-risk {
  position: relative;
  border-color: var(--accent);
  color: var(--ink);
}

.garden-chip.at-risk::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent-strong);
  animation: streak-pulse 1.6s var(--ease) infinite;
}

@keyframes streak-pulse {
  50% {
    box-shadow: 0 0 0 5px var(--ring);
  }
}

.meadow-dialog {
  width: min(560px, calc(100% - 32px));
}

.meadow-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px 24px 0;
}

.meadow-title {
  margin: 0;
  font-family: var(--font-read);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.meadow-streak {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.meadow-streak > .icon {
  font-size: 30px;
  color: var(--ok);
}

.meadow-streak.at-risk > .icon {
  color: var(--accent-ink);
}

.meadow-streak-number {
  font-family: var(--font-read);
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}

.meadow-streak strong {
  display: block;
  font-size: 15px;
}

.meadow-best,
.meadow-hint,
.meadow-status,
.herbarium-rarity {
  color: var(--muted);
  font-size: 13.5px;
}

.meadow-status {
  margin: -6px 0 0;
}

.meadow-savers,
.meadow-herbarium {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.meadow-heading {
  margin: 0;
  font-size: 14px;
  font-weight: 560;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--ink-2);
}

.meadow-hint {
  margin: 0;
}

.meadow-savers .btn {
  margin-top: 4px;
}

.herbarium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  width: 100%;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

/* A herbarium sheet: warm paper with the pressed specimen (drawn in garden-ui.js). */
.herbarium-item {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  text-align: center;
}

.herbarium-name {
  font-size: 13px;
  line-height: 1.25;
}

.herbarium-item.missing .herbarium-name {
  color: var(--muted);
  font-weight: 500;
}

.herbarium-item.rarity-very-rare:not(.missing) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.herbarium-item.rarity-legendary:not(.missing) {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, var(--surface));
}

@media (max-width: 640px) {
  .garden-chip {
    padding: 0 9px 0 7px;
  }
}

/* ---------- quote card (quote-card-ui.js) ---------- */

.card-dialog {
  width: min(900px, calc(100% - 32px));
}

.card-dialog form {
  display: grid;
  gap: 16px;
  padding: 22px 24px 0;
}

.card-title {
  margin: 0;
  font-family: var(--font-read);
  font-size: 24px;
  font-weight: 500;
}

/* The preview on a soft desk next to the options; under them on narrow screens. */
.card-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.card-preview {
  justify-self: center;
  width: 100%;
  max-width: 460px;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), 0 18px 40px -24px rgba(16, 36, 29, 0.45);
}

.card-preview[data-format="portrait"] {
  max-width: 380px;
}

.card-preview[data-format="story"] {
  max-width: 270px;
}

@media (max-width: 720px) {
  .card-body {
    grid-template-columns: 1fr;
  }

  .card-preview[data-format="story"] {
    max-width: 230px;
  }
}

.card-options {
  display: grid;
  gap: 16px;
}

.card-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.card-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.card-choice legend {
  width: 100%;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-choice label {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer;
}

.card-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.card-choice label:has(input:checked) {
  border-color: var(--brand-accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.card-choice label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Looks as little paper swatches with a line of "text" and a stroke of the marker. */
.card-looks label {
  gap: 8px;
  padding-inline-start: 6px;
}

.card-swatch {
  position: relative;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--swatch-bg);
  overflow: hidden;
}

.card-swatch::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(var(--swatch-mark), var(--swatch-mark)) 4px 11px / 11px 4px no-repeat,
    linear-gradient(var(--swatch-ink), var(--swatch-ink)) 4px 7px / 12px 2px no-repeat,
    linear-gradient(var(--swatch-ink), var(--swatch-ink)) 4px 12px / 9px 2px no-repeat;
}

.card-swatch[data-sheet]::before {
  inset: 4px 3px 3px;
  border-radius: 2px;
  background-color: var(--swatch-paper);
  background-position: 2px 7px, 2px 3px, 2px 8px;
  transform: rotate(-4deg);
}

.card-actions {
  flex-wrap: wrap;
}

/* ---------- shared shelves (shelves-ui.js) ---------- */

/* My library and the shared shelves as book spines standing on a wooden board. */
.shelf-bar {
  margin: -6px 0 22px;
}

.shelf-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-height: 58px;
  padding: 10px 6px 0;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 6px solid var(--shelf-board);
  box-shadow: 0 1px 0 var(--shelf-board-edge), 0 10px 12px -10px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
}

.spine {
  --spine-color: var(--spine-0);
  appearance: none;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  max-width: 230px;
  height: var(--spine-height, 42px);
  padding: 0 14px;
  border: 0;
  border-radius: 4px 4px 1px 1px;
  background-color: var(--spine-color);
  /* Two gilt bands near the top and bottom, and a rounded back. */
  background-image:
    linear-gradient(
      to bottom,
      transparent 6px,
      rgba(255, 255, 255, 0.28) 6px 7px,
      transparent 7px calc(100% - 8px),
      rgba(255, 255, 255, 0.28) calc(100% - 8px) calc(100% - 7px),
      transparent calc(100% - 7px)
    ),
    linear-gradient(to right, rgba(255, 255, 255, 0.12), transparent 30%, transparent 75%, rgba(0, 0, 0, 0.2));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  color: var(--spine-ink);
  font: 600 14px/1 var(--font-ui);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}

.spine-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spine-count {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* Hover pulls the book out a little; the open shelf stands out further. */
.spine:hover {
  transform: translateY(-3px);
}

.spine[aria-current="page"] {
  transform: translateY(-7px);
  box-shadow: 0 6px 10px -4px rgba(0, 0, 0, 0.35);
}

.spine-mine {
  --spine-color: var(--spine-mine);
  height: 46px;
}

.spine-0 { --spine-color: var(--spine-0); }
.spine-1 { --spine-color: var(--spine-1); }
.spine-2 { --spine-color: var(--spine-2); }
.spine-3 { --spine-color: var(--spine-3); }
.spine-4 { --spine-color: var(--spine-4); }
.spine-5 { --spine-color: var(--spine-5); }

/* Empty slots on the shelf: a new shelf, joining one. */
.spine-add,
.spine-join {
  height: 36px;
  border: 1.5px dashed var(--line-strong);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-weight: 550;
}

.spine-add:hover,
.spine-join:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.spine-add .icon {
  font-size: 15px;
}

.shelf-hidden {
  display: none !important;
}

.shelf-view {
  padding-bottom: 8px;
}

.shelf-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 3px double var(--line-strong);
}

.shelf-titles {
  flex: 1 1 260px;
  min-width: 0;
}

.shelf-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
}

.shelf-title {
  overflow-wrap: anywhere;
}

.shelf-people {
  display: inline-flex;
  align-items: center;
  padding: 2px 2px 2px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: pointer;
}

.shelf-avatar {
  --spine-color: var(--spine-0);
  width: 32px;
  height: 32px;
  margin-left: -8px;
  border: 2px solid var(--bg);
  background: var(--spine-color);
  color: var(--spine-ink);
  font: 600 12px/1 var(--font-ui);
  letter-spacing: 0.02em;
}

.shelf-more {
  background: var(--surface-3);
  color: var(--ink-2);
}

.shelf-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shelf-items {
  display: grid;
  gap: 12px;
}

.shelf-card {
  padding: 20px 22px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--surface-glow), var(--shadow-sm);
}

.shelf-quote {
  margin: 0 0 10px;
}

.shelf-source {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.shelf-meta {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.shelf-empty-note {
  margin: 0;
  color: var(--muted);
}

.btn.is-armed {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.share-menu {
  width: min(260px, calc(100vw - 48px));
}

.shelf-dialog {
  width: min(500px, calc(100% - 32px));
}

.shelf-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px 24px 0;
}

.shelf-dialog-title {
  margin: 0;
  font-family: var(--font-read);
  font-size: 24px;
  font-weight: 500;
}

.shelf-dialog-lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.shelf-dialog .field {
  display: grid;
  gap: 6px;
}

.copy-field {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.copy-field .field-label,
.copy-field .field-hint {
  grid-column: 1 / -1;
}

.shelf-invite {
  display: grid;
  gap: 12px;
}

.shelf-invite > .btn {
  justify-self: start;
}

.shelf-members-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf-member {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 8px;
}

.shelf-member-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.shelf-me,
.shelf-member-role {
  color: var(--muted);
  font-size: 13px;
}

.shelf-me {
  margin-left: 6px;
}

.shelf-pick {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.shelf-pick-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.shelf-pick-option:has(input:checked) {
  border-color: var(--brand-accent);
  background: var(--accent-soft);
}

.shelf-pick-spine {
  --spine-color: var(--spine-0);
  flex: none;
  width: 10px;
  height: 26px;
  border-radius: 2px;
  background: var(--spine-color);
}

@media (max-width: 640px) {
  .shelf-head {
    align-items: flex-start;
  }

  .spine {
    max-width: 170px;
    padding: 0 11px;
  }
}
