:root {
  color-scheme: light;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --rule: #e4e1db;
  --paper: #fff;
  --background: #f7f6f3;
  --accent: #1a56db;
  --danger: #b42318;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8e8e8;
  --muted: #aaa;
  --rule: #333;
  --paper: #1e1e1e;
  --background: #141414;
  --accent: #8ab4ff;
  --danger: #ff8a80;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1.5rem 1rem;
  background: var(--background);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

main {
  max-width: 64rem;
  margin: 0 auto;
}

main.projects-page {
  max-width: 48rem;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

a {
  color: var(--accent);
}

button,
input,
select,
.button {
  font: inherit;
}

button,
.button,
input[type="search"],
input[type="text"],
select {
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  padding: 0.45rem 0.65rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.88rem;
}

button,
.button {
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: color-mix(in srgb, var(--paper), var(--ink) 7%);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary {
  background: #1a56db;
  border-color: #1a56db;
  color: #fff;
}

.primary:hover {
  background: #1549bd;
}

.active {
  color: var(--accent);
  border-color: var(--accent);
}

.danger {
  color: var(--danger);
}

form {
  margin: 0;
}

.page-header,
.navigation,
.filters,
.filter-summary,
.actions,
.dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.page-header {
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 0.8rem;
}

.filters {
  margin-bottom: 0.8rem;
}

.filters input[type="search"] {
  flex: 1 1 12rem;
  min-width: 0;
}

.filters select {
  max-width: 100%;
}

.filter-summary {
  margin-bottom: 1rem;
}

.chip {
  display: inline-block;
  max-width: 100%;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font: inherit;
  font-size: 0.78rem;
  background: var(--paper);
  color: var(--muted);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.project-chip {
  color: var(--accent);
  border-color: var(--accent);
}

button.chip {
  cursor: pointer;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--paper);
  border: 1px solid var(--rule);
}

th,
td {
  padding: 0.75rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

th a {
  color: inherit;
  text-decoration: none;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.title-column {
  width: auto;
}

.project-column {
  width: 20%;
}

.date-column {
  width: 9rem;
}

.actions-column {
  width: 9.4rem;
}

.title-link {
  display: block;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.filename {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.date {
  color: var(--muted);
  font-size: 0.8rem;
}

.actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 0.15rem;
}

.icon-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex: 0 0 1.95rem;
  width: 1.95rem;
  height: 1.95rem;
  padding: 0.35rem;
  border: 1px solid transparent;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--rule);
  color: var(--ink);
}

.icon-button.danger {
  color: var(--danger);
}

svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notice,
.error,
.empty,
.documentation-box {
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 0.35rem;
  background: var(--paper);
}

.notice {
  color: var(--accent);
}

.error {
  color: var(--danger);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.documentation-box {
  margin-top: 1.25rem;
  border-left: 4px solid var(--accent);
}

.documentation-box h2 {
  margin-bottom: 0.4rem;
}

.documentation-box p {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.88rem;
}

dialog {
  width: min(29rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: 1.4rem;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 15px 50px rgb(0 0 0 / 0.25);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

dialog label.field {
  display: block;
  margin-bottom: 1rem;
}

dialog label.field > span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
}

dialog input[type="text"] {
  width: 100%;
}

dialog p {
  line-height: 1.5;
}

dialog fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

dialog legend {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.project-choices {
  display: grid;
  gap: 0.35rem;
  max-height: 15rem;
  overflow: auto;
  padding: 0.15rem;
}

.project-choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.project-choice:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--paper), var(--accent) 8%);
}

.project-choice input {
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.export-options {
  display: grid;
  gap: 0.5rem;
}

.export-options a {
  justify-content: flex-start;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 42rem) {
  body {
    padding: 1rem 0.65rem;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    padding: 0.6rem;
    border-bottom: 1px solid var(--rule);
  }

  td {
    padding: 0.3rem;
    border: 0;
  }

  td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-size: 0.78rem;
  }

  .actions {
    justify-content: flex-start;
  }

  .projects-page .actions {
    justify-content: flex-start;
  }

  .filters select {
    flex: 1 1 9rem;
  }
}
.tool-menu {
  position: relative;
}
.tool-menu summary {
  list-style: none;
}
.tool-menu summary::-webkit-details-marker {
  display: none;
}
.tool-menu .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  z-index: 40;
  min-width: 15rem;
  padding: 0.3rem;
  border: 1px solid var(--rule);
  border-radius: 0.35rem;
  background: var(--paper);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.16);
}
.tool-menu .menu button,
.tool-menu .menu a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.5rem 0.55rem;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}
.tool-menu .menu button:hover,
.tool-menu .menu a:hover {
  background: color-mix(in srgb, var(--paper), var(--ink) 7%);
}
.tool-menu .menu button.danger {
  color: var(--danger);
}
.tool-menu .menu form {
  width: 100%;
}

/* Bulk selection toolbar */
.bulk-bar {
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 100%;
  gap: 0.5rem;
  margin: 0.75rem 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.bulk-bar .bulk-count-box {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  background: var(--paper);
  white-space: nowrap;
  font-size: 0.88rem;
  color: var(--muted);
}
.bulk-bar .bulk-tools {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  background: var(--paper);
  transition: opacity 0.15s ease;
}
.bulk-bar[data-selected="0"] .bulk-tools {
  opacity: 0.4;
  pointer-events: none;
}
.bulk-bar select,
.bulk-bar input[type="text"] {
  box-sizing: border-box;
  height: 2.2rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  background: var(--paper);
  color: var(--ink);
}
.bulk-bar button[type="submit"] {
  box-sizing: border-box;
  height: 2.2rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.bulk-bar button[type="submit"]:hover {
  background: color-mix(in srgb, var(--paper), var(--ink) 7%);
}
.bulk-bar button.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.bulk-combo {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
}
.bulk-combo select,
.bulk-combo input[type="text"] {
  border-right: 0;
  border-radius: 0.3rem 0 0 0.3rem;
  min-width: 8rem;
}
.bulk-combo button[type="submit"] {
  border-left: 0;
  border-radius: 0 0.3rem 0.3rem 0;
}
.select-column {
  box-sizing: border-box;
  width: 2.1rem;
  min-width: 2.1rem;
  padding: 0 0.3rem;
  text-align: left;
}
.select-column input[type="checkbox"] {
  display: block;
  width: 1rem;
  height: 1rem;
  margin: 0;
}
@media (max-width: 42rem) {
  .bulk-bar {
    gap: 0.3rem;
  }
  .bulk-bar .bulk-tools {
    gap: 0.3rem;
  }
  .bulk-bar select,
  .bulk-bar input[type="text"] {
    min-width: 6rem;
  }
  .bulk-combo select,
  .bulk-combo input[type="text"] {
    min-width: 6rem;
  }
}

/* Dark theme: keep page titles and headings legible. */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] .typenik-title,
html[data-theme="dark"] .shared-title {
  color: var(--ink);
}
