/* 打字机 · Noir 暗调剪贴簿 × 暗色学院 */

.miya-typewriter-app {
  --tw-ink: #1a1a1a;
  --tw-parchment: #dcd0c0;
  --tw-cream: #e8e4d9;
  --tw-paper: #f5f5dc;
  --tw-walnut: #0a0a0a;
  --tw-mahogany: #121212;
  --tw-brass: #8b7355;
  --tw-gold: #a68b6d;
  --tw-copper: #6b5344;
  --tw-forest: #1b3022;
  --tw-burgundy: #8b0000;
  --tw-frost: #e0e0e0;
  --tw-snow: #ffffff;
  --tw-muted: rgba(224, 224, 224, 0.42);
  --tw-line: rgba(255, 255, 255, 0.1);
  --tw-serif: "Cormorant Garamond", "Noto Serif SC", serif;
  --tw-script: "Great Vibes", cursive;
  --tw-display: "Italiana", "Noto Serif SC", serif;
  --tw-ui: "Jost", "Noto Sans SC", sans-serif;
  --tw-safe-t: env(safe-area-inset-top, 0px);
  --tw-safe-b: env(safe-area-inset-bottom, 0px);
  position: fixed;
  inset: 0;
  z-index: 520;
  display: flex;
  flex-direction: column;
  background: var(--tw-mahogany);
  color: var(--tw-frost);
  font-family: var(--tw-ui);
  overflow: hidden;
}

.miya-typewriter-app[hidden] { display: none !important; }

/* ═══ 连接加载层 ═══ */
.tw-boot {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 55% 45% at 50% 40%, rgba(139, 115, 85, 0.08) 0%, transparent 65%),
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 35%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(168deg, #000000 0%, var(--tw-mahogany) 45%, #0a0a0a 100%);
  transition: opacity 0.55s ease, visibility 0.55s;
}

.tw-boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tw-boot__frame {
  position: relative;
  width: min(88vw, 320px);
  padding: 36px 28px 32px;
  text-align: center;
}

.tw-boot__corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--tw-brass);
  opacity: 0.7;
}
.tw-boot__corner--tl { top: 0; left: 0; border-width: 2px 0 0 2px; }
.tw-boot__corner--tr { top: 0; right: 0; border-width: 2px 2px 0 0; }
.tw-boot__corner--bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.tw-boot__corner--br { bottom: 0; right: 0; border-width: 0 2px 2px 0; }

.tw-boot__emblem {
  font-family: var(--tw-display);
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--tw-brass);
  text-transform: uppercase;
  margin: 0 0 20px;
}

.tw-boot__typewriter {
  width: 120px;
  height: 72px;
  margin: 0 auto 24px;
  position: relative;
}

.tw-boot__tw-body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 48px;
  background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 100%);
  border-radius: 4px 4px 2px 2px;
  border: 1px solid rgba(139, 115, 85, 0.35);
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

.tw-boot__tw-platen {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 28px;
  background: var(--tw-cream);
  border-radius: 2px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
  overflow: hidden;
}

.tw-boot__tw-paper {
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  font-family: var(--tw-serif);
  font-size: 7px;
  color: var(--tw-ink);
  text-align: left;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
}

.tw-boot__tw-keys {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
}

.tw-boot__tw-key {
  width: 8px;
  height: 6px;
  background: #0a0a0a;
  border-radius: 1px;
  border: 0.5px solid var(--tw-brass);
  animation: tw-key-tap 0.8s ease infinite;
}
.tw-boot__tw-key:nth-child(2) { animation-delay: 0.12s; }
.tw-boot__tw-key:nth-child(3) { animation-delay: 0.24s; }
.tw-boot__tw-key:nth-child(4) { animation-delay: 0.36s; }
.tw-boot__tw-key:nth-child(5) { animation-delay: 0.48s; }

@keyframes tw-key-tap {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(2px); opacity: 1; background: var(--tw-brass); }
}

.tw-boot__status {
  font-family: var(--tw-serif);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--tw-frost);
  min-height: 22px;
  margin: 0 0 16px;
}

.tw-boot__status.is-success {
  color: var(--tw-gold);
  font-style: italic;
}

.tw-boot__bar {
  width: 100%;
  height: 3px;
  background: rgba(139, 115, 85, 0.18);
  border-radius: 2px;
  overflow: hidden;
}

.tw-boot__bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--tw-copper), var(--tw-gold));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.tw-boot__flourish {
  margin: 18px 0 0;
  font-family: var(--tw-script);
  font-size: 22px;
  color: var(--tw-brass);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.tw-boot__flourish.is-show {
  opacity: 1;
  transform: translateY(0);
}

/* ═══ 主界面氛围层 ═══ */
.tw-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 55% at 12% 8%, rgba(139, 115, 85, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse 45% 38% at 90% 88%, rgba(27, 48, 34, 0.14) 0%, transparent 50%),
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 30%, rgba(0, 0, 0, 0.65) 100%);
}

.tw-veil::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.tw-veil::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 79px,
    rgba(139, 115, 85, 0.18) 79px,
    rgba(139, 115, 85, 0.18) 80px
  );
}

.tw-rule-deco {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  opacity: 0.35;
}
.tw-rule-deco--h {
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tw-brass), transparent);
}
.tw-rule-deco--h1 { top: calc(108px + var(--tw-safe-t)); }
.tw-rule-deco--h2 { bottom: calc(68px + var(--tw-safe-b)); }

/* ═══ 顶栏 ═══ */
.tw-masthead {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: calc(12px + var(--tw-safe-t)) 16px 10px;
}

.tw-back {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(139, 115, 85, 0.35);
  border-radius: 50%;
  background: rgba(26, 26, 26, 0.35);
  color: var(--tw-frost);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.tw-back:active { background: rgba(139, 115, 85, 0.2); }

.tw-masthead__center {
  text-align: center;
  min-width: 0;
}

.tw-masthead__script {
  margin: 0;
  font-family: var(--tw-script);
  font-size: 18px;
  color: var(--tw-brass);
  line-height: 1;
}

.tw-masthead__title {
  margin: 2px 0 0;
  font-family: var(--tw-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--tw-snow);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  line-height: 1.1;
}

.tw-masthead__sub {
  margin: 3px 0 0;
  font-size: 8px;
  letter-spacing: 0.32em;
  color: rgba(224, 224, 224, 0.42);
  text-transform: uppercase;
}

.tw-import-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px 7px 10px;
  border: 1px solid rgba(139, 115, 85, 0.45);
  border-radius: 2px;
  background:
    linear-gradient(135deg, rgba(26, 26, 26, 0.9) 0%, rgba(18, 18, 18, 0.95) 100%);
  color: var(--tw-frost);
  font-family: var(--tw-ui);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.12em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.tw-import-btn::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 0.5px solid rgba(166, 139, 109, 0.2);
  pointer-events: none;
}
.tw-import-btn:active {
  border-color: var(--tw-gold);
  box-shadow: 0 0 12px rgba(166, 139, 109, 0.2);
}
.tw-import-btn svg {
  width: 14px;
  height: 14px;
  stroke: var(--tw-brass);
  fill: none;
  stroke-width: 1.4;
}

/* ═══ 双页切换 ═══ */
.tw-pages {
  flex: 1;
  position: relative;
  min-height: 0;
  z-index: 2;
}

.tw-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.4s;
}

.tw-page.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* ═══ 底栏 Tab ═══ */
.tw-tabbar {
  position: relative;
  z-index: 6;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0 20px calc(10px + var(--tw-safe-b));
  background: linear-gradient(0deg, rgba(10, 10, 10, 0.95) 0%, transparent 100%);
}

.tw-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: rgba(224, 224, 224, 0.38);
  font-family: var(--tw-ui);
  font-size: 9px;
  letter-spacing: 0.2em;
  cursor: pointer;
  position: relative;
  transition: color 0.25s;
}

.tw-tab::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 28px;
  height: 1.5px;
  background: var(--tw-gold);
  transition: transform 0.3s ease;
}
.tw-tab.is-active { color: var(--tw-snow); }
.tw-tab.is-active::after { transform: translateX(-50%) scaleX(1); }

.tw-tab__glyph {
  font-family: var(--tw-display);
  font-size: 20px;
  line-height: 1;
  color: var(--tw-brass);
  opacity: 0.55;
  transition: opacity 0.25s;
}
.tw-tab.is-active .tw-tab__glyph { opacity: 1; }

/* ═══ 编纂室 · 博物馆展厅 ═══ */
.tw-shelf-stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 24px;
  background:
    radial-gradient(ellipse 90% 30% at 50% 0%, rgba(139, 115, 85, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(0, 0, 0, 0.55) 0%, transparent 70%),
    linear-gradient(180deg, #111111 0%, #080808 45%, #050505 100%);
  position: relative;
}

.tw-shelf-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 79px,
      rgba(255, 255, 255, 0.012) 79px,
      rgba(255, 255, 255, 0.012) 80px
    );
  z-index: 0;
}

.tw-shelf-intro {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 12px 24px 28px;
}

.tw-shelf-intro__line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}
.tw-shelf-intro__line::before,
.tw-shelf-intro__line::after {
  content: "";
  flex: 1;
  max-width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tw-brass), transparent);
}

.tw-shelf-intro__vol {
  font-size: 8px;
  letter-spacing: 0.3em;
  color: var(--tw-brass);
}

.tw-shelf-intro__quote {
  margin: 0;
  font-family: var(--tw-serif);
  font-size: 13px;
  font-style: italic;
  color: rgba(224, 224, 224, 0.55);
  line-height: 1.5;
}

.tw-shelf-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 10px;
  max-width: 420px;
  margin: 0 auto;
  padding: 8px 12px 80px;
}

/* 空状态 */
.tw-empty-shelf {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 28px;
  max-width: 280px;
  margin: 0 auto;
}

.tw-empty-shelf__frame {
  position: relative;
  padding: 28px 20px;
  border: 1px solid rgba(139, 115, 85, 0.35);
  background: linear-gradient(160deg, var(--tw-cream) 0%, var(--tw-parchment) 100%);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

.tw-empty-shelf__script {
  margin: 0 0 12px;
  font-family: var(--tw-script);
  font-size: 28px;
  color: var(--tw-brass);
}

.tw-empty-shelf__text {
  margin: 0;
  font-family: var(--tw-serif);
  font-size: 13px;
  font-style: italic;
  color: rgba(26, 26, 26, 0.65);
  line-height: 1.6;
}

/* ═══ 共读室 ═══ */
.tw-salon {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tw-salon__header {
  flex-shrink: 0;
  text-align: center;
  padding: 6px 24px 14px;
}

.tw-salon__script {
  margin: 0;
  font-family: var(--tw-script);
  font-size: 26px;
  color: var(--tw-brass);
}

.tw-salon__title {
  margin: 4px 0 0;
  font-family: var(--tw-display);
  font-size: 20px;
  letter-spacing: 0.24em;
  color: var(--tw-snow);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.tw-salon__badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border: 0.5px solid rgba(139, 115, 85, 0.35);
  font-size: 8px;
  letter-spacing: 0.22em;
  color: rgba(224, 224, 224, 0.4);
}

.tw-salon__scene {
  flex: 1;
  min-height: 0;
  position: relative;
  margin: 0 12px;
  border: 1px solid rgba(139, 115, 85, 0.2);
  border-radius: 2px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(139, 115, 85, 0.06) 0%, transparent 60%),
    linear-gradient(180deg, rgba(18, 18, 18, 0.75) 0%, rgba(0, 0, 0, 0.9) 100%);
  overflow: hidden;
}

.tw-salon__curtain {
  position: absolute;
  top: 0;
  width: 18%;
  height: 100%;
  background: linear-gradient(180deg, var(--tw-burgundy), rgba(139, 0, 0, 0.25));
  opacity: 0.4;
  pointer-events: none;
}
.tw-salon__curtain--l { left: 0; border-radius: 0 0 40% 0; }
.tw-salon__curtain--r { right: 0; border-radius: 0 0 0 40%; }

.tw-salon__chandelier {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 28px;
  pointer-events: none;
}
.tw-salon__chandelier::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 10px;
  background: var(--tw-brass);
}
.tw-salon__chandelier::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 14px;
  background: radial-gradient(ellipse, rgba(201,164,92,0.5), transparent);
  border-radius: 50%;
}

.tw-salon__floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(26, 26, 26, 0.3) 0px,
      rgba(26, 26, 26, 0.3) 28px,
      rgba(18, 18, 18, 0.2) 28px,
      rgba(18, 18, 18, 0.2) 30px
    );
  opacity: 0.5;
}

.tw-salon__table {
  position: absolute;
  bottom: 28%;
  left: 50%;
  transform: translateX(-50%);
  width: 56%;
  height: 8px;
  background: linear-gradient(180deg, #3a3a3a, #1a1a1a);
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.tw-salon__book-open {
  position: absolute;
  bottom: calc(28% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 44%;
  height: 32px;
  display: flex;
  gap: 1px;
}
.tw-salon__book-page {
  flex: 1;
  background: var(--tw-cream);
  border-radius: 1px 2px 0 0;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
  position: relative;
}
.tw-salon__book-page::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  height: 1px;
  background: rgba(26,20,16,0.12);
  box-shadow: 0 6px 0 rgba(26,20,16,0.08), 0 12px 0 rgba(26,20,16,0.06);
}

.tw-salon__chair {
  position: absolute;
  bottom: 14%;
  width: 22%;
  height: 18%;
}
.tw-salon__chair--l { left: 8%; }
.tw-salon__chair--r { right: 8%; }

.tw-salon__chair-back {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 55%;
  background: linear-gradient(180deg, var(--tw-forest), #1a3028);
  border-radius: 6px 6px 2px 2px;
  border: 1px solid rgba(184,149,107,0.2);
}
.tw-salon__chair-seat {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 35%;
  background: #2a4038;
  border-radius: 3px;
  border: 1px solid rgba(184,149,107,0.15);
}

.tw-salon__avatar {
  position: absolute;
  bottom: 52%;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d4c4a8, #8b6a4a);
  border: 1.5px solid var(--tw-brass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--tw-serif);
  font-size: 12px;
  color: var(--tw-ink);
}
.tw-salon__chair--r .tw-salon__avatar {
  background: radial-gradient(circle at 35% 30%, #c8b8d8, #6a5a7a);
}

.tw-salon__panels {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 14px 8px;
}

.tw-salon__panel {
  padding: 12px 10px;
  border: 1px solid rgba(139, 115, 85, 0.35);
  background: linear-gradient(145deg, var(--tw-cream) 0%, var(--tw-parchment) 100%);
  border-radius: 2px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.tw-salon__panel-lbl {
  margin: 0 0 6px;
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--tw-brass);
  text-transform: uppercase;
}

.tw-salon__panel-val {
  margin: 0;
  font-family: var(--tw-serif);
  font-size: 12px;
  color: var(--tw-ink);
  font-style: italic;
}

.tw-salon__chat-preview {
  flex-shrink: 0;
  margin: 0 14px 12px;
  padding: 14px 12px;
  border: 1px solid rgba(139, 115, 85, 0.3);
  background: linear-gradient(160deg, var(--tw-cream) 0%, var(--tw-parchment) 100%);
  min-height: 72px;
  position: relative;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

.tw-salon__chat-preview::before {
  content: "‹ reading in progress ›";
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 7px;
  letter-spacing: 0.15em;
  color: rgba(139, 115, 85, 0.35);
  font-style: italic;
}

.tw-salon__chat-line {
  margin: 0 0 6px;
  font-family: var(--tw-serif);
  font-size: 11px;
  color: rgba(26, 26, 26, 0.72);
  line-height: 1.5;
}
.tw-salon__chat-line:last-child { margin-bottom: 0; }
.tw-salon__chat-line em {
  font-style: normal;
  color: var(--tw-brass);
  font-size: 9px;
  letter-spacing: 0.1em;
  margin-right: 6px;
}

.tw-salon__soon {
  flex-shrink: 0;
  text-align: center;
  padding: 0 20px 6px;
  font-size: 8px;
  letter-spacing: 0.18em;
  color: rgba(139, 115, 85, 0.35);
}

/* ═══ 阅读界面 · 全屏沉浸 ═══ */
.miya-typewriter-app.is-reading .tw-masthead,
.miya-typewriter-app.is-reading .tw-pages,
.miya-typewriter-app.is-reading .tw-tabbar,
.miya-typewriter-app.is-reading .tw-veil,
.miya-typewriter-app.is-reading .tw-rule-deco,
.miya-typewriter-app.is-reading .tw-boot:not(.is-done) {
  visibility: hidden;
  pointer-events: none;
}

.tw-reader {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 120% 80% at 20% 0%, rgba(255, 255, 255, 0.35) 0%, transparent 55%),
    linear-gradient(155deg, var(--tw-paper) 0%, var(--tw-cream) 42%, var(--tw-parchment) 100%);
  color: var(--tw-ink);
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.28s ease, visibility 0.28s;
}

.tw-reader[hidden] {
  display: none !important;
}

.tw-reader.is-open {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
}

.tw-reader__book {
  flex: 1;
  min-height: 0;
  display: flex;
  padding:
    calc(18px + var(--tw-safe-t))
    20px
    calc(18px + var(--tw-safe-b));
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.tw-reader__spread {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.tw-reader__page {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.tw-reader__page-body {
  min-height: 100%;
}

.tw-reader__chrome {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 20;
  padding-top: var(--tw-safe-t);
  background: linear-gradient(180deg, rgba(10, 10, 10, 0.82) 0%, rgba(10, 10, 10, 0.45) 55%, transparent 100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.26s ease, visibility 0.26s ease, transform 0.26s ease;
}

.tw-reader.is-show-chrome .tw-reader__chrome {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.tw-reader__head {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 20px;
}

.tw-reader__back {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: var(--tw-frost);
  font-size: 17px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.tw-reader__title-wrap {
  text-align: center;
  min-width: 0;
  padding: 0 4px;
}

.tw-reader__script {
  margin: 0;
  font-family: var(--tw-script);
  font-size: 14px;
  color: var(--tw-brass);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw-reader__title {
  margin: 1px 0 0;
  font-family: var(--tw-serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--tw-frost);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw-reader__folio {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(224, 224, 224, 0.72);
  white-space: nowrap;
  padding-right: 4px;
}

.tw-reader__page,
.tw-reader__page-body {
  font-family: var(--tw-serif);
  font-size: 15px;
  line-height: 1.82;
}

.tw-reader__page-no {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(26, 26, 26, 0.35);
  font-style: italic;
}

.tw-reader__page-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  opacity: 0.25;
}
.tw-reader__page-corner--tl { top: 8px; left: 8px; border-top: 1px solid var(--tw-ink); border-left: 1px solid var(--tw-ink); }
.tw-reader__page-corner--br { bottom: 8px; right: 8px; border-bottom: 1px solid var(--tw-ink); border-right: 1px solid var(--tw-ink); }

.tw-reader__dropcap {
  float: left;
  font-family: var(--tw-display);
  font-size: 42px;
  line-height: 0.85;
  margin: 2px 8px 0 0;
  color: var(--tw-burgundy);
}

.tw-reader__text {
  margin: 0;
  text-align: justify;
  hyphens: auto;
}

.tw-reader__ornament {
  text-align: center;
  margin: 12px 0;
  font-size: 10px;
  color: rgba(26, 26, 26, 0.25);
  letter-spacing: 0.3em;
}

/* ═══ Toast ═══ */
.tw-toast {
  position: fixed;
  bottom: calc(80px + var(--tw-safe-b));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid rgba(139, 115, 85, 0.4);
  color: var(--tw-snow);
  font-size: 11px;
  letter-spacing: 0.06em;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
.tw-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══ 导入进度 ═══ */
.tw-import-progress {
  position: absolute;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0.24s;
}
.tw-import-progress.is-show {
  opacity: 1;
  visibility: visible;
}
.tw-import-progress__veil {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 8, 0.58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.tw-import-progress__panel {
  position: relative;
  z-index: 1;
  width: min(280px, calc(100% - 48px));
  padding: 22px 20px 18px;
  border: 1px solid rgba(139, 115, 85, 0.45);
  background:
    linear-gradient(160deg, rgba(245, 240, 230, 0.98) 0%, rgba(232, 224, 208, 0.98) 100%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.tw-import-progress__title {
  margin: 0 0 6px;
  font-family: var(--tw-display);
  font-size: 11px;
  letter-spacing: 0.28em;
  color: rgba(26, 26, 26, 0.45);
  text-transform: uppercase;
}
.tw-import-progress__status {
  margin: 0 0 14px;
  font-family: var(--tw-serif);
  font-size: 14px;
  color: var(--tw-ink);
  line-height: 1.5;
}
.tw-import-progress__bar {
  height: 4px;
  background: rgba(26, 26, 26, 0.1);
  overflow: hidden;
}
.tw-import-progress__fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--tw-burgundy), var(--tw-brass));
  transition: width 0.18s ease;
}
.tw-import-progress__pct {
  margin: 8px 0 0;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(26, 26, 26, 0.5);
  text-align: right;
}

/* 隐藏文件输入 */
.tw-file-input { display: none; }
