* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: #f5f5f5;
  color: #203040;
}

.hidden {
  display: none !important;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  min-height: 44px;
  background: #2f78a8;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(47, 120, 168, .16);
}

button:disabled {
  opacity: .45;
  cursor: default;
}

input,
select {
  font-size: 16px;
  padding: 13px 14px;
  border: 1px solid #b8dff3;
  border-radius: 12px;
  background: #fff;
}

.eyebrow {
  margin: 0 0 2px;
  color: #2f78a8;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .12em;
}

/* ログイン */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(
      circle at top left,
      rgba(140, 211, 247, .48),
      transparent 32%
    ),
    linear-gradient(
      135deg,
      #f4fbff,
      #dff3ff
    );
}

.login-card {
  width: min(440px, 100%);
  padding: 36px;
  background: rgba(255,255,255,.95);
  border: 1px solid #ccecff;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(43,110,150,.16);
}

.login-card h1 {
  margin: 0 0 12px;
}

.login-card input,
.login-card button {
  width: 100%;
}

.login-card input {
  margin: 16px 0 12px;
}

.error-message {
  min-height: 1.4em;
  color: #c43d3d;
}

.note {
  color: #5f7890;
  font-size: 13px;
  line-height: 1.6;
}

/* ヘッダー */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px clamp(18px, 4vw, 56px);
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid #ccecff;
  box-shadow: 0 8px 24px rgba(43,110,150,.08);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(18px, 2.4vw, 28px);
line-height: 1.05;
}

.secondary-button {
  background: #7bbfe5;
  color: #143247;
}

.link-button {
  background: #2f78a8;
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(47,120,168,.18);
}

/* 本棚 */
.bookshelf {
  padding: 28px clamp(18px, 4vw, 56px) 56px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}

.toolbar input,
.toolbar select {
  min-width: 240px;
}

.book-grid {
  display: block;
}

.category-shelf {
  margin-bottom: 34px;
}

.category-shelf-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
}

.category-shelf-header h2 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  color: #143247;
}

.category-shelf-header span {
  color: #5f7890;
  font-size: 14px;
  font-weight: 700;
}

.category-book-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 4px 18px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.book-card {
  flex: 0 0 230px;
  display: block;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: #fff;
  border: 1px solid #f2f4f7;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  scroll-snap-align: start;
  transition: .2s ease;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 46px rgba(0,0,0,.07);
}

.book-cover {
  aspect-ratio: 4 / 5;
  overflow: hidden;
  padding: 0;
  background: transparent;
}


.book-cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  background: #fff;
}

.book-cover-title {
  font-size: 20px;
  line-height: 1.35;
  font-weight: 800;
}

.book-cover-sub {
  margin-top: 16px;
  color: #2f78a8;
  font-size: 13px;
  font-weight: 800;
}

.book-info {
  padding: 16px 16px 8px;
}

.book-info h2 {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.35;
white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.book-meta {
  color: #5f7890;
  font-size: 13px;
  line-height: 1.7;
margin-top: 2px;
}

.empty-books-message {
  padding: 24px;
  background: #fff;
  border: 1px solid #ccecff;
  border-radius: 16px;
  color: #5f7890;
}

/* リーダー */
.reader-layout {
  max-width: none;
  width: 100%;
  padding: 10px 12px 106px;
  margin: 0;
}

.viewer-panel {
  width: 100%;
  min-width: 0;
}

.zoom-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.zoom-toolbar button {
  background: #7bbfe5;
  color: #143247;
  box-shadow: none;
}

@media (min-width: 821px) {

  .zoom-toolbar {
    gap: 8px;
    margin-bottom: 15px;
  }



  #zoomIndicator {
    min-width: 46px;
    font-size: 12px;
  }

}
#zoomIndicator {
  min-width: 74px;
  text-align: center;
  color: #2f78a8;
  font-weight: 800;
}

.mode-message,
.message-box {
  width: min(1100px, 100%);
  margin: 0 auto 14px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #b8dff3;
  border-radius: 14px;
  color: #2f78a8;
  text-align: center;
  font-weight: 700;
  line-height: 1.6;
}

.error-box {
  color: #8a2525;
  white-space: pre-wrap;
  background: #fff6f6;
  border-color: #ffb6b6;
}

/* PDF表示エリア */
.viewer-scroll {
  position: relative;
  width: 100%;
  height: calc(100vh - 205px);
  min-height: 520px;
  overflow: hidden;
  display: grid;
  place-items: start center;
  background: #f5f5f5;
  padding-left: 20px;
  padding-right: 20px;
}

/* 拡大時 */
.viewer-scroll.zoomed {
  overflow: auto;
  place-items: start center;
  background: #f5f5f5;
  overscroll-behavior: contain;
  cursor: grab;
}

.viewer-scroll.zoomed:active {
  cursor: grabbing;
}

.desktop-book {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  transform-style: preserve-3d;
  perspective: 2200px;
}

.desktop-book.zoomed-book {
  padding: 30px;
}

.book-layer {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  transform-style: preserve-3d;
}

.outgoing-layer {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  pointer-events: none;
}

.incoming-layer {
  position: relative;
  z-index: 1;
}

.page-card {
  position: relative;
  background: #fff;
  overflow: hidden;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.page-card img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  object-fit: contain;
}

/* 縦長PDF：見開き表示 */
.page-card.spread img {
  height: calc(100vh - 220px);
  width: auto;
  max-width: 48vw;
}

/* 横長PDF：通常時のみ、画面内に収める */
@media (min-width: 821px) {
  .viewer-scroll:not(.zoomed) .page-card.single img {
    width: auto !important;
    height: calc(100vh - 250px) !important;
    max-width: calc(100vw - 80px) !important;
    max-height: calc(100vh - 250px) !important;
    object-fit: contain !important;
  }

  .viewer-scroll:not(.zoomed) .page-card.single {
    width: fit-content;
    max-width: calc(100vw - 80px);
  }
}

/* 拡大時はJS側のサイズ指定を優先させる */
@media (min-width: 821px) {
  .viewer-scroll.zoomed .page-card.single img,
  .viewer-scroll.zoomed .page-card.spread img {
    max-width: none !important;
    max-height: none !important;
  }
}

/* クリックエリア */
.pc-click-zone {
  position: absolute;
  top: 0;
  width: 22%;
  height: 55%;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  z-index: 20;
}

.pc-prev-zone {
  left: 0;
  cursor: w-resize;
}

.pc-next-zone {
  right: 0;
  cursor: e-resize;
}

.viewer-scroll.zoomed .pc-click-zone {
  display: none;
}

/* Kindle風：スワイプページ送り（PC） */
@media (min-width: 821px) {
  .desktop-book.flip-active {
    overflow: hidden;
  }

  .desktop-book.flip-active .incoming-layer {
    position: relative;
    z-index: 2;
    will-change: transform, opacity;
  }

  .desktop-book.flip-active .outgoing-layer {
    display: flex !important;
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 1;
    pointer-events: none;
    will-change: transform, opacity;
  }

  .desktop-book.flip-active.turn-next .incoming-layer {
    animation: vicKindleInNext .26s cubic-bezier(.22,.61,.36,1) both !important;
  }

  .desktop-book.flip-active.turn-next .outgoing-layer {
    animation: vicKindleOutNext .26s cubic-bezier(.22,.61,.36,1) both !important;
  }

  .desktop-book.flip-active.turn-prev .incoming-layer {
    animation: vicKindleInPrev .26s cubic-bezier(.22,.61,.36,1) both !important;
  }

  .desktop-book.flip-active.turn-prev .outgoing-layer {
    animation: vicKindleOutPrev .26s cubic-bezier(.22,.61,.36,1) both !important;
  }

  .desktop-book.flip-active.turn-next::after,
  .desktop-book.flip-active.turn-prev::after,
  .outgoing-layer .page-card::after {
    display: none !important;
    animation: none !important;
  }
}

@keyframes vicKindleInNext {
  0% {
    opacity: .35;
    transform: translate3d(44px, 0, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes vicKindleOutNext {
  0% {
    opacity: 1;
    transform: translateX(-50%) translate3d(0, 0, 0);
  }
  100% {
    opacity: .18;
    transform: translateX(-50%) translate3d(-44px, 0, 0);
  }
}

@keyframes vicKindleInPrev {
  0% {
    opacity: .35;
    transform: translate3d(-44px, 0, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes vicKindleOutPrev {
  0% {
    opacity: 1;
    transform: translateX(-50%) translate3d(0, 0, 0);
  }
  100% {
    opacity: .18;
    transform: translateX(-50%) translate3d(44px, 0, 0);
  }
}

/* スマホビューア */


.mobile-page-button {
  display: none;
}

.hint {
  width: min(1100px, 100%);
  margin: 14px auto 0;
  color: #5f7890;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}

body.zoom-mode {
  overscroll-behavior: contain;
}

/* 目次 */
.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(20,50,71,.28);
  display: grid;
  place-items: end center;
  padding: 16px;
  animation: tocOverlayFadeIn .16s ease both;
}

.toc-overlay.hidden {
  display: none !important;
}

.toc-drawer {
  width: min(560px, 100%);
  max-height: min(76vh, 680px);
  overflow: auto;
  background: #fff;
  border: 1px solid #b8dff3;
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(20,50,71,.25);
  padding: 16px;
  animation: tocDrawerUp .18s ease both;
}

.toc-overlay.closing {
  animation: tocOverlayFadeOut .18s ease both;
}

.toc-overlay.closing .toc-drawer {
  animation: tocDrawerDown .18s ease both;
}

.toc-drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 8px;
  background: #fff;
  color: #143247;
  font-size: 18px;
}

.toc-close-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  background: #eef9ff;
  color: #143247;
  box-shadow: none;
  font-size: 22px;
}

.toc-drawer #tocList {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.toc-drawer #tocList button {
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  text-align: left;
  background: #eef9ff;
  color: #203040;
  border-radius: 12px;
  box-shadow: none;
}

@keyframes tocOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tocOverlayFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

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

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

/* 固定フッター */
.reader-footer-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 1000;
  transform: translateX(-50%);

  width: min(700px, calc(100% - 24px));

  display: grid;
  grid-template-columns: 1fr .95fr .75fr .95fr;
  align-items: center;

  gap: 7px;
  padding: 8px;

  background: rgba(255,255,255,.94);
  border: 1px solid #b8dff3;
  border-radius: 999px;

  box-shadow: 0 10px 28px rgba(43,110,150,.18);
  backdrop-filter: blur(8px);
}

.footer-icon-button,
.footer-nav-button {
  min-height: 34px;

  padding: 6px 12px;

  font-size: 13px;
  font-weight: 700;

  border-radius: 999px;
}

.footer-icon-button {
  background: #143247;
  color: #fff;
}

.footer-page-indicator {
  text-align: center;
  color: #2f78a8;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

/* スマホ */
@media (max-width: 820px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
  }

  .bookshelf {
    padding: 20px 14px 44px;
  }

  .toolbar input,
  .toolbar select {
    width: 100%;
    min-width: 0;
  }

  .category-book-row .book-card {
    flex-basis: 180px;
  }

  .reader-layout {
    padding: 16px 12px 96px;
  }

  .zoom-toolbar {
    display: none;
  }


  .viewer-scroll {
    display: none !important;
  }

  .mobile-viewer {
    border-radius: 14px;
  }




  .mobile-prev-button {
    left: 8px;
  }

  .mobile-next-button {
    right: 8px;
  }

  .reader-footer-nav {
    bottom: 10px;
    width: calc(100% - 16px);
    grid-template-columns: 1fr .9fr .75fr .9fr;
    gap: 6px;
    padding: 8px;
    border-radius: 22px;
  }

  .footer-icon-button,
  .footer-nav-button {
    min-height: 38px;
    padding: 7px 8px;
    font-size: 13px;
    touch-action: manipulation;
  }

  .footer-page-indicator {
    font-size: 13px;
  }
}

.mobile-page-button {
  display: grid;
  place-items: center;

  position: absolute;
  top: 50%;
  z-index: 5;

  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;

  transform: translateY(-50%);

  border-radius: 999px;

  background: rgba(47,120,168,.21);

  color: rgba(255,255,255,.92);

  font-size: 28px;
  line-height: 1;

  box-shadow:
    0 4px 10px rgba(47,120,168,.08);

  touch-action: manipulation;
}

/* v5.2: カテゴリ棚の左右スクロール矢印 */
.category-shelf-scroll-wrap {
  position: relative;
}

.shelf-arrow {
  position: absolute;
  top: 42%;
  z-index: 5;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: #2f78a8;
  border: 1px solid #dbe7ef;
  box-shadow: 0 8px 22px rgba(0,0,0,.12);
  font-size: 34px;
  line-height: 1;
  backdrop-filter: blur(6px);
}

.shelf-arrow-left {
  left: -10px;
}

.shelf-arrow-right {
  right: -10px;
}

.shelf-arrow:disabled {
  opacity: .25;
  cursor: default;
}

.category-book-row {
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

@media (max-width: 820px) {
  .shelf-arrow {
    display: none !important;
  }
}
/* 教材ページのヘッダー調整 */
.reader-header {
  justify-content: flex-start;
}

.reader-header > div {
  flex: 1;
  text-align: left;
}
@media (min-width: 821px) {
  .app-header,
  .reader-header {
    padding-top: 10px;
    padding-bottom: 10px;
  }

}
.pc-page-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;

  width: 48px;
  height: 48px;
  min-height: 48px;

  border-radius: 999px;

  background: rgba(47,120,168,.65);
  color: #fff;

  font-size: 34px;
  font-weight: 700;


  box-shadow: 0 2px 3px rgba(47,120,168,.04);
}

.pc-prev-button {
  left: 16px;
}

.pc-next-button {
  right: 16px;
}

.pc-page-button:hover {
  background: rgba(47,120,168,.75);
}
/* PC表示：左右ページ送り矢印をPDFに少し重ねる */
@media (min-width: 821px) {
  .pc-page-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;

    width: 50px;
    height: 50px;
    min-height: 50px;
    padding: 0;

    border-radius: 999px;
    background: rgba(47,120,168,.45);
    color: #fff;

    font-size: 34px;
    font-weight: 700;
    line-height: 1;

    box-shadow: 0 2px 6px rgba(0,0,0,.08);
  }

  .pc-prev-button {
    left: calc(50% - 430px);
  }

  .pc-next-button {
    left: calc(50% + 375px);
  }

  .viewer-scroll.zoomed .pc-page-button {
    display: none;
  }
}
.book-cover {
  position: relative;
}

.continue-badge {
  position: absolute;

  bottom: 12px;
  right: 12px;

  z-index: 5;

  min-height: auto;
  padding: 7px 10px;

  border-radius: 999px;

  background: rgba(255,116,72,.65);
  color: #fff;

  font-size: 12px;
  font-weight: 700;

  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

@media (max-width:820px){

  .continue-badge{

    font-size:10px;

    padding:4px 7px;

    bottom:8px;
    right:8px;
  }

}

 /* ==========================
   Floating Bookshelf Button
   VIC Version
   ========================== */

.floating-bookshelf-button{
  position:fixed;

  left:auto !important;
  right:18px;
  bottom:24px;

  width:58px;
  height:58px;
  min-height:auto;

  display:flex;
  align-items:center;
  justify-content:center;

  border:none;
  border-radius:50%;

  cursor:pointer;

  font-size:26px;
  color:#5f6b7a;

  background:rgba(255,255,255,.55);

  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);

  box-shadow:
    0 8px 24px rgba(0,0,0,.12);

  transition:
    transform .18s ease,
    box-shadow .18s ease,
    background .18s ease;

  z-index:9999;
}

.floating-bookshelf-button:hover{
  transform:translateY(-2px);

  background:rgba(255,255,255,.88);

  box-shadow:
    0 12px 28px rgba(0,0,0,.18);
}

.floating-bookshelf-button:active{
  transform:scale(.96);
}

/* スマホ：固定フッターと被らないように上へ逃がす */
@media (max-width:820px){

  .floating-bookshelf-button{
    left:auto !important;
    right:12px;

    bottom:calc(env(safe-area-inset-bottom) + 80px);

    width:48px;
    height:48px;

    font-size:22px;
  }

}

#modeMessage{
  display:none !important;
}


@media (max-width:820px){

  .category-shelf-scroll-wrap::after{
    content:"";
    position:absolute;
    top:0;
    right:0;
    width:39px;
    height:100%;
    pointer-events:none;

   
  }

}

@media (max-width:820px){

  .category-book-row{
    padding-right:24px;
  }

  .category-book-row .book-card{
    flex:0 0 39vw;
    max-width:170px;
  }

}
.mobile-slide-next {
  animation: mobileKindleNext .32s cubic-bezier(.22,.61,.36,1) both;
}

.mobile-slide-prev {
  animation: mobileKindlePrev .32s cubic-bezier(.22,.61,.36,1) both;
}

.mobile-slide-next {
  animation: mobileKindleNext .36s cubic-bezier(.2,.75,.25,1) both;
}

.mobile-slide-prev {
  animation: mobileKindlePrev .36s cubic-bezier(.2,.75,.25,1) both;
}

@keyframes mobileKindleNext {
  from {
    opacity: .15;
    transform: translate3d(110vw, 0, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes mobileKindlePrev {
  from {
    opacity: .15;
    transform: translate3d(-110vw, 0, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes mobileKindlePrev {
  from {
    opacity: .25;
    transform: translate3d(-85vw, 0, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 820px) {
   .mobile-viewer {
    overscroll-behavior: contain;
    touch-action: auto;
  }

  .mobile-viewer img {
    touch-action: auto;
  }
}
/* スマホピンチズーム用 */
.mobile-viewer {
  position: relative;
  overflow: hidden;
}

#mobilePageImage {
  display: block;
  width: 100%;
  height: auto;

  transform-origin: center center;

  will-change: transform;

  transition:
    transform .05s linear;
}

.mobile-viewer.mobile-zoomed {
  overflow: hidden;
}

#mobilePageImage {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: center center;
  will-change: transform;
}

.mobile-viewer.mobile-zoomed {
  overflow: hidden;
}
.mobile-viewer {
  overscroll-behavior: contain;
}

@media (max-width: 820px) {
  .mobile-page-button,
  .mobile-prev-button,
  .mobile-next-button {
    display: none !important;
  }
}

@media (min-width: 821px) {

  .zoom-toolbar button {

    height: 32px !important;
    min-height: 20px !important;

    padding-top: 0 !important;
    padding-bottom: 0 !important;

    padding-left: 12px !important;
    padding-right: 12px !important;

    line-height: 20px !important;

    border-radius: 4px !important;

    font-size: 12px !important;

    box-sizing: border-box;
  }

}