:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d0f12;
  color: #f2f4f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(40, 92, 100, 0.32), transparent 34%),
    linear-gradient(225deg, rgba(99, 74, 34, 0.22), transparent 34%),
    #0d0f12;
}

button,
input {
  font: inherit;
}

button,
.button-link {
  align-items: center;
  background: #d5f774;
  border: 0;
  border-radius: 7px;
  color: #101214;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: #e4ff9e;
  text-decoration: none;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #323b40;
  border-radius: 7px;
  background: #15191d;
  color: #f7faf4;
  padding: 0 12px;
}

label {
  color: #aeb9be;
  display: grid;
  font-size: 0.88rem;
  gap: 6px;
}

a {
  color: #d5f774;
}

.shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  color: #9cb1a8;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  line-height: 0.95;
  margin-bottom: 0;
}

h2 {
  font-size: 1.05rem;
  margin: 0;
}

h3 {
  font-size: 0.96rem;
  line-height: 1.25;
  margin-bottom: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  background: #1b2025;
  color: #f2f4f8;
}

.tab.active {
  background: #d5f774;
  color: #101214;
}

.panel {
  border: 1px solid rgba(218, 230, 218, 0.12);
  border-radius: 8px;
  background: rgba(18, 22, 26, 0.9);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  padding: 16px;
}

.token-panel,
.search-panel,
.status {
  margin-bottom: 14px;
}

.hidden,
.view {
  display: none;
}

.view.active {
  display: block;
}

.row,
.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.status {
  color: #9cb1a8;
  min-height: 22px;
}

.status.ok {
  color: #d5f774;
}

.status.error {
  color: #ffb58f;
}

.status.loading {
  color: #a6d5ff;
}

.panel-heading,
.heading-actions,
.indexer-title,
.card-actions,
.reader-controls {
  align-items: center;
  display: flex;
  gap: 10px;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.count {
  border-radius: 999px;
  background: #25302c;
  color: #d5f774;
  font-size: 0.8rem;
  font-weight: 800;
  min-width: 34px;
  padding: 4px 10px;
  text-align: center;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.poster-grid.empty {
  color: #9cb1a8;
  display: block;
}

.book-card,
.indexer-card {
  border: 1px solid rgba(218, 230, 218, 0.1);
  border-radius: 8px;
  background: #15191d;
  padding: 12px;
}

.cover {
  align-items: center;
  aspect-ratio: 2 / 3;
  background:
    linear-gradient(145deg, rgba(213, 247, 116, 0.9), rgba(78, 140, 148, 0.72)),
    #22282d;
  border-radius: 7px;
  color: #101214;
  display: flex;
  font-size: 2.3rem;
  font-weight: 900;
  justify-content: center;
  margin-bottom: 12px;
  text-align: center;
}

.cover[data-ext="pdf"] {
  background: linear-gradient(145deg, #ffb58f, #8ab7ff);
}

.cover[data-ext="epub"] {
  background: linear-gradient(145deg, #d5f774, #7dc8a8);
}

.meta {
  color: #9cb1a8;
  font-size: 0.84rem;
  line-height: 1.42;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.ghost-link {
  align-items: center;
  color: #d5f774;
  display: inline-flex;
  font-weight: 700;
  min-height: 40px;
  text-decoration: none;
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-layout .full,
.settings-actions {
  grid-column: 1 / -1;
}

.settings-layout .panel {
  display: grid;
  gap: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.indexer-list {
  display: grid;
  gap: 12px;
}

.check-label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.check-label input {
  min-height: auto;
  width: auto;
}

.reader-body {
  background: #0d0f12;
}

.reader-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.reader-bar {
  align-items: center;
  background: #12161a;
  border-bottom: 1px solid rgba(218, 230, 218, 0.12);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 10px 14px;
}

.back-link {
  color: #d5f774;
  font-weight: 800;
  text-decoration: none;
}

.reader-surface {
  min-height: 0;
  padding: 0;
}

.pdf-reader,
.epub-viewer {
  border: 0;
  height: calc(100vh - 62px);
  width: 100%;
}

.epub-viewer {
  background: #f6f3ec;
  color: #151515;
}

.text-reader {
  background: #f6f3ec;
  color: #111;
  font: 1.05rem/1.65 Georgia, serif;
  margin: 0 auto;
  max-width: 880px;
  min-height: calc(100vh - 62px);
  padding: 42px;
  white-space: pre-wrap;
}

.unsupported {
  margin: 60px auto;
  max-width: 520px;
  padding: 20px;
}

@media (max-width: 840px) {
  .topbar,
  .settings-layout,
  .field-grid,
  .row,
  .search-form,
  .reader-bar {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .shell {
    width: min(100% - 20px, 1220px);
    padding-top: 18px;
  }

  .poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  }

  .reader-controls {
    flex-wrap: wrap;
  }
}
