/* PolyUAI mobile integration layer for the external paper reader. */
@media (max-width: 700px) {
  :root {
    --reader-header-height: 54px;
    --reader-mobile-tools-height: 68px;
    --tools-width: 0px;
  }

  .reader-view .header {
    height: var(--reader-header-height);
    padding: 0 7px;
    border: 0;
    background: linear-gradient(
      180deg,
      rgba(238, 241, 233, 0.72),
      rgba(238, 241, 233, 0.28)
    );
    backdrop-filter: blur(10px);
    transition: opacity 260ms ease, transform 260ms ease;
  }

  .reader-view .header .icon-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    border-radius: 11px;
  }

  .reader-view .header svg {
    width: 23px;
    height: 23px;
  }

  .header .reader-left-tools {
    gap: 5px;
  }

  .reader-view .document-name {
    display: none;
  }

  .reader-layout,
  .reader-layout.sidebar-hidden {
    inset: 0;
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .stage {
    display: grid;
    padding: 3px;
    overflow: auto;
    align-content: safe center;
    justify-content: start;
    scroll-padding: 8px;
    scrollbar-width: none;
  }

  .stage::-webkit-scrollbar {
    display: none;
  }

  .book-space {
    margin: 0;
  }

  .book-cover {
    inset: 0 -3px -7px;
    box-shadow: 0 18px 28px -17px rgba(52, 60, 54, 0.58),
      0 6px 12px -7px rgba(52, 60, 54, 0.3);
  }

  .reader-tools {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    display: flex;
    width: auto;
    height: var(--reader-mobile-tools-height);
    padding: 7px;
    overflow: visible;
    border: 0;
    border-radius: 18px;
    background: rgba(239, 242, 234, 0.58);
    box-shadow: none;
    backdrop-filter: blur(14px);
    transition: opacity 260ms ease, transform 260ms ease;
  }

  .reader-tools .reading-controls {
    display: grid;
    width: min(100%, 390px);
    height: 54px;
    margin: 0 auto;
    padding: 0;
    grid-template-columns: 54px minmax(96px, 1fr) 54px 54px;
    gap: 7px;
    align-items: center;
    border: 0;
    border-radius: 14px;
    background: transparent;
    box-shadow: none;
  }

  .reader-tools .tool-divider,
  .reader-tools #scale-up,
  .reader-tools #fit-book,
  .reader-tools #scale-down,
  .reader-tools #page-mode,
  .reader-tools #sound,
  .reader-tools #fullscreen {
    display: none;
  }

  .reader-tools #previous,
  .reader-tools #next,
  .reader-tools #zoom,
  .reader-tools .page-count {
    width: 100%;
    min-width: 0;
    height: 50px;
    min-height: 50px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
  }

  .reader-tools #previous {
    grid-column: 1;
    grid-row: 1;
  }

  .reader-tools .page-count {
    grid-column: 2;
    grid-row: 1;
    color: #34482c;
    font-size: 18px;
    font-weight: 650;
    line-height: 1;
  }

  .reader-tools .page-count span {
    display: inline;
    margin: 0 0 0 5px;
    color: #66745e;
    font-size: 15px;
  }

  .reader-tools #next {
    grid-column: 3;
    grid-row: 1;
  }

  .reader-tools #zoom {
    grid-column: 4;
    grid-row: 1;
  }

  .reader-tools svg {
    width: 27px;
    height: 27px;
  }

  .reading .reader-tools,
  .reading .header {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  body.polyu-controls-hidden .reader-view .header {
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
  }

  body.polyu-controls-hidden .reader-tools {
    opacity: 0;
    transform: translateY(18px);
    pointer-events: none;
  }

  .progress-track {
    bottom: 0;
  }

  .sidebar,
  .reader-layout .sidebar {
    width: min(88vw, 360px);
    font-size: 17px;
  }

  .sidebar-heading {
    font-size: 20px;
  }

  .sidebar-tabs button,
  .outline-empty {
    font-size: 17px;
  }

  .chapter-link {
    font-size: 18px;
  }

  .outline-tree ul ul .chapter-link {
    font-size: 16px;
  }

  .zoom-dialog {
    height: 100dvh;
  }

  .zoom-toolbar {
    height: 58px;
    padding: 0 8px;
  }

  .zoom-scroll {
    height: calc(100% - 58px);
    padding: 10px;
  }
}

@media (max-width: 420px) {
  .reader-tools .reading-controls {
    grid-template-columns: 50px minmax(86px, 1fr) 50px 50px;
    gap: 5px;
  }

  .reader-view .document-name {
    font-size: 14px;
  }
}

@media (max-width: 700px) and (orientation: landscape) {
  :root {
    --reader-header-height: 48px;
    --reader-mobile-tools-height: 60px;
  }

  .reader-view .header .icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .reader-view .document-name {
    left: 94px;
  }

  .reader-tools {
    padding-top: 4px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
  }

  .reader-tools .reading-controls {
    height: 50px;
  }

  .reader-tools #previous,
  .reader-tools #next,
  .reader-tools #zoom,
  .reader-tools .page-count {
    height: 46px;
    min-height: 46px;
  }
}
