/* ---------- Study step 3: links, menus, outline, tags, search results ---------- */

/* ----- web + note links inside the page ----- */
.study-prose a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: text;
}

.study-note-link {
  display: inline-block;
  padding: 0 7px;
  line-height: 1.5;
  color: var(--green);
  background: rgba(61, 255, 180, 0.1);
  border: 1px solid rgba(61, 255, 180, 0.3);
  border-radius: 999px;
  cursor: pointer;
}

.study-note-link::before {
  content: "↗ ";
  opacity: 0.7;
}

.study-note-link:hover {
  background: rgba(61, 255, 180, 0.2);
}

.study-note-link.is-missing {
  color: var(--muted);
  background: transparent;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.2);
  text-decoration: line-through;
  cursor: default;
}

.ProseMirror-selectednode.study-note-link {
  outline: 2px solid var(--green);
}

/* ----- link popover ----- */
.study-linkpop {
  position: fixed;
  z-index: 1000;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.8), var(--card-shadow);
}

.study-linkpop[hidden] {
  display: none;
}

.study-linkpop input {
  width: 260px;
  max-width: 55vw;
  padding: 5px 8px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}

.study-linkpop input:focus {
  border-color: rgba(61, 255, 180, 0.5);
}

.study-linkpop button {
  padding: 4px 10px;
  font: inherit;
  font-size: 0.78rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.study-linkpop button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.study-linkpop .is-danger {
  color: var(--red);
}

/* ----- "/" and "[[" popup list ----- */
.study-pop {
  position: fixed;
  z-index: 1000;
  width: 280px;
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.8), var(--card-shadow);
}

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

.study-pop__row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
}

.study-pop__row.is-sel {
  background: rgba(61, 255, 180, 0.14);
}

.study-pop__title {
  font-size: 0.9rem;
  color: var(--text);
}

.study-pop__hint {
  font-size: 0.74rem;
  color: var(--muted);
}

/* ----- outline panel ----- */
.study-crumbrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-right: var(--space-4);
}

.study-crumbrow .study-crumbs {
  flex: 1;
  min-width: 0;
}

.study-outline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 3px 10px;
  font: inherit;
  font-size: 0.76rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.study-outline-toggle:hover,
.study-outline-toggle.is-active {
  color: var(--green);
  border-color: rgba(61, 255, 180, 0.4);
}

.study-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

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

.study-outline {
  flex: 0 0 240px;
  overflow-y: auto;
  padding: var(--space-3);
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.study-outline[hidden] {
  display: none;
}

.study-outline__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-2) 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.study-outline__list + .study-outline__head {
  margin-top: var(--space-5);
}

.study-outline__x {
  padding: 0 6px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.study-outline__item {
  display: block;
  width: 100%;
  padding: 4px 8px 4px calc(8px + var(--lv, 0) * 12px);
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 0.84rem;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.study-outline__item:hover {
  color: var(--green);
  background: rgba(255, 255, 255, 0.06);
}

.study-outline__empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ----- tags: chips under the title, list in the left panel ----- */
.study-tagbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--space-5);
}

.study-tagbar__chips {
  display: contents;
}

.study-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 4px 1px 9px;
  font-size: 0.8rem;
  color: var(--green);
  background: rgba(61, 255, 180, 0.1);
  border: 1px solid rgba(61, 255, 180, 0.3);
  border-radius: 999px;
}

.study-tag button {
  padding: 0 5px;
  font-size: 0.95rem;
  line-height: 1.3;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.study-tag button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.study-tagbar__input {
  width: 110px;
  padding: 2px 8px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: none;
  border: 1px dashed var(--border);
  border-radius: 999px;
  outline: none;
}

.study-tagbar__input:focus {
  border-color: rgba(61, 255, 180, 0.5);
}

.study-tags[hidden] {
  display: none;
}

.study-taglist {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 92px;
  overflow-y: auto;
}

.study-taglist__item {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Small × that appears on hover / keyboard focus: deletes the tag from all notes. */
.study-taglist__x {
  position: absolute;
  top: -5px;
  right: -4px;
  width: 15px;
  height: 15px;
  padding: 0;
  font-size: 0.8rem;
  line-height: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
}

.study-taglist__item:hover .study-taglist__x,
.study-taglist__x:focus-visible {
  opacity: 1;
}

.study-taglist__x:hover {
  color: var(--red);
  border-color: var(--red);
}

.study-taglist__tag {
  padding: 2px 9px;
  font: inherit;
  font-size: 0.76rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.study-taglist__tag span {
  color: var(--muted);
}

.study-taglist__tag:hover {
  border-color: rgba(61, 255, 180, 0.4);
}

.study-taglist__tag.is-active {
  color: #031a10;
  background: var(--green);
  border-color: var(--green);
}

.study-taglist__tag.is-active span {
  color: #031a10;
}

.study-sidebar__label {
  margin: 0 0 var(--space-2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ----- search / tag results in the tree ----- */
.st-result {
  align-items: flex-start;
  padding-top: 6px;
  padding-bottom: 6px;
}

.st-result .st-ico {
  margin: 3px 0 0 14px;
}

.st-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.st-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
}

.st-snippet mark {
  color: var(--text);
  background: rgba(61, 255, 180, 0.28);
  border-radius: 2px;
}

.st-filter {
  margin: 4px 6px 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.st-filter b {
  color: var(--green);
}

@media (max-width: 1099px) {
  .study-outline {
    flex-basis: 200px;
  }
}

@media (max-width: 760px) {
  .study-body {
    position: relative;
  }

  .study-outline {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    box-shadow: -12px 0 30px rgba(0, 0, 0, 0.6);
  }
}
