:root {
  --bg: #fbfaf6;
  --paper: #fffdf8;
  --ink: #171513;
  --muted: #686059;
  --green: #184f33;
  --green-dark: #103722;
  --wine: #5b1217;
  --gold: #b9934d;
  --line: rgba(23, 21, 19, 0.12);
  --shadow: 0 24px 70px rgba(38, 31, 24, 0.12);
  --font-ui: "Vazirmatn", Tahoma, Arial, sans-serif;
  --font-nastaliq: "IranNastaliq", "Noto Nastaliq Urdu", serif;
  --reader-zoom: 1;
  color-scheme: light;
}

@font-face {
  font-family: "IranNastaliq";
  src: url("/assets/fonts/IranNastaliq.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(24, 79, 51, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(91, 18, 23, 0.08), transparent 38%),
    var(--bg);
}

button,
input {
  font: inherit;
}

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

.title-screen {
  min-height: 100svh;
  background: #fbfaf6;
  overflow-x: hidden;
}

.title-page {
  position: relative;
  width: min(100%, 1180px);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 66px) clamp(28px, 7vw, 92px);
  display: grid;
  place-items: start center;
  background: #fffefb;
  border-inline: 5px solid #d8cfb7;
}

.title-content {
  width: 100%;
  display: grid;
  justify-items: center;
  text-align: center;
  align-self: start;
  margin-top: clamp(16px, 3vh, 34px);
  transform: none;
}

.home-cover {
  width: min(18vw, 112px);
  aspect-ratio: 740 / 1040;
  display: block;
  margin: 0 auto clamp(22px, 4vh, 42px);
  background: center / cover no-repeat url("/api/cover");
  box-shadow: 0 18px 46px rgba(23, 21, 19, 0.16);
  pointer-events: none;
  user-select: none;
}

.title-content h1 {
  margin: 0;
  color: #111;
  letter-spacing: 0;
}

.title-nastaliq .title-content h1 {
  font-family: var(--font-nastaliq);
  font-size: clamp(2.9rem, 7.8vw, 6.7rem);
  font-weight: 400;
  line-height: 1.28;
  padding: 0.22em 0 0.34em;
}

.title-standard .title-content h1 {
  font-family: var(--font-ui);
  font-size: clamp(2.85rem, 7.7vw, 6rem);
  font-weight: 900;
  line-height: 1.55;
}

.book-type {
  margin: clamp(18px, 3vh, 34px) 0 0;
  color: var(--green);
  font-size: clamp(1.7rem, 4.2vw, 3.5rem);
  font-weight: 800;
}

.title-nastaliq .book-type {
  font-family: var(--font-nastaliq);
  font-weight: 400;
  line-height: 1.28;
  padding: 0.16em 0 0.26em;
}

.book-author {
  margin: clamp(34px, 6vh, 72px) 0 0;
  color: #121212;
  font-size: clamp(2rem, 5vw, 4.4rem);
  font-weight: 800;
}

.title-nastaliq .book-author {
  font-family: var(--font-nastaliq);
  font-weight: 400;
  line-height: 1.28;
  padding: 0.16em 0 0.28em;
}

.open-book-button {
  min-width: min(100%, 270px);
  min-height: 58px;
  margin-top: clamp(18px, 3.4vh, 34px);
  margin-bottom: 0;
  padding: 15px 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: #fff;
  border: 1px solid rgba(16, 55, 34, 0.1);
  font-size: 1.08rem;
  font-weight: 800;
  box-shadow: 0 16px 36px rgba(24, 79, 51, 0.18);
}

.open-book-button:hover {
  background: var(--green-dark);
}

.shell {
  width: min(100% - 32px, 760px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 48px 0;
}

.intro {
  width: 100%;
  padding: clamp(28px, 6vw, 58px);
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.kicker {
  margin: 0 0 14px;
  color: var(--wine);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: clamp(2.35rem, 8vw, 5rem);
  line-height: 1.7;
  letter-spacing: 0;
}

.author {
  margin: 16px 0 0;
  color: var(--green);
  font-size: 1.18rem;
  font-weight: 700;
}

.summary {
  max-width: 42rem;
  margin: 24px 0 30px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 2;
}

.password-box {
  display: grid;
  gap: 10px;
}

.password-box label {
  font-weight: 700;
}

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

input {
  min-height: 54px;
  width: 100%;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(24, 79, 51, 0.12);
}

button {
  min-height: 54px;
  border: 0;
  padding: 0 22px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--green-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.form-message {
  min-height: 28px;
  margin: 0;
  color: var(--wine);
  font-size: 0.94rem;
}

.small-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.9;
}

.admin-shell {
  width: min(100% - 32px, 820px);
}

.upload-progress {
  height: 12px;
  margin-top: 18px;
  background: rgba(24, 79, 51, 0.12);
  overflow: hidden;
}

.upload-progress div {
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 0.25s ease;
}

.guide h1 {
  font-family: var(--font-ui);
  font-size: clamp(2rem, 6vw, 3.3rem);
  line-height: 1.45;
}

.guide-list {
  margin: 0;
  padding: 0 26px 0 0;
  display: grid;
  gap: 14px;
  color: var(--ink);
  font-size: 1.04rem;
  line-height: 1.95;
}

.guide-list strong {
  direction: ltr;
  display: inline-block;
  color: var(--green);
}

.guide-heading {
  margin: 34px 0 12px;
  color: var(--green);
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  line-height: 1.7;
}

.guide-copy {
  margin: 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 2;
}

.reader-body {
  background: #eee8de;
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 74px;
  padding: 12px clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(248, 242, 232, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.reader-header p,
.reader-header h1 {
  margin: 0;
}

.reader-header p {
  color: var(--muted);
  font-size: 0.9rem;
}

.reader-header h1 {
  font-family: var(--font-ui);
  font-size: clamp(1.1rem, 3vw, 1.55rem);
}

.reader-actions {
  display: flex;
  gap: 8px;
  direction: ltr;
}

.reader-actions button {
  min-width: 46px;
  min-height: 44px;
  padding: 0 14px;
}

.reader-main {
  width: min(100% - 24px, 1060px);
  margin: 0 auto;
  padding: 20px 0 44px;
}

.page-counter {
  margin: 0 0 18px;
  color: var(--muted);
  text-align: center;
}

.pages {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.book-page {
  width: min(100%, calc(760px * var(--reader-zoom)));
  margin: 0;
  background: var(--paper);
  border: 1px solid rgba(23, 21, 19, 0.08);
  box-shadow: 0 18px 50px rgba(23, 21, 19, 0.12);
}

.book-page img {
  display: block;
  width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.book-page figcaption {
  display: none;
}

@media (max-width: 640px) {
  .title-page {
    border-inline-width: 3px;
    padding: 26px 22px;
  }

  .title-content {
    margin-top: clamp(14px, 3vh, 26px);
    transform: none;
  }

  .home-cover {
    width: min(28vw, 92px);
    margin-bottom: clamp(18px, 3vh, 28px);
  }

  .title-nastaliq .title-content h1 {
    font-size: clamp(2.7rem, 13vw, 4.4rem);
  }

  .title-standard .title-content h1 {
    font-size: clamp(2.35rem, 11vw, 3.9rem);
  }

  .book-type {
    font-size: clamp(1.5rem, 8vw, 2.3rem);
  }

  .book-author {
    margin-top: clamp(34px, 6vh, 56px);
    font-size: clamp(1.75rem, 9vw, 2.8rem);
  }

  .open-book-button {
    width: 100%;
  }

  .intro {
    padding: 24px;
  }

  .password-row,
  .reader-header {
    grid-template-columns: 1fr;
  }

  .password-row {
    display: grid;
  }

  .password-row button {
    width: 100%;
  }

  .reader-header {
    align-items: stretch;
  }

  .reader-actions {
    justify-content: stretch;
  }

  .reader-actions button {
    flex: 1;
  }
}
