:root {
  color-scheme: dark;
  --bg: #0c0e12;
  --bar: rgba(13, 16, 21, 0.94);
  --panel: rgba(25, 30, 38, 0.88);
  --panel-soft: rgba(31, 37, 46, 0.86);
  --edge: rgba(255, 255, 255, 0.065);
  --text: #eef1f5;
  --muted: #8d96a3;
  --faint: #626b77;
  --gold: #cbb865;
  --gold-hot: #ffe17a;
  --blue: #8ea9df;
  font-family: "Google Sans", "Roboto", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -18%, rgba(255, 225, 122, 0.075), transparent 30%),
    linear-gradient(180deg, #11141a 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 58px;
  gap: 18px;
  background: var(--bar);
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px);
}

.menu-button {
  position: absolute;
  left: 18px;
  display: grid;
  width: 36px;
  height: 36px;
  place-content: center;
  gap: 4px;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.menu-button:hover,
.icon-button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.menu-button span {
  display: block;
  width: 19px;
  height: 2px;
  border-radius: 99px;
  background: currentColor;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.icon-button span {
  display: block;
  margin-top: -2px;
  font-size: 42px;
  line-height: 34px;
}

.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 26px;
  line-height: 1;
}

.pager input {
  width: 68px;
  border: 0;
  border-bottom: 2px solid rgba(238, 242, 247, 0.86);
  border-radius: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  text-align: center;
  font-size: 26px;
}

.pager input::-webkit-outer-spin-button,
.pager input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.shell {
  min-height: calc(100vh - 58px);
}

.library {
  position: fixed;
  top: 58px;
  bottom: 0;
  left: 0;
  z-index: 4;
  width: min(286px, calc(100vw - 24px));
  padding: 20px 14px;
  overflow-y: auto;
  background: rgba(12, 15, 20, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.055);
  box-shadow: 20px 0 54px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
  transform: translateX(-102%);
  transition: transform 220ms ease;
}

body.library-open .library {
  transform: translateX(0);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 7px;
  color: #111419;
  background: linear-gradient(145deg, #ffffff, #d5ddeb);
  box-shadow: 0 10px 24px rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.upload {
  display: grid;
  gap: 9px;
  margin-bottom: 18px;
}

.upload label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.upload input,
.favorites-controls select,
.rename-form input {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  color: var(--text);
  background: rgba(9, 11, 15, 0.68);
}

.upload input {
  border-style: dashed;
  color: var(--muted);
}

.upload button,
.book-main,
.book-edit,
.library-action,
.favorite-export,
.rename-form button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  background: rgba(28, 33, 41, 0.9);
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.upload button {
  color: var(--gold-hot);
  font-weight: 700;
  text-align: center;
  background: rgba(255, 225, 122, 0.11);
  border: 1px solid rgba(255, 225, 122, 0.22);
  box-shadow: 0 0 18px rgba(255, 225, 122, 0.06);
}

.upload button:hover,
.book-main:hover,
.book-edit:hover,
.library-action:hover,
.favorite-export:hover,
.rename-form button:hover {
  transform: translateY(-1px);
}

.upload p,
.rename-form p {
  min-height: 14px;
  margin: 0;
  color: var(--blue);
  font-size: 11px;
}

.book-list {
  display: grid;
  gap: 7px;
}

.book-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.book-main {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 10px 11px;
}

.book-main strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.book-main span {
  color: var(--muted);
  font-size: 11px;
}

.book-edit {
  align-self: stretch;
  min-width: 44px;
  padding: 0 9px;
  color: var(--gold);
  font-size: 11px;
  text-align: center;
  border: 1px solid rgba(255, 225, 122, 0.16);
}

.book-item.active .book-main,
.book-item.active .book-edit {
  background: rgba(34, 40, 50, 0.94);
  outline: 1px solid rgba(255, 225, 122, 0.27);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 0 20px rgba(255, 225, 122, 0.08);
}

.library-action {
  display: block;
  width: 100%;
  margin-top: 18px;
  color: var(--gold-hot);
  text-align: center;
  font-weight: 700;
  border: 1px solid rgba(255, 225, 122, 0.18);
  background: rgba(255, 225, 122, 0.09);
}

.library-action.active {
  outline: 1px solid rgba(255, 225, 122, 0.27);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 0 20px rgba(255, 225, 122, 0.08);
}

.install-action {
  margin-top: 8px;
  color: #111419;
  background: linear-gradient(145deg, #fff0a3, var(--gold-hot));
  box-shadow: 0 0 24px rgba(255, 225, 122, 0.12);
}

.install-action[hidden] {
  display: none;
}

.rename-form {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(255, 225, 122, 0.18);
  border-radius: 7px;
  background: rgba(24, 29, 37, 0.94);
}

.rename-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.rename-form button {
  text-align: center;
  font-size: 12px;
}

.reader {
  padding: 20px clamp(12px, 4vw, 72px) 42px;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  animation: pageIn 180ms ease both;
}

.favorites-page {
  max-width: 960px;
  margin: 0 auto;
  animation: pageIn 180ms ease both;
}

.favorites-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 18px clamp(18px, 3.2vw, 42px);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(31, 37, 47, 0.92), rgba(21, 26, 34, 0.88)),
    rgba(25, 30, 38, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.075),
    0 0 28px rgba(255, 225, 122, 0.04),
    0 16px 38px rgba(0, 0, 0, 0.23);
}

.favorites-title h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 40px);
  font-weight: 700;
  letter-spacing: 0;
}

.favorites-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.favorites-title span {
  min-width: 42px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--gold-hot);
  background: rgba(255, 225, 122, 0.11);
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 0 20px rgba(255, 225, 122, 0.08);
}

.favorites-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.favorites-controls select {
  min-height: 42px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(31, 37, 46, 0.9), rgba(12, 15, 20, 0.88)),
    rgba(9, 11, 15, 0.68);
}

.favorite-export {
  min-width: 132px;
  padding: 0 16px;
  color: var(--gold-hot);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  border: 1px solid rgba(255, 225, 122, 0.18);
  background: rgba(255, 225, 122, 0.09);
}

.favorite-export:disabled {
  opacity: 0.45;
  cursor: default;
}

.favorites-list {
  display: grid;
  gap: 8px;
}

.favorites-empty {
  margin: 0;
  padding: 18px clamp(18px, 3.2vw, 42px);
  color: var(--muted);
  border: 1px solid var(--edge);
  border-radius: 7px;
  background: var(--panel);
  font-size: 16px;
  line-height: 1.35;
}

.favorite-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px clamp(18px, 3.2vw, 42px);
  border: 1px solid rgba(255, 225, 122, 0.13);
  border-radius: 7px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(31, 37, 46, 0.88), rgba(17, 21, 28, 0.82)),
    rgba(25, 30, 38, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 0 18px rgba(255, 225, 122, 0.04);
  cursor: pointer;
  text-align: left;
}

.favorite-item:hover {
  border-color: rgba(255, 225, 122, 0.28);
  background: rgba(34, 40, 50, 0.94);
}

.favorite-item span {
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.favorite-item strong {
  color: var(--text);
  font-size: clamp(17px, 1.45vw, 22px);
  font-weight: 500;
  line-height: 1.42;
}

.empty {
  max-width: 640px;
  margin: 12vh auto 0;
  padding: 34px;
  border-radius: 7px;
  background: var(--panel);
}

.empty h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: 0;
}

.empty p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.42;
}

.block {
  position: relative;
  width: 100%;
  margin: 0 0 6px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28),
    0 14px 32px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(14px);
  overflow-wrap: anywhere;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.block.h1,
.block.h2 {
  border-radius: 7px;
}

.block.h1 {
  margin-bottom: 18px;
  padding: 15px clamp(18px, 3.2vw, 46px);
  font-size: clamp(22px, 2.25vw, 31px);
  font-weight: 500;
  line-height: 1.2;
  background:
    linear-gradient(135deg, rgba(31, 37, 47, 0.9), rgba(21, 26, 34, 0.88)),
    rgba(25, 30, 38, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.075),
    0 0 28px rgba(255, 225, 122, 0.035),
    0 16px 38px rgba(0, 0, 0, 0.23);
}

.block.h2 {
  margin: 16px 0 18px;
  padding: 14px clamp(18px, 3.2vw, 46px);
  font-size: clamp(19px, 1.8vw, 25px);
  font-weight: 700;
  line-height: 1.2;
  background:
    linear-gradient(135deg, rgba(30, 36, 45, 0.88), rgba(22, 27, 35, 0.86)),
    rgba(25, 30, 38, 0.88);
}

.block.sentence {
  min-height: 46px;
  padding: 12px clamp(42px, 4.6vw, 58px) 12px clamp(18px, 3.2vw, 46px);
  border-radius: 0;
  font-size: clamp(17px, 1.55vw, 24px);
  line-height: 1.42;
}

.block.sentence:hover {
  background: var(--panel-soft);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 38px rgba(0, 0, 0, 0.22);
}

.block.sentence + .block.sentence {
  border-top: 1px solid rgba(0, 0, 0, 0.62);
}

.star {
  position: absolute;
  top: 50%;
  right: 14px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: rgba(255, 229, 138, 0.82);
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 229, 138, 0.2), rgba(255, 229, 138, 0.035) 48%, transparent 72%),
    rgba(255, 255, 255, 0.018);
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow:
    0 0 16px rgba(255, 229, 138, 0.16),
    inset 0 0 12px rgba(255, 229, 138, 0.06);
  filter:
    drop-shadow(0 0 5px rgba(255, 229, 138, 0.38))
    drop-shadow(0 0 14px rgba(255, 229, 138, 0.12));
  transition: color 150ms ease, transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

.star svg {
  position: relative;
  z-index: 1;
  width: 21px;
  height: 21px;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.85;
}

.star:hover {
  color: var(--gold-hot);
  box-shadow:
    0 0 24px rgba(255, 229, 138, 0.28),
    inset 0 0 16px rgba(255, 229, 138, 0.12);
  filter:
    drop-shadow(0 0 9px rgba(255, 229, 138, 0.72))
    drop-shadow(0 0 22px rgba(255, 229, 138, 0.28));
  transform: translateY(-50%) scale(1.08);
}

.star.active {
  color: var(--gold-hot);
  box-shadow:
    0 0 30px rgba(255, 229, 138, 0.42),
    0 0 62px rgba(255, 229, 138, 0.18),
    inset 0 0 18px rgba(255, 229, 138, 0.18);
  filter:
    drop-shadow(0 0 7px rgba(255, 229, 138, 1))
    drop-shadow(0 0 26px rgba(255, 229, 138, 0.7));
  animation: starPulse 2.4s ease-in-out infinite;
}

.star.active svg {
  fill: currentColor;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes starPulse {
  0%,
  100% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.12);
  }
}

@media (max-width: 860px) {
  .topbar {
    height: 54px;
  }

  .library {
    top: 54px;
  }

  .reader {
    padding: 12px 8px 36px;
  }

  .pager,
  .pager input {
    font-size: 23px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .icon-button span {
    font-size: 40px;
  }

  .block.sentence {
    padding-right: 42px;
  }

  .favorites-controls {
    grid-template-columns: 1fr;
  }

  .favorites-title {
    align-items: flex-start;
  }
}
