:root {
  --paper: #f5f1e8;
  --ink: #2f2a24;
  --muted: #8a8070;
  --line: #ddd5c6;
  --accent: #b4472d;
  --shadow: 0 12px 32px rgba(47, 42, 36, 0.16);
}

* {
  box-sizing: border-box;
}

/* 浏览器默认的 [hidden] 只是 display:none，会被下面的 .login-form{display:flex} 盖掉，
   所以这里必须显式加 !important，否则登录框藏不住 */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #ece7dc;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 阅读页 ---------- */
.reader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100%;
  padding: 24px 16px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(880px, 100%);
  overflow: hidden;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.page-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  user-select: none;
}

/* ---------- 文字页 ---------- */
.text-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  width: 100%;
  min-height: min(560px, calc(100vh - 200px));
  padding: 56px 48px;
  background: var(--paper);
}

.text-page-title {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 6px;
  text-align: center;
}

.text-page-line {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 2.1;
  letter-spacing: 1px;
  text-align: center;
  white-space: pre-wrap;
}

.slide-from-right {
  animation: slideFromRight 260ms ease-out;
}

.slide-from-left {
  animation: slideFromLeft 260ms ease-out;
}

@keyframes slideFromRight {
  from { transform: translateX(6%); opacity: 0.4; }
  to   { transform: translateX(0);  opacity: 1; }
}

@keyframes slideFromLeft {
  from { transform: translateX(-6%); opacity: 0.4; }
  to   { transform: translateX(0);   opacity: 1; }
}

.loading {
  position: absolute;
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 14px;
}

.nav-button {
  position: fixed;
  top: 50%;
  width: 48px;
  height: 48px;
  min-width: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}

.nav-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.prev { left: 12px; }
.next { right: 12px; }

/* 自动播放被拦时出现的一句话提示 */
.audio-hint {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: var(--shadow);
  animation: hintIn 320ms ease-out;
}

@keyframes hintIn {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.status-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(880px, 100%);
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 240ms ease-out;
}

/* ---------- 看板页 ---------- */
body.admin {
  padding: 24px 16px 48px;
  background: #f2f4f7;
}

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  max-width: 900px;
  margin: 0 auto 24px;
}

.admin-header h1 {
  flex: 1;
  margin: 0;
  font-size: 20px;
}

.connection {
  padding: 4px 10px;
  border-radius: 999px;
  background: #e3e7ee;
  color: #5a6475;
  font-size: 13px;
}

.connection.connected {
  background: #dff3e4;
  color: #1f6b3a;
}

.connection.disconnected {
  background: #fbe3e0;
  color: #a33a2a;
}

.login-form,
.panel,
.online-total {
  max-width: 900px;
  margin: 0 auto 16px;
  padding: 20px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(20, 30, 50, 0.06);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form input {
  padding: 10px 12px;
  border: 1px solid #c8cfdb;
  border-radius: 8px;
  font-size: 15px;
}

.login-form button,
.admin-header button {
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: #2f5bd7;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.admin-header button {
  padding: 6px 12px;
  font-size: 13px;
  background: #6b7488;
}

.login-error {
  margin: 0;
  color: #a33a2a;
  font-size: 14px;
}

.online-total {
  font-size: 18px;
  color: #4a5468;
}

.online-total span {
  font-size: 44px;
  font-weight: 700;
  color: #1d2433;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 15px;
  color: #4a5468;
}

.panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.distribution-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 14px;
}

.distribution-label {
  width: 78px;
  flex-shrink: 0;
  color: #4a5468;
}

.distribution-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.distribution-bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #2f5bd7;
}

.distribution-count {
  width: 48px;
  text-align: right;
  color: #6b7488;
}

.ip-card {
  padding: 12px 0;
  border-bottom: 1px solid #eef1f6;
}

.ip-card:last-child {
  border-bottom: 0;
}

.ip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ip-address {
  color: #1d2433;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ip-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: #e3e7ee;
  color: #5a6475;
  font-size: 12px;
}

.ip-badge.online {
  background: #dff3e4;
  color: #1f6b3a;
}

.ip-line {
  margin: 2px 0;
  color: #4a5468;
  font-size: 14px;
  line-height: 1.6;
}

.ip-meta {
  color: #8a93a5;
  font-size: 13px;
}

.ip-geo {
  margin-bottom: 4px;
  color: #6b7488;
  font-size: 13px;
}

.ip-dwell {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f2f5fc;
  color: #2f5bd7;
  font-size: 13px;
}

/* ---------- 网站开关 ---------- */
.admin-header .site-toggle {
  background: #a33a2a;
}

.admin-header .site-toggle.is-closed {
  background: #1f6b3a;
}

.site-status {
  max-width: 900px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fbe3e0;
  color: #a33a2a;
  font-size: 14px;
}

.poll-hint {
  max-width: 900px;
  margin: 16px auto 0;
  color: #9aa3b4;
  font-size: 13px;
  text-align: center;
}

/* 网站被主人关掉后，访客看到的样子 */
.closed-message {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 1px;
  text-align: center;
  padding: 24px;
}

.activity-row:last-child {
  border-bottom: 0;
}

.empty {
  padding: 8px 0;
  color: #9aa3b4;
  font-size: 14px;
}

/* ---------- 手机 ---------- */
@media (max-width: 640px) {
  /* 手机上保持垂直居中、贴左右边缘——
     放到底部会和页码条叠在一起 */
  .nav-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 22px;
  }

  .prev { left: 8px; }
  .next { right: 8px; }

  .page-image {
    max-height: calc(100vh - 200px);
  }

  .text-page {
    min-height: calc(100vh - 220px);
    padding: 32px 24px;
  }

  .text-page-line {
    font-size: 16px;
    line-height: 2;
  }

}
