:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #1d252f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: #1f5f8b;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #dde3ea;
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
}

.topbar div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar span,
small,
p {
  color: #647284;
}

.shell {
  margin: 0 auto;
  max-width: 980px;
  padding: 32px 20px;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.panel {
  background: #ffffff;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 28px;
}

.auth-panel {
  max-width: 480px;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0 0 8px;
}

p {
  line-height: 1.5;
  margin: 0 0 18px;
}

.section-head {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.button {
  appearance: none;
  align-items: center;
  border: 1px solid #c8d2de;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  font: inherit;
  font-weight: 650;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.82;
}

.button.primary {
  background: #216b9f;
  border-color: #216b9f;
  color: #ffffff;
}

.button.subtle {
  background: #ffffff;
  color: #354254;
}

.scan-status {
  color: #647284;
  font-size: 14px;
  margin-top: 8px;
  max-width: 240px;
}

.spinner {
  animation: spin 0.8s linear infinite;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: none;
  height: 16px;
  width: 16px;
}

.loading-button.is-loading .spinner,
a.is-loading .spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.notice,
.empty {
  background: #f1f5f8;
  border: 1px solid #d8e2ea;
  border-radius: 8px;
  color: #44546a;
  padding: 16px;
}

.filter-bar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(180px, auto) auto auto;
  margin-bottom: 16px;
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-bar label span,
.result-count {
  color: #647284;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #c8d2de;
  border-radius: 6px;
  color: #1d252f;
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  line-height: 1.45;
  min-height: 130px;
  resize: vertical;
}

.result-count {
  margin-bottom: 12px;
}

.settings-form {
  border: 1px solid #dde3ea;
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 16px;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-form label span {
  color: #354254;
  font-weight: 700;
}

.settings-form p {
  font-size: 14px;
  margin: 10px 0;
}

.settings-form .button {
  margin-top: 12px;
}

.settings-status {
  max-width: none;
}

.library-list,
.file-list {
  border: 1px solid #dde3ea;
  border-radius: 8px;
  overflow: hidden;
}

.library-row,
.file-row {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #dde3ea;
  color: inherit;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 16px;
}

.library-row:last-child,
.file-row:last-child {
  border-bottom: 0;
}

.library-row:hover,
.file-row:hover {
  background: #f8fafc;
  text-decoration: none;
}

.library-row.is-loading {
  cursor: wait;
  opacity: 0.82;
}

.library-row.is-loading .spinner {
  display: inline-block;
}

.row-action {
  align-items: center;
  color: #647284;
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 700;
  gap: 8px;
}

.entry-kind {
  color: #647284;
  font-size: 12px;
  font-weight: 700;
  margin-right: 6px;
  text-transform: uppercase;
}

.book-row {
  cursor: default;
}

.format-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.format-link {
  border: 1px solid #c8d2de;
  border-radius: 6px;
  color: #1f5f8b;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 8px;
}

.format-link:hover {
  background: #eef5fa;
  text-decoration: none;
}

.library-row span:first-child,
.file-row span:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

small {
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
  }

  .section-head,
  .filter-bar,
  .library-row,
  .file-row {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar {
    display: flex;
  }
}
