:root {
  --bg: #fff7df;
  --panel: #ffffff;
  --ink: #183044;
  --muted: #66717a;
  --line: #eadfbf;
  --primary: #207c78;
  --primary-dark: #155e5b;
  --accent: #ffb238;
  --sky: #dff4ff;
  --leaf: #ddf6d2;
  --berry: #f7d9ef;
  --danger: #b42318;
  --shadow: 0 18px 44px rgba(24, 48, 68, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--sky) 0 260px, var(--bg) 260px 100%);
  font-family: Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
  font-weight: 900;
  text-decoration: none;
}

.brand span {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #5ebf86);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(32, 124, 120, .2);
}

.app-header nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.app-header nav a {
  padding: 8px 10px;
  color: var(--muted);
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 800;
  text-decoration: none;
  background: rgba(255, 178, 56, .12);
}

main {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px 14px 92px;
}

.hero,
.panel,
.page-head,
.detail,
.reader,
.admin-section {
  padding: 20px;
  border: 2px solid rgba(255, 255, 255, .78);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  min-height: calc(100vh - 106px);
  display: grid;
  align-content: center;
  background:
    linear-gradient(135deg, rgba(255, 178, 56, .2), rgba(32, 124, 120, .14)),
    var(--panel);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.15rem, 11vw, 4.2rem);
  line-height: 1;
}

h2 {
  font-size: 1.18rem;
}

p {
  color: var(--muted);
  font-weight: 650;
}

.actions,
.search-bar {
  display: grid;
  gap: 10px;
}

.actions {
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 16px;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #35a47b);
  box-shadow: 0 12px 24px rgba(32, 124, 120, .2);
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  color: var(--primary);
  border-color: rgba(47, 125, 104, .25);
  background: var(--leaf);
}

.text-link {
  display: inline-flex;
  margin-top: 14px;
  color: var(--primary);
  font-weight: 900;
  text-decoration: none;
}

.form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font: inherit;
}

textarea {
  resize: vertical;
}

.flash-stack {
  display: grid;
  gap: 8px;
  width: min(980px, 100%);
  margin: 14px auto 0;
  padding: 0 14px;
}

.flash {
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 800;
}

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

.flash.success {
  color: var(--primary);
}

.page-head {
  margin-bottom: 14px;
  background:
    linear-gradient(135deg, rgba(223, 244, 255, .9), rgba(255, 255, 255, .9)),
    var(--panel);
}

.book-grid,
.admin-list {
  display: grid;
  gap: 12px;
}

.book-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(23, 33, 38, .08);
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}

.book-card:active,
.book-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(23, 33, 38, .12);
}

.cover {
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  color: #fff;
  background:
    linear-gradient(135deg, var(--primary), var(--accent));
  font-size: 2rem;
  font-weight: 950;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover.large {
  width: min(260px, 100%);
  margin: 0 auto 16px;
}

.book-card h2 {
  margin: 8px 0 4px;
}

.book-card p {
  margin-bottom: 8px;
}

.book-card strong {
  color: var(--primary);
}

.pill {
  display: inline-flex;
  padding: 5px 8px;
  color: var(--primary-dark);
  background: rgba(47, 125, 104, .12);
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 950;
}

.detail-copy {
  display: grid;
  gap: 12px;
}

.info-list,
.modal-details {
  display: grid;
  gap: 8px;
  margin: 0;
}

.info-list div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

dt {
  color: var(--primary);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
  font-weight: 800;
}

.notice,
.empty,
.external-book {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .58);
  font-weight: 800;
}

.reader-head {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.reader-page {
  overflow: hidden;
  background: #102630;
}

.reader-page .app-header,
.reader-page .flash-stack {
  display: none;
}

.reader-page main {
  width: 100%;
  height: 100vh;
  padding: 0;
}

.reader-fullscreen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100vh;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #102630;
  box-shadow: none;
}

.reader-topbar,
.reader-bottom {
  position: relative;
  z-index: 2;
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 10px;
  color: #fff;
  background: rgba(16, 38, 48, .94);
}

.reader-topbar {
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 62px;
}

.reader-back,
.reader-icon,
.reader-nav,
.reader-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 14px;
  background: rgba(255, 255, 255, .12);
  font: inherit;
  font-size: .9rem;
  font-weight: 900;
  text-decoration: none;
}

.reader-title {
  min-width: 0;
}

.reader-title span,
.reader-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-title span {
  color: rgba(255, 255, 255, .68);
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.reader-title strong {
  font-size: 1rem;
}

.reader-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, .12), transparent 38%),
    #102630;
}

#pdfCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .32);
}

.reader-loading {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  text-align: center;
}

.reader-bottom {
  grid-template-columns: 1fr 120px 1fr;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.reader-page-field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  color: rgba(255, 255, 255, .68);
  font-size: .72rem;
  font-weight: 900;
  text-align: center;
}

.reader-page-field input {
  width: 100%;
  min-height: 42px;
  padding: 6px;
  color: #102630;
  border: 0;
  border-radius: 14px;
  font-weight: 950;
  text-align: center;
}

#totalPaginas,
.reader-page #saveStatus {
  color: rgba(255, 255, 255, .76);
  font-size: .78rem;
  font-weight: 900;
}

.reader-save {
  grid-column: 1 / -1;
  color: #102630;
  background: var(--accent);
}

.reader-nav:disabled {
  opacity: .42;
}

.reader-frame {
  width: 100%;
  min-height: 66vh;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.reader-control {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

#saveStatus {
  color: var(--primary);
  font-weight: 900;
}

.admin-section {
  margin-top: 14px;
}

.admin-list article {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.admin-list span {
  color: var(--muted);
  font-weight: 750;
}

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

.admin-actions .btn {
  min-height: 42px;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.check-row input {
  width: 22px;
  min-height: 22px;
}

.current-file {
  color: var(--primary);
  font-size: .86rem;
  font-weight: 800;
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .app-header nav {
    width: 100%;
  }

  .app-header nav a {
    flex: 1 0 auto;
    text-align: center;
  }

  .book-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .reader-icon {
    width: 42px;
    padding: 0;
    overflow: hidden;
    white-space: nowrap;
  }
}

@media (min-width: 760px) {
  main {
    padding-top: 28px;
  }

  .actions,
  .search-bar,
  .reader-head {
    display: flex;
    align-items: center;
  }

  .search-bar input {
    flex: 1;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
  }

  .cover.large {
    margin: 0;
  }

  .reader-bottom {
    grid-template-columns: auto 150px auto auto 100px;
    justify-content: center;
  }

  .reader-save {
    grid-column: auto;
  }
}
