/* Right rail: outline, files, tags, backlinks, history and metadata of the open note. */
.rightrail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-1);
  border-left: 1px solid var(--line);
}

.rr-tabs {
  display: flex;
  gap: var(--sp-1);
  height: var(--topbar-h);
  align-items: center;
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.rr-tab {
  height: 28px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-weight: 500;
}

.rr-tab:hover {
  color: var(--text);
}

.rr-tab[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text);
}

.rr-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-5) var(--sp-7);
}

.rr-section + .rr-section {
  margin-top: var(--sp-7);
}

.rr-section h3 {
  margin-bottom: var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rr-list {
  display: grid;
  gap: var(--sp-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.rr-list a,
.rr-list button {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 26px;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-align: left;
}

.rr-list a:hover,
.rr-list button:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.outline-h2 {
  padding-left: 18px !important;
}

.outline-h3 {
  padding-left: 30px !important;
}

.rr-empty {
  color: var(--text-3);
}

.meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-3) var(--sp-5);
  margin: 0;
  color: var(--text-2);
}

.meta-grid dt {
  color: var(--text-3);
}

.meta-grid dd {
  margin: 0;
}

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

.rr-list .i {
  flex: none;
  color: var(--ic, var(--text-3));
}

.history button {
  justify-content: space-between;
  padding-block: var(--sp-3);
}

.hist-main {
  display: grid;
  gap: 2px;
}

.hist-main small,
.hist-size {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.version-preview {
  max-height: 55vh;
  margin: 0;
  padding: var(--sp-5);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  font: var(--fs-sm) / 1.6 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--sp-4);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ic, var(--text-3)) 16%, transparent);
  color: var(--ic, var(--text-2));
  font-size: var(--fs-sm);
  font-weight: 500;
}

.tag .tag-x {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin: 0 calc(var(--sp-2) * -1) 0 var(--sp-1);
  border-radius: 50%;
  color: inherit;
  opacity: 0.7;
}

.tag .tag-x:hover {
  background: color-mix(in srgb, var(--ic, var(--text-3)) 25%, transparent);
  opacity: 1;
}

.tag .tag-x .i {
  width: 11px;
  height: 11px;
}

.tag-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--ic, var(--text-3));
}

.archived-item .input {
  flex: 1;
}

.archived-item .meta {
  min-width: 3ch;
  text-align: right;
}

/* outline drag: where the section will land */
.outline button[data-drop="before"] {
  box-shadow: inset 0 2px 0 var(--accent);
}

.outline button[data-drop="after"] {
  box-shadow: inset 0 -2px 0 var(--accent);
}
