:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe4ea;
  --accent: #0f766e;
  --tomato: #ff5a3d;
  --tomato-dark: #e64124;
  --accent-2: #2563eb;
  --danger: #b42318;
  --reader-bg: #fbfaf5;
  --reader-ink: #22252c;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fff7f3 0%, #f7f8fb 28%, #f6f8f7 100%);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 20%, rgba(94, 234, 212, 0.2), transparent 28%),
    linear-gradient(145deg, #eef7f5, #f7f9fc 58%, #edf3ff);
}

.login-card {
  width: min(430px, 100%);
  padding: 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-row h1,
.brand-row p,
.reader-topbar h1,
.reader-topbar p,
.panel-head h2,
.shelf-head h2,
.modal-head h2,
.modal-head p,
.drawer-head h2 {
  margin: 0;
}

.brand-row h1 {
  font-size: 24px;
}

.brand-row p,
.muted,
.status-line,
.reader-topbar p,
.modal-head p {
  color: var(--muted);
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 12px;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: #2563eb;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px;
}

.topbar,
.reader-topbar,
.reader-actions,
.modal-head,
.drawer-head,
.shelf-head,
.panel-head,
.top-actions,
.brand {
  display: flex;
  align-items: center;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 247, 243, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.24);
}

.brand {
  gap: 8px;
  font-weight: 800;
  min-width: 0;
}

.top-actions {
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.clock-time {
  font-variant-numeric: tabular-nums;
  color: #0f766e;
  font-weight: 800;
  padding: 0 4px;
}

.mobile-hero {
  padding: 16px 6px 10px;
}

.mobile-hero p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.mobile-hero h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.status-pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 999px;
  padding: 2px 9px;
  color: #0f766e;
  background: rgba(94, 234, 212, 0.16);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.offline {
  color: #b45309;
  border-color: rgba(180, 83, 9, 0.3);
  background: rgba(251, 191, 36, 0.16);
}

.view {
  padding: 12px 0 84px;
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.remember-row {
  color: var(--muted);
  font-size: 13px;
}

.account-form {
  display: grid;
  gap: 8px;
}

.account-list {
  display: grid;
  gap: 8px;
}

.account-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.8);
}

.account-row strong {
  font-size: 14px;
}

.profile-card {
  min-height: 86px;
  margin-bottom: 12px;
  padding: 16px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 90, 61, 0.14), transparent 55%),
    #ffffff;
  border: 1px solid rgba(255, 90, 61, 0.18);
  box-shadow: 0 10px 24px rgba(129, 55, 28, 0.08);
  display: grid;
  align-content: center;
  gap: 6px;
}

.profile-card strong {
  font-size: 20px;
}

.profile-card span {
  color: var(--muted);
  font-size: 13px;
}

.compact {
  margin: 0;
}

.panel-head,
.shelf-head {
  justify-content: space-between;
  gap: 10px;
}

.panel-head h2,
.shelf-head h2 {
  font-size: 17px;
}

.primary-action,
.tool-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 12px;
  background: #fff;
  color: var(--ink);
}

.primary-action {
  background: linear-gradient(135deg, var(--tomato), var(--tomato-dark));
  color: white;
  font-weight: 800;
}

.tool-button {
  border-color: var(--line);
}

.tool-button.danger {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.25);
}

.shelf-head {
  margin: 18px 0 10px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 14px;
}

.empty-state {
  padding: 18px 4px;
}

.book-card {
  min-height: 196px;
  background: linear-gradient(155deg, #fff 0%, #fff8f4 100%);
  border: 1px solid rgba(255, 90, 61, 0.18);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
  align-content: space-between;
  box-shadow: 0 10px 24px rgba(129, 55, 28, 0.08);
}

.book-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.book-card h3::before {
  content: "";
  display: block;
  width: 48px;
  height: 64px;
  margin-bottom: 10px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent 45%),
    linear-gradient(145deg, #ff7a50, #dd3d25);
  box-shadow: inset 0 -18px 34px rgba(112, 26, 7, 0.18);
}

.book-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.book-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.reader-view {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--reader-bg);
  color: var(--reader-ink);
}

.reader-topbar,
.reader-actions {
  gap: 8px;
  padding: 10px;
  background: rgba(251, 250, 245, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.24);
}

.reader-topbar {
  justify-content: space-between;
}

.reader-topbar > div {
  min-width: 0;
  flex: 1;
  text-align: center;
}

.reader-topbar h1 {
  font-size: 16px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reader-scroller {
  overflow: auto;
  padding: 22px min(6vw, 46px) 36px;
}

.reader-scroller h2 {
  margin: 0 0 18px;
  text-align: center;
  font-size: 1.2em;
}

.reader-scroller pre {
  margin: 0 auto;
  max-width: 760px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: var(--font-size, 20px);
  line-height: var(--line-height, 1.85);
}

.reader-actions {
  justify-content: space-around;
  border-top: 1px solid rgba(148, 163, 184, 0.24);
  border-bottom: none;
}

.drawer {
  position: fixed;
  right: 10px;
  top: 64px;
  z-index: 50;
  width: min(360px, calc(100vw - 20px));
  max-height: calc(100vh - 84px);
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 25;
  width: min(1120px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid rgba(148, 163, 184, 0.24);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  font-weight: 800;
  font-size: 14px;
}

.bottom-nav button.active {
  color: var(--tomato-dark);
  background: rgba(255, 90, 61, 0.1);
}

.drawer label {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toc-list {
  display: grid;
  gap: 6px;
}

.toc-list button {
  text-align: left;
  white-space: normal;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.34);
  padding: 12px;
}

.modal-dialog {
  width: min(920px, 92vw);
  height: min(760px, 76vh);
  min-height: 480px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr;
  box-shadow: var(--shadow);
}

.modal-head {
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-address {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 80;
  transform: translateX(-50%);
  max-width: min(360px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
}

body.eye-mode {
  --reader-bg: #edf7e8;
  --reader-ink: #1f3326;
}

@media (max-width: 680px) {
  .app-shell {
    max-width: 430px;
    padding: 8px 14px 78px;
  }

  .topbar {
    padding: 8px 2px;
  }

  .brand span {
    display: none;
  }

  .action-panel {
    margin-bottom: 12px;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .book-card {
    min-height: 188px;
  }

  .panel {
    padding: 12px;
  }

  .reader-topbar {
    grid-template-columns: auto 1fr auto;
  }

  .reader-scroller {
    padding: 18px 24px 36px;
  }

  .bottom-nav {
    width: min(430px, 100%);
    padding-left: 14px;
    padding-right: 14px;
  }

  .bottom-nav button {
    font-size: 13px;
  }

  .modal-dialog {
    width: 94vw;
    height: 76vh;
    min-height: 520px;
  }

  .modal-address {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 374px) {
  .book-grid {
    grid-template-columns: 1fr;
  }
}
