:root {
  color-scheme: light;
  --ink: #212b29;
  --muted: #718078;
  --paper: #f7f5f1;
  --card: #fff;
  --line: #e8e5dc;
  --green: #375c4d;
  --green2: #294b3e;
  --red: #a53c31;
  --shadow: 0 18px 48px rgba(34, 43, 37, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a {
  color: inherit;
}
.topbar {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1200px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(14px);
}
.brand {
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.06em;
  text-decoration: none;
  color: var(--ink);
}
.brand span {
  color: #bd7452;
}
.topbar nav {
  display: flex;
  align-items: center;
  gap: 26px;
}
.topbar nav a,
.text-button,
.subtle-link {
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}
.topbar nav form {
  margin: 0;
}
.text-button {
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}
.wrap {
  max-width: 1200px;
  padding: 42px 28px 26px;
  margin: auto;
}
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  margin-bottom: 30px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.hero h1,
.login-card h1,
.reader-wrap h1 {
  font-size: clamp(32px, 4vw, 48px);
  letter-spacing: -0.045em;
  line-height: 1.1;
  margin: 0 0 12px;
}
.muted,
.author {
  color: var(--muted);
}
.hero .muted {
  max-width: 640px;
  margin: 0;
}
.storage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  min-width: 190px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 13px;
}
.storage strong {
  color: var(--ink);
  font-size: 24px;
}
.storage small {
  font-size: 12px;
}
.upload-panel,
.library-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 25px;
  margin: 22px 0;
  box-shadow: var(--shadow);
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
}
.section-title h2 {
  font-size: 22px;
  letter-spacing: -0.025em;
  margin: 0;
}
.section-title .muted {
  margin: 5px 0 0;
}
.dropzone {
  position: relative;
  overflow: hidden;
  min-height: 176px;
  padding: 20px;
  border: 2px dashed #93a99a;
  border-radius: 17px;
  background: #fafbf9;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
}
.dropzone:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 35%, transparent);
  outline-offset: 3px;
}
.dropzone.dragging {
  border-color: var(--green);
  background: #eef4ef;
  transform: scale(1.01);
  box-shadow: 0 8px 26px #23442a1c;
}
.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}
.dropzone strong {
  color: var(--ink);
  font-size: 17px;
}
.dropzone > span:nth-of-type(2) {
  font-size: 13px;
}
.upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: #e8f0e9;
  font-size: 25px;
  color: var(--green);
}
.drop-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #eaf2ebf2;
  color: var(--green);
  font-size: 19px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.dropzone.dragging .drop-overlay {
  opacity: 1;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button.primary {
  background: var(--green);
  color: white;
}
.button.primary:hover {
  background: var(--green2);
}
.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}
.button.danger {
  border-color: #f0d2ce;
  background: #fff8f7;
  color: var(--red);
}
.upload-status {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 14px;
  align-items: center;
  padding: 9px 11px;
  border-radius: 10px;
  background: #f8f8f6;
  font-size: 13px;
}
.upload-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-row > span {
  color: var(--muted);
}
.progress {
  grid-column: 1/-1;
  height: 4px;
  border-radius: 9px;
  background: #e2e7e3;
  overflow: hidden;
}
.progress i {
  display: block;
  width: 0;
  height: 100%;
  background: #547e68;
  transition: width 0.1s;
}
.upload-row.done > span {
  color: var(--green);
}
.upload-row.failed > span {
  color: var(--red);
}
.upload-summary {
  margin: 5px 0;
  font-weight: 650;
}
.global-progress {
  width: 100%;
  height: 7px;
  accent-color: var(--green);
}
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filters select,
.search input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 11px;
  color: var(--ink);
  font: inherit;
}
.search {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding-left: 11px;
  color: var(--muted);
}
.search input {
  border: 0;
  min-width: 170px;
  outline: none;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}
.book-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}
.book-cover {
  height: 190px;
  background: linear-gradient(145deg, #e8e2d5, #cddbd2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  overflow: hidden;
}
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cover-mark {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--green);
  margin-bottom: 12px;
}
.cover-title {
  font:
    600 20px/1.2 Georgia,
    serif;
  max-width: 220px;
}
.book-info {
  padding: 14px;
}
.book-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
.format-pill {
  background: #eff3ef;
  color: var(--green);
  border-radius: 20px;
  padding: 3px 8px;
  font-weight: 750;
}
.book-info h3 {
  margin: 10px 0 2px;
  font-size: 17px;
  line-height: 1.25;
}
.author {
  margin: 0;
  font-size: 13px;
}
.edit-details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.edit-details summary {
  font-size: 12px;
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
}
.edit-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.edit-form label,
.login-card label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 650;
}
.edit-form input,
.edit-form textarea,
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: white;
}
.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.card-actions .button {
  font-size: 12px;
  min-height: 34px;
  padding: 6px 9px;
}
.card-actions form {
  margin: 0;
}
.empty {
  text-align: center;
  padding: 55px 20px;
  color: var(--muted);
}
.empty > span {
  font-size: 40px;
  color: #9bad9f;
}
.empty h3 {
  color: var(--ink);
  margin: 8px 0;
}
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 23px 0 5px;
}
.pagination a {
  font-weight: 650;
  color: var(--green);
  text-decoration: none;
}
.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 12px;
}
.notice {
  padding: 12px 14px;
  border-radius: 11px;
  background: #edf3ef;
  color: var(--green);
}
.notice.error {
  background: #fff0ed;
  color: var(--red);
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 50% 0, #e6ece4, transparent 50%), var(--paper);
}
.login-card {
  width: min(100%, 430px);
  padding: 35px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.login-card .brand {
  display: inline-block;
  margin-bottom: 35px;
}
.login-card .muted {
  margin: 0 0 22px;
}
.login-card form {
  display: grid;
  gap: 14px;
}
.login-card input {
  min-height: 46px;
}
.login-card .button {
  width: 100%;
  margin-top: 4px;
  min-height: 45px;
}
.subtle-link {
  display: block;
  margin-top: 22px;
  font-size: 13px;
}
.reader-wrap {
  max-width: 1000px;
  margin: 32px auto;
  padding: 0 24px;
}
.reader-controls {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}
.reader-controls button {
  border: 1px solid var(--line);
  background: white;
  padding: 9px 14px;
  border-radius: 9px;
  font: inherit;
  cursor: pointer;
}
.pdf-view {
  width: 100%;
  height: 78vh;
  border: 1px solid var(--line);
  border-radius: 12px;
}
#epub-view {
  min-height: 75vh;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--line);
}
#epub-view.reader-error {
  display: grid;
  min-height: 180px;
  padding: 24px;
  place-items: center;
  color: var(--red);
  text-align: center;
}
@media (max-width: 900px) {
  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .filters {
    width: 100%;
  }
}
@media (max-width: 620px) {
  .topbar {
    height: 60px;
    padding: 0 16px;
  }
  .topbar nav {
    gap: 14px;
    font-size: 13px;
  }
  .wrap {
    padding: 25px 14px;
  }
  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }
  .storage {
    min-width: 100%;
    grid-template-columns: 1fr auto;
  }
  .storage small {
    grid-column: 1/-1;
  }
  .upload-panel,
  .library-section {
    padding: 17px;
    border-radius: 17px;
  }
  .dropzone {
    min-height: 158px;
  }
  .book-grid {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .book-cover {
    height: 145px;
  }
  .book-info {
    padding: 10px;
  }
  .book-info h3 {
    font-size: 15px;
  }
  .card-actions {
    gap: 5px;
  }
  .card-actions .button {
    font-size: 11px;
    padding: 5px 7px;
  }
  .filters select {
    flex: 1;
  }
  .search {
    flex: 1;
  }
  .search input {
    min-width: 0;
    width: 100%;
  }
  .reader-wrap {
    padding: 0 12px;
  }
  .pdf-view {
    height: 75vh;
  }
}
@media (max-width: 390px) {
  .book-grid {
    grid-template-columns: 1fr;
  }
  .book-cover {
    height: 180px;
  }
  .card-actions .button {
    font-size: 12px;
  }
}
