/* ============================================================================
   My Lists pages
   ============================================================================ */
.lists-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.lists-header-left  { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.lists-header-right { display: flex; align-items: center; gap: 0.5rem; }
.lists-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--c-text-main);
}
.lists-title--brand { color: var(--c-brand); }
.lists-title-star { color: var(--c-brand); flex-shrink: 0; }
.lists-back {
  font-size: 0.85rem;
  color: var(--c-link);
  text-decoration: none;
  white-space: nowrap;
}
.lists-back:hover { text-decoration: underline; }
.lists-count { font-size: 0.85rem; color: var(--c-text-muted); margin-bottom: 1rem; }
.lists-empty { color: var(--c-text-muted); font-style: italic; margin-top: 2rem; }

.btn-new-list {
  background: var(--c-link);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn-new-list:hover { background: var(--c-link-dark); }

.btn-secondary {
  background: var(--c-bg-gray);
  color: var(--c-text-main);
  border: 1px solid var(--c-border);
  border-radius: 5px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { border-color: var(--c-link); color: var(--c-link); }

.btn-danger {
  background: none;
  color: #c0392b;
  border: 1px solid #c0392b;
  border-radius: 5px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.btn-danger:hover { background: #c0392b; color: #fff; }

/* List cards grid */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.list-card {
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 1rem;
  position: relative;
}
.list-card:hover { border-color: var(--c-link); }
.list-card-link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--c-text-main);
  padding-bottom: 0.5rem;
}
.list-card-star { color: var(--c-brand); }
.list-card-name { font-weight: 600; font-size: 0.95rem; }
.list-card-count { font-size: 0.75rem; color: var(--c-text-muted); }
.list-card-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-top: 0.4rem;
}
.list-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-muted);
  padding: 0.2rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}
.list-action-btn:hover { color: var(--c-link); background: var(--c-bg-gray); }
.list-action-btn--danger:hover { color: #c0392b; background: var(--c-bg-gray); }

/* Mobile: single column for lists grid */
@media (max-width: 480px) {
  .lists-grid { grid-template-columns: 1fr; }
}

/* Authors page */
.sort-bar { margin-bottom: 1.2rem; font-size: 0.9rem; color: var(--c-text-sub, #666); }
.sort-bar a { margin-left: 0.5rem; }
.sort-bar .active { font-weight: 700; color: var(--c-text); text-decoration: none; }

.author-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 2rem;
}
@media (max-width: 700px) {
  .author-columns { grid-template-columns: 1fr; }
}

.author-list { list-style: none; margin: 0; padding: 0; }
.author-list li {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--c-border-light, #eee);
  font-size: 0.9rem;
}
.author-list li a { color: var(--c-link); text-decoration: none; }
.author-list li a:hover { text-decoration: underline; }
.paper-count {
  font-size: 0.78rem; color: var(--c-text-sub, #888);
  white-space: nowrap; margin-left: 0.4rem;
}

/* Keyword tags */
.kw-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin: 0.15rem 0.2rem 0.15rem 0;
  font-size: 0.78rem;
  border-radius: 3px;
  background: var(--c-bg-gray, #f0f0f0);
  color: var(--c-link, #0066cc);
  border: 1px solid var(--c-border, #ddd);
  text-decoration: none;
  white-space: nowrap;
}
.kw-tag:hover {
  background: var(--c-link, #0066cc);
  color: #fff;
  border-color: var(--c-link, #0066cc);
}
.kw-tag--small {
  font-size: 0.68rem;
  padding: 0.1rem 0.35rem;
}
.kw-tag--cat {
  font-family: monospace;
  font-size: 0.78rem;
  background: var(--c-bg-alt, #f0f4f8);
  border-color: #9cb0c8;
  color: #3a6080;
}
.kw-tag--cat:hover {
  background: #3a6080;
  border-color: #3a6080;
  color: #fff;
}
/* kw-tag with info button (keyword has an associated URL) */
.kw-tag--has-info {
  display: inline-flex;
  align-items: center;
  padding: 0;
}
.kw-tag--has-info .kw-tag__link {
  padding: 0.15rem 0.2rem 0.15rem 0.5rem;
  color: inherit;
  text-decoration: none;
}
.kw-tag--has-info.kw-tag--small .kw-tag__link {
  padding: 0.1rem 0.15rem 0.1rem 0.35rem;
}
.kw-tag__info {
  display: inline-flex;
  align-items: center;
  padding: 0 0.4rem 0 0.1rem;
  color: inherit;
  text-decoration: none;
  opacity: 0.5;
  line-height: 1;
  position: relative;
  transition: opacity 0.1s;
}
.kw-tag--has-info:hover .kw-tag__info { opacity: 1; }

.kw-tag__info[data-sf-preview]::after,
.page-title__link[data-sf-preview]::after {
  content: attr(data-sf-preview);
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 0.35rem);
  left: 50%;
  width: max-content;
  max-width: min(20rem, 80vw);
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  background: var(--c-bg-surface);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
  color: var(--c-text-main);
  font-size: 0.72rem;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.2rem);
  transition: opacity 0.12s, transform 0.12s;
  white-space: normal;
}

.kw-tag__info[data-sf-preview]:hover::after,
.kw-tag__info[data-sf-preview]:focus-visible::after,
.page-title__link[data-sf-preview]:hover::after,
.page-title__link[data-sf-preview]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Watched keyword highlight */
.kw-tag--watched {
  border-color: var(--c-brand);
  color: var(--c-brand);
  font-weight: 500;
}
.kw-tag--watched:hover {
  background: var(--c-brand);
  border-color: var(--c-brand);
  color: #fff;
}

/* Watched author: bold + brand colour */
.paper-authors a.watched-author {
  font-weight: 600;
  color: var(--c-paper-watch);
}
.paper-authors a.watched-author:hover { color: var(--c-paper-watch); }

.paper-kw-tags--list {
  margin-top: 0.5rem;
  line-height: 1.8;
}

.search-match-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.1rem 0 0.2rem;
}

.search-match-chip {
  border: 1px solid var(--c-border);
  border-radius: 999px;
  color: var(--c-text-muted);
  font-size: 0.68rem;
  line-height: 1.2;
  padding: 0.08rem 0.45rem;
}

.search-hit {
  background: #fff3a3;
  border-radius: 2px;
  color: inherit;
  padding: 0 0.08em;
}

:root.dark .search-hit {
  background: hsl(49, 52%, 28%);
}

:root.compact-papers .search-match-line {
  margin: 0.02rem 0 0.08rem;
}

@media (max-width: 768px) {
  :root.compact-papers .paper {
    padding: 0.55rem 0.7rem;
  }

  :root.compact-papers .paper-authors {
    margin-bottom: 0;
  }

  :root.compact-papers .paper-links a,
  :root.compact-papers .paper-icon-btn {
    min-height: 2.35rem;
    min-width: 2rem;
  }

  :root.compact-papers .paper-links .bullet {
    line-height: 2.35rem;
  }

  :root.compact-papers summary.paper-title {
    font-size: 0.94rem;
  }
}

/* Contextual override: author lists and calendar cells both use paper counts. */
.calendar-day .paper-count {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--c-text-main);
  line-height: 1;
  font-family: system-ui, sans-serif;
  margin-left: 0;
}

@media (max-width: 768px) {
  .calendar-day .paper-count {
    font-size: 1.1rem;
  }
}

/* Watch controls */
.watch-btn {
  background: none;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  color: var(--c-text-sub);
  cursor: pointer;
  font-size: 0.85em;
  padding: 2px 10px;
  vertical-align: middle;
}

.watch-btn:hover {
  color: var(--c-link);
  border-color: var(--c-link);
}

.watch-btn.watching {
  background: var(--c-link);
  color: #fff;
  border-color: var(--c-link);
}

.watch-section {
  margin-top: 2rem;
}

.watch-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-sub);
}

.watch-section-title--spaced {
  margin-top: 1.2rem;
}

.watch-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.watch-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--c-bg-alt);
  border-radius: 999px;
  padding: 0.2rem 0.7rem 0.2rem 0.3rem;
  font-size: 0.85rem;
}

.watch-pill a {
  color: var(--c-link);
  text-decoration: none;
}

.watch-pill a:hover {
  text-decoration: underline;
}

.watch-pill-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--c-text-sub);
  padding: 0 0.1rem;
  border-radius: 50%;
}

.watch-pill-remove:hover {
  color: var(--c-danger);
}

.feed-watch-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.feed-watch-keyword {
  margin-top: 0.3rem;
}

.btn-load-more {
  display: inline-block;
  padding: 0.4rem 1.4rem;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  color: var(--c-link);
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-load-more:hover {
  background: var(--c-bg-alt);
  color: var(--c-link);
  text-decoration: none;
}

/* Login page */
.login-box {
  max-width: 620px;
  margin: 3rem auto;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 0.4rem;
}

.login-box p {
  color: var(--c-muted);
  font-size: 0.92rem;
  margin-bottom: 2rem;
}

.orcid-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 1.4rem;
  background: #a6ce39;
  color: #000;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.orcid-btn:hover {
  background: #8fb82e;
  color: #000;
  text-decoration: none;
}

.orcid-btn svg {
  width: 1.4em;
  height: 1.4em;
}

.login-features {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  text-align: left;
  display: inline-block;
}

.login-features li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.92rem;
  color: var(--c-text-main);
}

.login-features li svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  color: var(--c-link);
}

.login-note {
  margin-top: 1.8rem;
  font-size: 0.8rem;
  color: var(--c-muted);
  line-height: 1.5;
}

.login-box p.login-note--muted {
  margin-top: 0.8rem;
  color: var(--c-text-muted);
}

.login-unavailable {
  color: var(--c-muted);
}

/* Keyword pages */
.kw-cloud {
  line-height: 2.4;
  word-spacing: 0.1rem;
  margin-top: 1rem;
}

.admin-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.3rem;
  padding-bottom: 0.05rem;
}

.admin-kw-strip {
  margin: 1rem 0 1.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--c-border);
  border-radius: 5px;
  background: var(--c-bg-header);
  font-size: 0.88rem;
}

.admin-kw-strip__label {
  margin-bottom: 0.6rem;
  color: var(--c-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-kw-strip__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  align-items: flex-end;
}

.admin-kw-strip__fields label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--c-text-muted);
}

.akw-score-input {
  width: 3.2em;
  text-align: center;
  padding: 0.15rem 0.2rem;
  border: 1px solid var(--c-border);
  border-radius: 3px;
  background: var(--c-bg-surface);
  color: var(--c-text-main);
  font-size: 0.85rem;
}

.inline-edit {
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-family: inherit;
  color: inherit;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  outline: none;
}

.inline-edit:hover {
  background: var(--c-bg-alt);
}

.inline-edit:focus {
  background: var(--c-bg-surface);
  outline: 1px solid var(--c-link);
}

.inline-edit.saved {
  outline: 2px solid #4a4 !important;
}

.inline-edit.error {
  outline: 2px solid #c44 !important;
}

.akw-url-field {
  min-width: 14rem;
}

.alias-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.alias-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--c-border);
  border-radius: 99px;
  background: var(--c-bg-alt);
  font-family: monospace;
  font-size: 0.78rem;
}

.alias-chip button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--c-text-muted);
  font-size: 0.9rem;
  line-height: 1;
}

.alias-chip button:hover {
  color: var(--c-danger);
}

.alias-add-btn {
  background: none;
  border: 1px dashed var(--c-border);
  border-radius: 99px;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

.alias-add-btn:hover {
  border-color: var(--c-link);
  color: var(--c-link);
}

.merge-btn {
  border-color: #c9aaec;
  color: #7a3ab5;
}

.merge-btn:hover {
  border-color: #7a3ab5;
  color: #5a1a8a;
}

.alias-add-input {
  display: none;
  width: 130px;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--c-link);
  border-radius: 3px;
  background: var(--c-bg-surface);
  color: var(--c-text);
  font-family: monospace;
  font-size: 0.8rem;
}

.btn-retag {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--c-text-sub);
  padding: 0 3px;
  vertical-align: middle;
  transition: color 0.15s;
}

.btn-retag:hover {
  color: var(--c-link);
}

.btn-retag:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-trash {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  color: var(--c-muted);
  line-height: 1;
}

.btn-trash:hover {
  color: var(--c-danger);
}

.btn-trash svg {
  width: 1rem;
  height: 1rem;
  vertical-align: middle;
}

.sc-panel {
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: var(--c-bg-alt);
}

.sc-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.sc-panel-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--c-border);
}

.sc-panel-item:last-child {
  border-bottom: none;
}

.sc-panel-phrase {
  font-weight: 600;
  min-width: 10rem;
}

.sc-sug {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.admin-kw-strip .sc-sug {
  margin-top: 0.25rem;
}

.sc-sug-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  color: var(--c-text-sub);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
}

.sc-sug-btn:hover {
  border-color: var(--c-link);
  color: var(--c-link);
}

.sc-sug-btn--exact-key {
  background: #eaf7ef;
  border-color: #6bb98a;
  background: color-mix(in srgb, var(--c-link) 10%, var(--c-bg-surface));
  border-color: color-mix(in srgb, var(--c-link) 55%, var(--c-border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-link) 22%, transparent);
  color: var(--c-text-main);
  font-weight: 600;
}

.sc-sug-btn .sc-sug-match {
  font-size: 0.7rem;
  color: var(--c-text-muted);
}

.sc-sug-applied {
  font-size: 0.78rem;
  color: #4a4;
  font-weight: 600;
}
