* { box-sizing: border-box; }

:root{
  --bg: #f4f4f6;
  --panel: #ffffff;
  --border: #e5e5ea;
  --shadow: 0 12px 30px rgba(0,0,0,.12);
  --radius: 16px;
}

html { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: #222;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 共通ボタン */
.btn{
  padding: 10px 14px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.btn:active{ transform: translateY(1px); }
.btn:hover{ background:#f0f0f3; }
.btn.ghost{ opacity: .75; }

/* 上部バー */
.bar{
  position: sticky;
  top: 0;
  z-index: 10;
  display:flex;
  align-items:center;
  gap:12px;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.title{
  flex:1;
  text-align:center;
  font-weight: 650;
  font-size: 20px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:10px;
  margin: 6px 0px 4px 0px;
}

/* 中央寄せの要：内側ラッパー */
.controls-inner{
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  justify-content: center; /* ここで中央 */
}

/* 3つの操作をまとめて“浮いてるチップ”感 */
.zoom{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(244,244,246,.95);
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

.chip{
  appearance: none;
  border: 0;
  background: #fff;
  color: #111;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 8px 18px rgba(0,0,0,.06);
  -webkit-tap-highlight-color: transparent;
}

.chip:active{ transform: translateY(1px); }
.chip-ghost{
  background: transparent;
  box-shadow: none;
  opacity: .8;
}

.zoomLabel{
  font-size: 12px;
  color: #666;
  min-width: 54px;
  text-align: right;
}

/* スマホは“操作しやすさ優先” */
@media (max-width: 600px){
  .controls{ top: 54px; }
  .zoom{ gap: 8px; padding: 8px; }
  .chip{ padding: 12px 16px; font-size: 20px; }
  .zoomLabel{ display:none; } /* 狭いので消す */
}

/* ビューワ枠 */
.wrap{
  flex: 1;
  min-height: 0;
  display:flex;
  justify-content:center;
  padding: 8px;
}
.viewer{
  width: min(980px, 96vw);
  height: min(70vh, 800px);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

/* epub.js が中で iframe を作るので、そのサイズを埋める */
#viewer iframe{
  width:100% !important;
  height:100% !important;
  border:0;
}

/* スマホでは表示領域を優先 */
@media (max-width: 600px){
  .wrap{ padding: 4px; }
  .viewer{
    width: 100vw;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
  }
  .title{ font-size: 14px; }
  .btn{ padding: 12px 16px; font-size: 18px; }
  .zoomLabel{ display:none; } /* 画面狭いので隠す */
}

.tapZone{
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 5; /* iframeの上に */
}

.tapZone.left{ left: 0; }
.tapZone.right{ right: 0; }

/* 真ん中触れるようにしたいなら width調整する */

.viewer{
  overflow: auto;     /* hidden → auto */
  position: relative;
  -webkit-overflow-scrolling: touch;
  touch-action: none; /* ドラッグを拾う */
}

#stage{
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

