/* Team filter banner, color coding, dialogs and the vault. Loaded after admin.css. */

.hq-top .chips {
  flex-shrink: 0;
}

.schema-banner {
  margin: 0;
  padding: 10px var(--gutter);
  background: #2b2308;
  border-bottom: 1px solid #5c4a10;
  color: #f1dc8c;
  font-size: 15px;
}

/* ---------- Color coding ---------- */

.task {
  border-left: 4px solid var(--task-color, var(--line));
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch, transparent);
  background-clip: padding-box;
  cursor: pointer;
}

.swatch-none {
  width: auto;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font: 600 12px/1 var(--f-body);
}

.swatch[aria-pressed='true'] {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg);
}

.swatch-none[aria-pressed='true'] {
  background: rgba(139, 198, 65, 0.14);
  color: var(--lime-hi);
}

.project-colors {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.project-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.project-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.project-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--swatch);
}

.project-add {
  display: flex;
  gap: 8px;
}

/* ---------- General dialog ---------- */

.hq-modal {
  width: min(100% - 32px, 460px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.hq-modal-wide {
  width: min(100% - 32px, 820px);
}

.hq-modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
}

.hq-modal > header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px 4px;
}

.hq-modal h2 {
  margin: 0;
  font: 700 1.5rem/1.05 var(--f-display);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.hq-modal-body {
  padding: 10px 24px;
}

.hq-modal-body p {
  margin: 0 0 10px;
}

.hq-modal > footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 24px 20px;
}

/* ---------- Vault layout ---------- */

.vault {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  height: calc(100vh - 60px);
}

.vault-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
}

.vault-actions {
  display: flex;
  gap: 8px;
}

.vault-actions .btn {
  flex: 1;
  padding: 0 8px;
}

.note-search {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 15px;
}

/* ---------- Tree ---------- */

.note-tree {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tree-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree-list .tree-list {
  margin-left: 10px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.tree-row {
  display: flex;
  align-items: center;
}

.tree-folder,
.tree-file {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: 500 15px/1.25 var(--f-body);
  text-align: left;
  cursor: pointer;
}

.tree-folder {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--muted);
}

.tree-file {
  flex-wrap: wrap;
}

.tree-folder:hover,
.tree-file:hover {
  background: rgba(139, 198, 65, 0.08);
}

.tree-file.current {
  background: rgba(139, 198, 65, 0.16);
  color: var(--lime-hi);
}

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

.tree-sub {
  flex-basis: 100%;
  overflow: hidden;
  color: var(--dim);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-caret {
  width: 12px;
  color: var(--dim);
  font-size: 12px;
}

.tree-add {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--dim);
  font-size: 17px;
  cursor: pointer;
}

.tree-add:hover {
  background: rgba(139, 198, 65, 0.12);
  color: var(--lime);
}

.tree-empty {
  padding: 16px 8px;
  color: var(--dim);
  font-size: 14px;
}

.dirty-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--lime-hi);
}

/* ---------- Note pane ---------- */

.vault-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.vault-empty {
  margin: auto;
  padding: 24px;
  text-align: center;
}

.vault-empty h1 {
  margin: 0 0 8px;
  font: 700 2rem/1 var(--f-display);
  text-transform: uppercase;
}

.note-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.note-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.note-back {
  display: none;
}

.note-heading {
  min-width: 0;
  flex: 1 1 220px;
}

.note-heading h1 {
  margin: 0;
  font: 700 1.6rem/1.1 var(--f-display);
  overflow-wrap: anywhere;
}

.note-meta {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.note-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.note-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 18px;
  background: #2b2308;
  border-bottom: 1px solid #5c4a10;
  color: #f1dc8c;
  font-size: 15px;
}

.note-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.note-body.mode-edit,
.note-body.mode-preview {
  grid-template-columns: minmax(0, 1fr);
}

.mode-edit .note-preview,
.mode-preview .note-editor {
  display: none;
}

.note-editor {
  height: 100%;
  min-height: 0;
  padding: 18px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  font: 500 14.5px/1.65 var(--f-mono);
  resize: none;
}

.note-editor:focus {
  border-color: var(--line);
  box-shadow: none;
}

.note-preview {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 26px 40px;
}

.backlinks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
}

.backlinks:empty {
  display: none;
}

.backlinks h2 {
  margin: 0;
  padding: 9px 0;
  color: var(--muted);
  font: 600 13px/1 var(--f-body);
}

.backlink {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--lime);
  font: 500 13px/1.2 var(--f-body);
  cursor: pointer;
}

/* ---------- Rendered Markdown ---------- */

.md {
  color: #d6dfca;
  font-size: 16.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.md > :first-child {
  margin-top: 0;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 1.3em 0 0.4em;
  color: var(--text);
  font-family: var(--f-display);
  line-height: 1.15;
}

.md h1 {
  font-size: 1.9rem;
}

.md h2 {
  font-size: 1.5rem;
}

.md h3 {
  font-size: 1.25rem;
}

.md p,
.md ul,
.md ol,
.md blockquote,
.md pre,
.md table {
  margin: 0 0 0.9em;
}

.md ul,
.md ol {
  padding-left: 1.4em;
}

.md li:has(> input[type='checkbox']) {
  list-style: none;
  margin-left: -1.2em;
}

.md input[type='checkbox'] {
  width: auto;
  min-height: 0;
}

.md blockquote {
  padding: 2px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}

.md code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--lime-hi);
  font: 500 0.88em var(--f-mono);
}

.md pre {
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}

.md pre code {
  padding: 0;
  background: none;
  color: var(--text);
}

.md table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

.md th,
.md td {
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.md img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

.md a.wikilink {
  color: var(--lime);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
}

.md a.wikilink.missing {
  color: var(--dim);
  border-bottom-style: dashed;
}

/* ---------- History ---------- */

.version-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 12px;
  height: min(60vh, 520px);
}

.version-list {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
}

.version {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: 400 13px/1.3 var(--f-body);
  text-align: left;
  cursor: pointer;
}

.version[aria-pressed='true'] {
  border-color: var(--lime);
  background: rgba(139, 198, 65, 0.12);
}

.version-view {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  font: 500 13.5px/1.55 var(--f-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Phones ---------- */

@media (max-width: 760px) {
  .vault {
    display: block;
    height: auto;
  }

  .vault-side {
    min-height: calc(100vh - 120px);
    border-right: 0;
  }

  .vault-main {
    display: none;
  }

  .vault.note-open .vault-side {
    display: none;
  }

  .vault.note-open .vault-main {
    display: flex;
  }

  .note-back {
    display: inline-flex;
  }

  .note-body,
  .note-body.mode-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .note-editor {
    height: 55vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .version-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .version-list {
    max-height: 170px;
  }

  .version-view {
    max-height: 45vh;
  }
}
