:root {
  color-scheme: light dark;
  --paper: light-dark(oklch(98% 0.009 250), oklch(20% 0.015 250));
  --chalk: light-dark(oklch(100% 0 0), oklch(24% 0.018 250));
  --graphite: light-dark(oklch(24% 0.025 250), oklch(94% 0.009 250));
  --slate: light-dark(oklch(43% 0.035 250), oklch(77% 0.025 250));
  --line: light-dark(oklch(87% 0.018 250), oklch(39% 0.022 250));
  /* Control borders are the only outline of empty fields, so they keep 3:1 against chalk and paper. */
  --control: light-dark(oklch(62% 0.02 250), oklch(56% 0.02 250));
  --ink: light-dark(oklch(40% 0.11 255), oklch(80% 0.09 250));
  --selection: light-dark(oklch(94% 0.026 252), oklch(31% 0.058 250));
  --backdrop: oklch(25% 0.03 255 / 50%);
  --step: 0.5rem;
  --jump-size: 2.75rem;
  --jump-gap: 0.25rem;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--graphite);
  font:
    1rem/1.5 'Segoe UI',
    sans-serif;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--chalk);
  padding: 0.45rem 0.65rem;
}
/* Buttons are identified by their labels; fields and pickers rely on their border alone. */
input,
select,
textarea,
.filters button {
  border-color: var(--control);
}
::placeholder {
  color: var(--slate);
  opacity: 1;
}
button {
  cursor: pointer;
}
/* :where() keeps this at element specificity so .primary:hover and row rules still win.
   Touch screens skip it, because a tapped button would otherwise keep the tint. */
@media (hover: hover) {
  button:hover:where(:not(:disabled)) {
    background: var(--selection);
  }
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
button[aria-current='true'] {
  background: var(--selection);
  border-inline-start: 3px solid var(--ink);
  font-weight: 650;
}
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
a {
  color: var(--ink);
}
a:hover {
  text-decoration: underline;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--chalk);
}
footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--slate);
}
.brand {
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: -0.035em;
  color: var(--graphite);
  text-decoration: none;
}
.brand i {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 80% 10% 80% 10%;
  background: var(--ink);
  margin-right: 0.5rem;
}
.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.primary {
  background: var(--ink);
  color: var(--chalk);
  border-color: var(--ink);
  font-weight: 600;
}
.primary:hover:not(:disabled) {
  background: var(--graphite);
}
.compact-nav {
  display: none;
}
.workspace {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr) clamp(15rem, 24vw, 22rem);
  min-height: calc(100vh - 4.5rem);
}
nav,
aside,
main {
  padding: 1.5rem;
  min-width: 0;
}
nav {
  border-right: 1px solid var(--line);
}
aside {
  border-left: 1px solid var(--line);
  background: var(--chalk);
}
main {
  background: var(--chalk);
}
.not-found {
  max-inline-size: 40rem;
  margin-inline: auto;
}
nav h2 {
  font-size: 0.88rem;
  color: var(--slate);
  margin: 1.5rem 0 0.4rem;
}
nav h3 {
  font-size: 0.8rem;
  color: var(--slate);
  margin: 0.8rem 0 0.2rem;
}
nav button {
  display: block;
  text-align: left;
  width: 100%;
  border-color: transparent;
  background: transparent;
  overflow-wrap: anywhere;
}
.suggest-link {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 0.65rem;
}
h1 {
  font-size: clamp(1.65rem, 3vw, 2.3rem);
  letter-spacing: -0.04em;
  line-height: 1.12;
  margin: 0 0 1rem;
}
h2 {
  font-size: 1.15rem;
  margin: 0 0 0.7rem;
  line-height: 1.35;
}
p {
  margin: 0 0 0.8rem;
}
.muted,
small {
  color: var(--slate);
}
.field-label {
  display: block;
  margin-block-end: 0.25rem;
  color: var(--slate);
  font-size: 0.875rem;
}
.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.search input {
  width: 100%;
  min-width: 0;
  background: var(--paper);
}
.search kbd {
  white-space: nowrap;
  color: var(--slate);
  font-size: 0.8rem;
}
#storage-status,
.legend > :first-child {
  min-block-size: 1.5rem;
}
.legend {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 0.75rem 0;
}
#library {
  scroll-margin-block-start: 1rem;
}
.pagination {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  padding-block: 1rem;
  border-block: 1px solid var(--line);
}
.pagination button:first-child {
  justify-self: start;
}
.pagination button:last-child {
  justify-self: end;
}
.page-label {
  color: var(--slate);
  text-align: center;
}
.result-region:has(#rows > li:nth-child(2)),
.result-region:has(.scroll-actions button:not([hidden])) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--jump-size);
  column-gap: var(--step);
}
.result-content {
  grid-column: 1;
  grid-row: 1;
  min-inline-size: 0;
}
.scroll-actions {
  --jump-stack: var(--jump-size);
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  align-self: start;
  display: grid;
  gap: var(--jump-gap);
  inset-block-start: max(
    var(--step),
    calc(100dvh - var(--jump-stack) - 1rem - env(safe-area-inset-bottom, 0px))
  );
}
.scroll-actions:has(#jump-top:not([hidden])):has(#jump-bottom:not([hidden])) {
  --jump-stack: calc(2 * var(--jump-size) + var(--jump-gap));
}
.scroll-actions button {
  display: grid;
  place-items: center;
  inline-size: var(--jump-size);
  min-block-size: var(--jump-size);
  padding: 0;
  font-size: 1.25rem;
}
.scroll-marker {
  position: relative;
  block-size: 1px;
}
.scroll-sentinel {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  visibility: hidden;
  pointer-events: none;
}
#scroll-start {
  inset-block-start: 60dvh;
}
#scroll-end {
  inset-block-end: 15dvh;
}
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
  padding: 0.65rem 0.55rem;
}
#bulk {
  margin: 0.75rem 0;
  padding: 0.6rem;
  background: var(--selection);
}
.first-run {
  margin-block-end: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  background: var(--paper);
}
.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-inline-size: 0;
  max-inline-size: 100%;
}
#tag {
  inline-size: 14rem;
  max-inline-size: 100%;
  min-inline-size: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  text-align: start;
}
#tag-label {
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#tag-search {
  inline-size: 100%;
  min-inline-size: 0;
  margin-block-end: 0.65rem;
}
.tag-options {
  max-block-size: min(42dvh, 22rem);
  overflow: auto;
  overscroll-behavior: contain;
  /* Room for the 2px focus ring and its 3px offset inside the scroll box. */
  padding: 0.375rem;
}
.tag-options li + li {
  margin-block-start: 0.25rem;
}
.tag-options button:not([aria-current='true']) {
  border-color: transparent;
}
.tag-options button[aria-current='true'] {
  border-block-color: transparent;
  border-inline-end-color: transparent;
}
.tag-options button {
  inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 2.75rem;
  text-align: start;
  overflow-wrap: anywhere;
}
select {
  max-width: 100%;
}
#backup-file {
  max-width: 100%;
}
.row:has(.inspect[aria-current='true']) {
  background: var(--selection);
  box-shadow: inset 3px 0 var(--ink);
}
.row a {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 650;
  color: var(--graphite);
  text-decoration: none;
}
.row-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.row a:hover {
  text-decoration: underline;
}
.outbound-cue {
  font-size: 0.85em;
  color: var(--slate);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.row small {
  display: block;
  overflow-wrap: anywhere;
}
.row button {
  min-width: 2.25rem;
  background: transparent;
}
.row button:hover {
  background: var(--chalk);
}
.row button[aria-pressed='true'] {
  color: var(--ink);
}
/* The row itself carries the selected treatment, so its Details button keeps its usual look. */
.row .inspect[aria-current='true'] {
  border-inline-start: 1px solid var(--line);
  font-weight: inherit;
}
@media (forced-colors: active) {
  .row:has(.inspect[aria-current='true']) {
    border-inline-start: 3px solid Highlight;
  }
}
.details-heading {
  overflow-wrap: anywhere;
}
dl {
  margin: 1.2rem 0;
}
dt {
  font-size: 0.85rem;
  color: var(--slate);
}
dd {
  margin: 0 0 0.75rem;
  overflow-wrap: anywhere;
}
dialog {
  width: min(29rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  background: var(--chalk);
  color: var(--graphite);
}
dialog:modal {
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: var(--backdrop);
  overflow: hidden;
  overscroll-behavior: contain;
}
dialog label {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
  margin: 0.7rem 0;
}
.skip {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  transform: translateY(-180%);
  background: var(--chalk);
  padding: 0.5rem;
}
.skip:focus {
  transform: none;
}
#browse-panel nav,
#detail-panel aside {
  padding: 0;
  border: 0;
}
#detail-panel #details-title {
  display: none;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.panel-heading h2 {
  margin: 0;
}
.workspace > nav,
.workspace > aside {
  position: sticky;
  inset-block-start: 0;
  align-self: start;
  max-block-size: 100dvh;
  overflow: auto;
  scrollbar-gutter: stable;
}
/* At these widths the script moves the details (65rem) and the navigation (42rem) into dialogs.
   Hiding them in place first keeps the first paint in the final layout, with no shift. */
@media (max-width: 65rem) {
  .workspace {
    grid-template-columns: 12rem minmax(0, 1fr);
  }
  .workspace > aside {
    display: none;
  }
}
@media (max-width: 42rem) {
  .workspace > nav {
    display: none;
  }
  header,
  main,
  footer {
    padding: 1rem;
  }
  .workspace {
    display: block;
    min-height: calc(100svh - 4.5rem);
  }
  .compact-nav {
    display: block;
  }
  .search kbd {
    display: none;
  }
  .legend {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }
  .filters {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  }
  .filters select {
    min-width: 0;
    padding-inline: 0.35rem;
  }
  #tag {
    inline-size: 100%;
  }
  .row {
    padding-inline: 0;
    gap: 0.4rem;
  }
  .row button {
    padding-inline: 0.4rem;
  }
  .pagination button {
    padding-inline: 0.4rem;
  }
  .page-label {
    font-size: 0.875rem;
  }
}
@media (pointer: coarse) {
  button,
  select,
  input:not([type='checkbox']) {
    min-height: 2.75rem;
  }
  .row input[type='checkbox'] {
    width: 1.5rem;
    height: 1.5rem;
    margin: 0.25rem;
  }
}
