/* 极简纯白风格（自由ZINE） */
:root{
  --bg: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e5e7eb;
  --shadow: rgba(15, 23, 42, .08);
  --accent: #111827;
  --accent2: #4f46e5;
  --danger: #ef4444;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }

/* 从封面页带 #zine= 进入时避免先闪出主页 */
html.freezine-boot-reader #homeView{
  visibility: hidden;
}

body{
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.hidden{ display:none !important; }
.view{ min-height: 100vh; width: 100%; }

/* 圆形扁平按钮 */
.circle-btn{
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 650;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.circle-btn:hover{
  background: rgba(15,23,42,.04);
  border-color: rgba(15,23,42,.18);
}
.circle-btn:active{ transform: translateY(1px); }
.circle-btn.primary{
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.circle-btn.danger{
  background: rgba(239, 68, 68, .08);
  border-color: rgba(239, 68, 68, .35);
  color: #b91c1c;
}
.circle-btn.small{
  padding: 10px 14px;
  font-size: 13px;
}

/* Home */
.home-view{
  position: relative;
  overflow: hidden;
}

.home-enter{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.icons-wall{
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}
.zine-item{
  position: absolute;
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content: flex-start;
  flex: 0 0 auto;
  max-width: 132px;
  pointer-events: auto;
}

#homeEnterBtn{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: auto;
}

.zine-icon-btn{
  position: relative;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(15,23,42,.1);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 8px 28px var(--shadow), 0 1px 0 rgba(255,255,255,.9) inset;
  display: grid;
  place-items: center;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.zine-icon-btn img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.zine-icon-btn:hover{
  border-color: rgba(79, 70, 229, .38);
  box-shadow: 0 14px 40px rgba(15,23,42,.12);
}
.zine-name{
  margin-top: 10px;
  width: 100%;
  max-width: 120px;
  text-align:center;
  font-size: 12px;
  font-weight: 700;
  color: #111827;
  background: transparent;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Designer */
.designer-top{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.designer-brand{
  font-weight: 900;
  letter-spacing: .2px;
}
.designer-layout{
  padding: 18px 20px 28px;
  max-width: 1100px;
  margin: 0 auto;
}

.panel{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(15,23,42,.04);
}

.setup-panel{
  padding: 16px;
}
.setup-row{
  display:flex;
  align-items:flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.control{
  display:flex;
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
}
.control-label{
  font-weight: 750;
  color: var(--muted);
  font-size: 13px;
}
input[type="number"]{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  min-height: 42px;
}
input[type="text"]{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  min-height: 42px;
}

/* 比例选择：扁平圆形 */
.ratio-group{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ratio-option{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  background: #fff;
  transition: border-color .15s ease, background .15s ease;
}
.ratio-option input{ display:none; }
.ratio-option span{
  font-weight: 800;
  font-size: 13px;
}
.ratio-option.is-selected{
  border-color: rgba(79,70,229,.45);
  background: rgba(79,70,229,.06);
}

.setup-actions{
  margin-top: 14px;
  display:flex;
  justify-content:center;
}

.editor-panel{
  padding: 16px;
  margin-top: 16px;
}
.editor-nav{
  display:flex;
  align-items:center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}
.page-indicator{
  flex: 1;
  text-align:center;
  font-weight: 800;
  color: var(--muted);
  font-size: 14px;
}

.toolbar{
  display:flex;
  align-items:center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  max-width: 100%;
}
.toolbar-top{ margin-bottom: 8px; }
.toolbar-bottom{ margin-bottom: 14px; }

.font-control{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  min-height: 42px;
}
.font-label{
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.font-control input[type="range"]{
  width: 130px;
}
.font-value{
  font-weight: 900;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.control-inline{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  min-height: 42px;
}
.control-label-inline{
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.control-select{
  border: none;
  outline: none;
  font-size: 13px;
  font-weight: 800;
  background: transparent;
  color: var(--text);
  max-width: 220px;
}
.control-select.wide-select{
  max-width: min(280px, 70vw);
}
.color-input{
  width: 44px;
  height: 30px;
  border: none;
  background: transparent;
  padding: 0;
}
.img-size-info{
  color: #111827;
  font-weight: 800;
  font-size: 12px;
}


.status{
  min-height: 22px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 650;
}

.editor-actions{
  display:flex;
  align-items:center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.page-wrap{
  border: none;
  border-radius: 14px;
  background: #fff;
  padding: 0;
  outline: none;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow: hidden;
  height: min(74vh, 900px);
  min-height: 420px;
}
.page-wrap.canvas-border-none{
  background: rgba(15,23,42,.04);
}
.page-wrap:focus{
  box-shadow: 0 0 0 4px rgba(79,70,229,.12);
}

#zineCanvas{
  background:#fff;
  display:block;
  outline-offset: -1px;
  transition: outline-color .2s ease, outline-width .2s ease, box-shadow .2s ease;
}
.page-wrap[data-canvas-border="gray"] #zineCanvas{
  outline: 1px solid rgba(15,23,42,.28);
}
.page-wrap[data-canvas-border="black"] #zineCanvas{
  outline: 2px solid #111827;
}
.page-wrap[data-canvas-border="none"] #zineCanvas{
  outline: 1px dashed rgba(15,23,42,.14);
}

.canvas-border-options{
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.border-option{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  user-select: none;
  background: #fff;
}
.border-option input{ display: none; }
.border-option.is-selected{
  border-color: rgba(79,70,229,.45);
  background: rgba(79,70,229,.06);
}
.canvas-border-control .control-label-inline{
  flex-shrink: 0;
}

/* Viewer：横向平铺可左右滑动 */
.viewer-overlay{
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.98);
  z-index: 50;
  display:flex;
  flex-direction: column;
}
.viewer-topbar{
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
}
.viewer-title{
  flex: 1;
  text-align: center;
  font-weight: 900;
  letter-spacing: .2px;
}
.viewer-status{
  min-width: 140px;
  text-align: right;
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
}

.viewer-right-actions{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.viewer-rail{
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  display:flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 18px 0;
  scroll-snap-type: x mandatory;
}

.viewer-rail.single-mode{
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: none;
  justify-content: center;
  align-items: center;
  padding: 12px 16px;
}
.viewer-rail.single-mode .viewer-page{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  flex: 1;
}
.viewer-rail.single-mode .viewer-page img{
  border: none !important;
  margin: 0 auto;
  max-width: min(calc(100vw - 32px), 920px);
  max-height: min(calc(100vh - 132px), 780px);
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 12px 40px rgba(15,23,42,.08);
  border-radius: 4px;
}

@keyframes viewerSingleInFromRight{
  from{
    opacity: 0;
    transform: translateX(22px);
  }
  to{
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes viewerSingleInFromLeft{
  from{
    opacity: 0;
    transform: translateX(-22px);
  }
  to{
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes viewerSingleInSoft{
  from{
    opacity: 0;
    transform: scale(0.985);
  }
  to{
    opacity: 1;
    transform: scale(1);
  }
}
.viewer-rail.single-mode .viewer-page.swap-from-right{
  animation: viewerSingleInFromRight .32s cubic-bezier(.22, 1, .36, 1) both;
}
.viewer-rail.single-mode .viewer-page.swap-from-left{
  animation: viewerSingleInFromLeft .32s cubic-bezier(.22, 1, .36, 1) both;
}
.viewer-rail.single-mode .viewer-page.swap-enter-soft{
  animation: viewerSingleInSoft .28s ease both;
}

/* 使用必看 */
.info-entry{
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 60;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.92);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  color: var(--text);
}
.info-entry:hover{ background:#fff; border-color:rgba(15,23,42,.18); }

.info-modal{
  position: fixed;
  top:0;left:0;width:100%;height:100%;
  z-index: 70;
  background: rgba(255,255,255,.94);
  display:flex;
  align-items:center;
  justify-content:center;
}
.info-card{
  width: min(440px, 90vw);
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  padding: 24px 20px;
  box-shadow: 0 16px 60px rgba(15,23,42,.08);
  overflow-y: auto;
}
.info-title{ font-weight:950; font-size:18px; margin-bottom:16px; }
.info-content{ font-size:15px; line-height:1.7; color:var(--text); white-space:pre-wrap; word-break:break-word; }
.info-actions{ display:flex; gap:12px; justify-content:flex-end; margin-top:20px; }

.global-error-bar{
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 90;
  background: rgba(239, 68, 68, .10);
  border: 1px solid rgba(239, 68, 68, .35);
  color: rgba(153, 27, 27, .95);
  font-weight: 900;
  padding: 10px 12px;
  border-radius: 14px;
  max-width: min(720px, 92vw);
  white-space: pre-wrap;
}

/* Book landing */
.book-landing{
  min-height: 100vh;
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content:center;
  gap: 18px;
  padding: 24px 16px;
}
.book-cover-wrap{
  width: min(420px, 86vw);
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow:hidden;
  background: rgba(15,23,42,.03);
  box-shadow: 0 18px 60px rgba(15,23,42,.10);
  transition: opacity .25s ease, transform .35s ease;
}
.book-cover-wrap.is-loading{
  opacity: .35;
}
.book-cover-wrap.cover-ready{
  animation: bookCoverPop .45s ease both;
}
@keyframes bookCoverPop{
  from{ opacity: 0; transform: scale(.96); }
  to{ opacity: 1; transform: scale(1); }
}
.book-cover{
  width: 100%;
  height: 100%;
  display:block;
  object-fit: cover;
}
.book-actions{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content:center;
}
.book-hint{
  color: rgba(15,23,42,.55);
  font-weight: 800;
  font-size: 13px;
}


.viewer-page{
  scroll-snap-align: start;
  margin: 0;
  padding: 0;
}
.viewer-page img{
  display:block;
  width: auto;
  border-right: 1px solid var(--border);
}
.viewer-page:first-child img{
  border-left: 1px solid var(--border);
}

/* Mobile layout tuning */
@media (max-width: 900px){
  .setup-row{
    justify-content:center;
  }
  .control{
    min-width: min(560px, 96vw);
  }
  .editor-nav{
    flex-wrap: wrap;
  }
  .page-indicator{
    flex: 0 0 100%;
  }
  .toolbar{
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px 8px;
    gap: 12px;
    scrollbar-width: thin;
  }
  .control-inline,
  .font-control{
    width: min(96vw, 560px);
    justify-content:center;
  }
  .font-control input[type="range"]{
    width: 170px;
  }
}

/* Lightweight animation effects */
.panel,
.zine-icon-btn,
.circle-btn{
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease, background .2s ease, border-color .2s ease;
}
.panel{
  animation: fadeSlideIn .24s ease both;
}
.zine-icon-btn:hover{
  transform: translateY(-2px);
}
.circle-btn:hover{
  transform: translateY(-1px);
}
@keyframes fadeSlideIn{
  from{ opacity: 0; transform: translateY(8px);}
  to{ opacity: 1; transform: translateY(0);}
}
@media (prefers-reduced-motion: reduce){
  *{
    animation: none !important;
    transition: none !important;
  }
}

/* 全屏加载层 */
.app-loader{
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity .22s ease, visibility .22s ease;
}
.app-loader.hidden{
  display: none;
}
.app-loader-inner{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.app-loader-ring{
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(15,23,42,.12);
  border-top-color: rgba(17,24,39,.85);
  animation: appLoaderSpin .75s linear infinite;
}
.app-loader-text{
  font-weight: 850;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: .02em;
}
@keyframes appLoaderSpin{
  to{ transform: rotate(360deg); }
}

@media (max-width: 900px){
  .viewer-topbar{
    flex-wrap: wrap;
    justify-content: center;
  }
  .viewer-title{
    flex: 1 1 100%;
    order: -1;
  }
  .viewer-right-actions{
    width: 100%;
    justify-content: center;
  }
  .viewer-status{
    text-align: center;
    width: 100%;
    min-width: 0;
  }
}

