/* Page metadata chips above the page body. Uses the palette from markdown.css. */
.page-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
  margin: 0.5em auto 2em;
  font-family: var(--font-global);
  font-size: 0.95rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6em;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  height: 2em;
  padding: 0 0.55em;
  border: none;
  border-radius: 5px;
  background-color: var(--gray-2);
  color: var(--gray-5);
  font: inherit;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip .icon {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
}

/* Status: a segmented group of buttons */
.chip-group {
  display: inline-flex;
  margin: 0;
  border-radius: 5px;
  overflow: hidden;
}

.chip-group .chip {
  border-radius: 0;
  padding: 0 0.75em;
  cursor: pointer;
}

.chip-group .chip + .chip {
  border-left: 1px solid var(--gray-1);
}

/* Same colours as links to pages with that status (see markdown.css) */
.chip[data-status="OnHold"]     { --status-color: var(--blue-3); }
.chip[data-status="InProgress"] { --status-color: var(--yellow-3); }
.chip[data-status="Complete"]   { --status-color: var(--green-3); }

.chip-group .chip:hover {
  background-color: var(--gray-3);
  color: var(--status-color);
}

.chip-group .chip.active {
  background-color: var(--status-color);
  color: var(--gray-0);
  cursor: default;
}

.chip-group[aria-busy="true"] .chip {
  cursor: progress;
}

.chip-group .chip:focus-visible {
  outline: 2px solid var(--yellow-4);
  outline-offset: -2px;
}

/* Top navigation: page title and read/edit toggle */
.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  max-width: 960px;
  margin: 0 auto;
  padding: 0.5em 1em;
  font-family: var(--font-global);
}

.page-nav-title {
  color: var(--green-3);
  font-size: 1.4rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.page-nav-title:hover { text-decoration: underline; }

.page-nav-action {
  display: inline-flex;
  color: var(--green-3);
  padding: 0.25em;
  border-radius: 5px;
}

.page-nav-action:hover { background-color: var(--gray-2); }

.page-nav-action .icon {
  width: 1.6rem;
  height: 1.6rem;
}

/* Floating round edit button on the read page */
.page-fab {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background-color: var(--green-3);
  color: var(--gray-0);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.page-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.page-fab:focus-visible {
  outline: 2px solid var(--yellow-4);
  outline-offset: 3px;
}

.page-fab .icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* Keep the end of the page clear of the floating button */
.page-body { padding-bottom: 5rem; }
.page-body:has(+ .page-backlinks),
.page-body:has(+ .page-versions) { padding-bottom: 0; }

/* Pages linking here, below the page body */
.page-backlinks {
  max-width: var(--reading-width, 720px);
  margin: 0 auto;
  padding: 1em 0.5ch 6rem;
  border-top: 1px solid var(--gray-2);
  font-family: var(--font-global);
}

.page-backlinks h2 {
  display: flex;
  align-items: center;
  gap: 0.45em;
  margin: 0 0 0.6em;
  color: var(--gray-4);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.page-backlinks h2 .icon {
  width: 1.1em;
  height: 1.1em;
}

.page-backlinks ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-backlinks a {
  display: inline-block;
  max-width: 100%;
  padding: 0.3em 0.7em;
  border-radius: 5px;
  background-color: var(--gray-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.page-backlinks a:hover { background-color: var(--gray-2); }

/* Same colours as links to pages with that status (see markdown.css) */
.page-backlinks .color-OnHold a     { color: var(--blue-3); }
.page-backlinks .color-InProgress a { color: var(--yellow-3); }
.page-backlinks .color-Complete a   { color: var(--green-3); }

/* Version picker, at the very bottom; the padding clears the edit button */
.page-backlinks:has(+ .page-versions) { padding-bottom: 1em; }

.page-versions {
  max-width: var(--reading-width, 720px);
  margin: 0 auto;
  padding: 1em 0.5ch 6rem;
  border-top: 1px solid var(--gray-2);
  font-family: var(--font-global);
}

.page-versions summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.3em 0.6em;
  border-radius: 5px;
  color: var(--gray-5);
  cursor: pointer;
  list-style: none;
}

.page-versions summary::-webkit-details-marker { display: none; }

.page-versions summary:hover,
.page-versions details[open] > summary { background-color: var(--gray-2); }

.page-versions summary .icon {
  width: 1.1em;
  height: 1.1em;
  color: var(--gray-4);
}

.page-versions summary .icon-chevron-down { transition: transform 0.15s ease; }
.page-versions details[open] > summary .icon-chevron-down { transform: rotate(180deg); }

.page-versions ul {
  max-height: 20em;
  margin: 0.4em 0 0;
  padding: 0.3em;
  overflow-y: auto;
  border: 1px solid var(--gray-2);
  border-radius: 8px;
  background-color: var(--gray-1);
  list-style: none;
}

.page-versions li a {
  display: flex;
  align-items: baseline;
  gap: 1em;
  padding: 0.35em 0.6em;
  border-radius: 5px;
  color: var(--gray-6);
  text-decoration: none;
}

.page-versions li a:hover { background-color: var(--gray-2); }
.page-versions li a[aria-current="true"] { color: var(--green-3); }

.page-versions-number {
  min-width: 2.5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.page-versions-time {
  color: var(--gray-4);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.page-versions-auto {
  margin-left: auto;
  color: var(--gray-4);
  font-size: 0.8em;
}

/* Settings page */
.page-nav-spacer { width: 2.1rem; }

.settings {
  max-width: 640px;
  margin: 1em auto 4em;
  padding: 0 1em;
  font-family: var(--font-global);
}

.settings-note {
  margin: 0 0 1.5em;
  color: var(--gray-4);
  font-size: 0.95rem;
}

.settings fieldset {
  margin: 0 0 1.5em;
  padding: 0.5em 1em 1em;
  border: 1px solid var(--gray-2);
  border-radius: 8px;
}

.settings legend {
  padding: 0 0.4em;
  color: var(--yellow-3);
}

.settings-field {
  display: grid;
  grid-template-columns: 8em 1fr;
  align-items: center;
  gap: 1em;
  padding: 0.4em 0;
}

.settings-unit {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: var(--gray-4);
}

.settings input[type="text"],
.settings input[type="number"] {
  box-sizing: border-box;
  height: 2.2em;
  padding: 0 0.6em;
  border: 1px solid var(--gray-2);
  border-radius: 5px;
  background-color: var(--gray-1);
  color: var(--gray-6);
  font: inherit;
}

.settings input[type="text"] { width: 100%; }
.settings input[type="number"] { width: 6em; }

.settings input:focus-visible,
.settings-button:focus-visible {
  outline: 2px solid var(--yellow-4);
  outline-offset: 1px;
}

.settings input:invalid { border-color: var(--red-3); }

.settings-check {
  display: flex;
  align-items: flex-start;
  gap: 0.7em;
  padding: 0.5em 0;
  cursor: pointer;
}

.settings-check input {
  width: 1.1em;
  height: 1.1em;
  margin: 0.15em 0 0;
  accent-color: var(--green-3);
}

.settings-check small {
  display: block;
  margin-top: 0.2em;
  color: var(--gray-4);
}

.settings-preview {
  margin: 0 auto 1.5em;
  padding: 0.5em 1em;
  border: 1px dashed var(--gray-2);
  border-radius: 8px;
}

.settings-preview h2 { margin-top: 0.3em; }

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
}

.settings-button {
  display: inline-flex;
  align-items: center;
  height: 2.4em;
  padding: 0 1.1em;
  border: none;
  border-radius: 5px;
  background-color: var(--gray-2);
  color: var(--gray-6);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.settings-button:hover { background-color: var(--gray-3); }

.settings-button.primary {
  background-color: var(--green-3);
  color: var(--gray-0);
}

.settings-button.primary:hover { background-color: var(--green-4); }

@media (max-width: 480px) {
  .settings-field { grid-template-columns: 1fr; gap: 0.3em; }
}

.settings-main { margin-bottom: 1.5em; }

.settings-account-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
  padding: 0.3em 0;
}

.settings-account-name small,
.settings-account-note {
  display: block;
  color: var(--gray-4);
}

.settings-account-row form { margin: 0; }

.settings-button .icon {
  width: 1.1em;
  height: 1.1em;
  margin-right: 0.45em;
}

/* Login page */
.auth {
  display: flex;
  justify-content: center;
  padding: 12vh 1em 2em;
  font-family: var(--font-global);
}

.auth-card {
  width: 100%;
  max-width: 340px;
  padding: 1.8em 1.6em;
  border: 1px solid var(--gray-2);
  border-radius: 10px;
  background-color: var(--gray-1);
}

.auth-title {
  margin: 0 0 1em;
  color: var(--green-3);
  font-size: 1.8rem;
  font-weight: 600;
  text-align: center;
}

.auth-error {
  margin: 0 0 1em;
  padding: 0.6em 0.8em;
  border-radius: 5px;
  background-color: var(--red-1);
  color: var(--red-5);
}

.auth-lead {
  margin: 0;
  color: var(--gray-5);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  color: var(--gray-5);
}

.auth-field input {
  box-sizing: border-box;
  height: 2.4em;
  padding: 0 0.7em;
  border: 1px solid var(--gray-2);
  border-radius: 5px;
  background-color: var(--gray-0);
  color: var(--gray-6);
  font: inherit;
}

.auth-field input:focus-visible,
.auth-link:focus-visible {
  outline: 2px solid var(--yellow-4);
  outline-offset: 1px;
}

.auth-form .settings-button { justify-content: center; }

.auth-link {
  color: var(--gray-4);
  text-align: center;
}

/* Default status on the settings page: radio buttons styled as the status chips */
.settings-status { justify-self: start; }

.settings-status .chip { gap: 0.45em; }

.settings-status input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-status .chip:has(input:checked) {
  background-color: var(--status-color);
  color: var(--gray-0);
  cursor: default;
}

.settings-status .chip:has(input:focus-visible) {
  outline: 2px solid var(--yellow-4);
  outline-offset: -2px;
}

.settings-hint {
  display: block;
  margin-top: 0.3em;
  color: var(--gray-4);
}

/* Wiki switcher: the wiki title, top left, opens a list of the user's wikis */
.page-nav-start {
  display: flex;
  align-items: center;
  gap: 0.6em;
  min-width: 0;
}

.wiki-switcher {
  position: relative;
  flex-shrink: 0;
}

.wiki-switcher > summary {
  list-style: none;
  cursor: pointer;
}

.wiki-switcher > summary::-webkit-details-marker { display: none; }

.wiki-switcher-title {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  max-width: 14em;
  padding: 0.2em 0.35em 0.2em 0.5em;
  border-radius: 5px;
  color: var(--gray-5);
  font-size: 1.1rem;
}

.wiki-switcher-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wiki-switcher-title .icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  color: var(--gray-4);
  transition: transform 0.15s ease;
}

.wiki-switcher-title:hover,
.wiki-switcher[open] > .wiki-switcher-title { background-color: var(--gray-2); }

.wiki-switcher[open] > .wiki-switcher-title .icon { transform: rotate(180deg); }

.wiki-switcher > summary:focus-visible {
  outline: 2px solid var(--yellow-4);
  outline-offset: 1px;
}

.wiki-menu {
  position: absolute;
  top: calc(100% + 0.4em);
  left: 0;
  z-index: 20;
  min-width: min(20em, calc(100vw - 2em));
  max-width: min(28em, calc(100vw - 2em));
  padding: 0.4em;
  border: 1px solid var(--gray-2);
  border-radius: 8px;
  background-color: var(--gray-1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.wiki-menu-label {
  margin: 0.2em 0.6em 0.4em;
  color: var(--gray-4);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wiki-menu-row {
  display: flex;
  align-items: stretch;
  gap: 0.2em;
}

.wiki-menu-row .wiki-menu-item {
  flex: 1;
  min-width: 0;
}

/* Link to the wiki's page tree, beside its name */
.wiki-menu-tree {
  display: flex;
  align-items: center;
  padding: 0 0.5em;
  border-radius: 5px;
  color: var(--gray-4);
}

.wiki-menu-tree:hover,
.wiki-menu-tree:focus-visible {
  background-color: var(--gray-2);
  color: var(--green-3);
  outline: none;
}

.wiki-menu-tree .icon {
  width: 1.1em;
  height: 1.1em;
}

.wiki-menu-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  padding: 0.5em 0.6em;
  border-radius: 5px;
  color: var(--gray-6);
  text-decoration: none;
}

.wiki-menu-item:hover,
.wiki-menu-item:focus-visible {
  background-color: var(--gray-2);
  outline: none;
}

.wiki-menu-item[aria-current="true"] { color: var(--green-3); }

.wiki-menu-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wiki-menu-key {
  color: var(--gray-4);
  font-size: 0.85em;
}

.wiki-menu-new {
  justify-content: flex-start;
  align-items: center;
  gap: 0.5em;
  margin-top: 0.3em;
  border-top: 1px solid var(--gray-2);
  border-radius: 0 0 5px 5px;
  color: var(--gray-5);
}

.wiki-menu-new .icon {
  width: 1em;
  height: 1em;
}

.auth-detail {
  margin: 0 0 1em;
  color: var(--gray-4);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.settings select {
  box-sizing: border-box;
  height: 2.2em;
  padding: 0 0.6em;
  border: 1px solid var(--gray-2);
  border-radius: 5px;
  background-color: var(--gray-1);
  color: var(--gray-6);
  font: inherit;
  justify-self: start;
}

.settings select:focus-visible {
  outline: 2px solid var(--yellow-4);
  outline-offset: 1px;
}

/* Tag pills on the read page link to the tag page */
a.chip-link {
  text-decoration: none;
  cursor: pointer;
}

a.chip-link:hover { background-color: var(--gray-3); color: var(--gray-6); }

a.chip-link:focus-visible {
  outline: 2px solid var(--yellow-4);
  outline-offset: 1px;
}

.page-nav-title .icon {
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.35em;
  vertical-align: -0.05em;
}

/* Tag page: the pages with a tag, grouped by wiki */
.tag-page {
  max-width: var(--reading-width, 720px);
  margin: 0.5em auto 4em;
  padding: 0 0.5ch;
  font-family: var(--font-global);
}

.tag-summary {
  margin: 0 0 1.5em;
  color: var(--gray-4);
}

.tag-group {
  margin: 0 0 1em;
  padding: 0.8em 1em 1em;
  border: 1px solid var(--gray-2);
  border-radius: 8px;
  scroll-margin-top: 1em;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

/* The wiki the tag was opened from (the #wiki-key in the URL) */
.tag-group:target {
  border-color: var(--green-3);
  background-color: color-mix(in srgb, var(--green-3) 6%, transparent);
}

.tag-group h2 {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  margin: 0 0 0.7em;
  font-size: 1.05rem;
  font-weight: 600;
}

.tag-group h2 a {
  color: var(--gray-6);
  text-decoration: none;
}

.tag-group h2 a:hover { text-decoration: underline; }

.tag-group-count {
  color: var(--gray-4);
  font-size: 0.85em;
  font-weight: 400;
}

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

.title-tree .title-tree {
  margin-left: 1.2em;
  padding-left: 0.6em;
  border-left: 1px solid var(--gray-2);
}

.title-tree li a {
  display: inline-block;
  max-width: 100%;
  margin: 0.15em 0;
  padding: 0.2em 0.6em;
  border-radius: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
  text-decoration: none;
}

.title-tree li a:hover { background-color: var(--gray-1); }

/* Parents only there to hold the listed child pages */
.title-tree .tree-parent > a {
  color: var(--gray-6);
  opacity: 0.45;
}

.title-tree .tree-parent > a:hover { opacity: 0.8; }

.title-tree .color-NotFound > a   { color: var(--red-2); }
.title-tree .color-OnHold > a     { color: var(--blue-3); }
.title-tree .color-InProgress > a { color: var(--yellow-3); }
.title-tree .color-Complete > a   { color: var(--green-3); }

/* Shown when reading a version other than the newest */
.page-old-version {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4em 0.6em;
  max-width: var(--reading-width, 720px);
  margin: 0.5em auto 0;
  padding: 0.6em 1em;
  border-radius: 5px;
  background-color: var(--gray-2);
  color: var(--gray-5);
  font-family: var(--font-global);
  font-size: 0.9rem;
  text-align: center;
}

.page-old-version .icon {
  flex: none;
  width: 1.1em;
  height: 1.1em;
  color: var(--yellow-3);
}

.page-old-version a {
  color: var(--green-3);
  font-weight: 600;
}
