:root {
  color-scheme: light;
  --bs-primary: #315fbd;
  --bs-primary-rgb: 49, 95, 189;
  --bs-success: #0f766e;
  --bs-success-rgb: 15, 118, 110;
  --bs-border-radius: 8px;
  --bs-border-radius-lg: 8px;
  --ink: #182033;
  --muted: #667085;
  --line: #d8dee9;
  --paper: #ffffff;
  --wash: #f6f8fb;
  --blue: #315fbd;
  --blue-rgb: 49, 95, 189;
  --blue-soft: #eef4ff;
  --blue-ink: #243b6b;
  --slate: #475569;
  --rose: #be123c;
  --quote-line: #94a3b8;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f6f7fb;
}

body.bg-body-tertiary {
  background-color: #f6f7fb !important;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.btn-primary {
  --bs-btn-bg: var(--blue);
  --bs-btn-border-color: var(--blue);
  --bs-btn-hover-bg: #284f9e;
  --bs-btn-hover-border-color: #284f9e;
  --bs-btn-active-bg: #223f7f;
  --bs-btn-active-border-color: #223f7f;
}

.btn-outline-primary {
  --bs-btn-color: var(--blue);
  --bs-btn-border-color: #c7d7fe;
  --bs-btn-hover-color: #284f9e;
  --bs-btn-hover-bg: var(--blue-soft);
  --bs-btn-hover-border-color: #a9c0fb;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--blue);
  --bs-btn-active-border-color: var(--blue);
}

.shell {
  max-width: 1320px;
}

.topbar {
  padding: 8px 0 0;
}

.kicker {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 22px;
  letter-spacing: 0;
}

.today-box {
  min-width: 330px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f7f9fc;
  box-shadow: inset 0 0 0 1px #e3e8f2;
}

.today-box .stat-card {
  min-height: 58px;
  padding: 9px 10px;
  background: transparent;
  box-shadow: none !important;
}

.panel {
  border-radius: 8px;
  background: #fff;
}

.main-panel {
  padding: 22px;
}

.library-panel {
  padding: 14px;
}

.library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.library-head h2 {
  margin-bottom: 0;
}

.library-random-button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.library-random-button:hover {
  background: var(--blue-soft);
}

.book-tree {
  display: grid;
  gap: 14px;
}

.folder-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.folder-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  padding: 10px 11px;
  border-left: 4px solid var(--blue);
  color: var(--blue-ink);
  background: var(--blue-soft);
  font-size: 14px;
  font-weight: 900;
}

.folder-count {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--blue-ink);
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.book-list {
  display: grid;
  gap: 4px;
  padding: 8px;
}

.book-button {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  overflow: hidden;
}

.book-button:hover,
.book-button.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.book-button.active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.book-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}

.book-content {
  min-width: 0;
}

.book-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.book-remaining {
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--blue-ink);
  background: #e0ecff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.book-button.active .book-remaining,
.book-button:hover .book-remaining {
  color: #fff;
  background: var(--blue);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(var(--blue-rgb), 0.13);
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.current-book-block {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 8px;
}

.current-book-block {
  background: var(--blue-soft);
  border-left: 4px solid var(--blue);
  box-shadow: inset 0 0 0 1px #dbeafe;
}

.focus-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.focus-bar span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.focus-bar strong {
  display: block;
  font-size: 18px;
  line-height: 1.35;
}

.book-hint {
  max-width: 220px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.book-status {
  display: grid;
  gap: 10px;
  justify-items: end;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(49, 95, 189, 0.12);
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.random-note-button {
  min-width: 96px;
}

.mobile-random-book-button {
  display: none;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.today-box .top-stats-row {
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 0;
}

.stat-card {
  min-height: 62px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.stat-card span,
.stat-card strong {
  display: block;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-card strong {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.stat-card:hover,
.stat-card.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.today-box .stat-card + .stat-card {
  border-left: 1px solid #e3e8f2 !important;
}

.today-box .stat-card:hover,
.today-box .stat-card.active {
  background: rgba(var(--blue-rgb), 0.08);
}

.review-panel {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.review-panel-head h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.plain-button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.plain-button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

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

.review-list-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 6px 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.review-list-item:hover {
  border-color: rgba(var(--blue-rgb), 0.35);
  background: var(--blue-soft);
}

.review-list-item span {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.review-list-item strong,
.review-list-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-list-item strong {
  font-size: 13px;
}

.review-list-item small {
  color: var(--muted);
  font-size: 12px;
}

.review-empty {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.review-action {
  margin-top: 10px;
}

.small-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.empty-state {
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--wash);
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.review-cards {
  display: grid;
  gap: 14px;
}

.book-tools {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  padding-top: 16px;
}

.reset-book-button {
  padding: 0;
  color: #9ca3af;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.reset-book-button:hover {
  color: #6b7280;
  text-decoration: underline;
}

.review-item {
  display: grid;
  gap: 10px;
}

.review-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  background: #f7f9fc;
  box-shadow: inset 0 0 0 1px #e3e8f2;
}

.review-card.done {
  border-color: rgba(var(--blue-rgb), 0.2);
  background: #f8fafc;
}

.quote-text {
  margin: 0;
  padding: 14px 15px 14px 16px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--quote-line);
  border-radius: 8px;
  color: #1f2937;
  background: #fff;
  line-height: 1.7;
}

.swipe-feedback {
  position: absolute;
  top: 16px;
  z-index: 2;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.94);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.swipe-feedback-left {
  left: 16px;
  color: #9f1239;
  background: #ffe4e6;
}

.swipe-feedback-right {
  right: 16px;
  color: #065f46;
  background: #d1fae5;
}

.review-card[data-swipe="left"] .swipe-feedback-left,
.review-card[data-swipe="right"] .swipe-feedback-right {
  opacity: var(--swipe-progress, 0.82);
  transform: scale(1);
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-button {
  min-height: 34px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.memory-choices .choice-button {
  flex: 1 1 110px;
  min-height: 44px;
  text-align: center;
  background: #fff;
}

.choice-button:hover,
.choice-button.selected {
  border-color: rgba(var(--blue-rgb), 0.38);
  color: var(--blue);
  background: var(--blue-soft);
}

.rewrite-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f1f6ff;
  box-shadow: inset 0 0 0 1px #dbeafe;
}

.optional-rewrite {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.optional-rewrite summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.optional-rewrite textarea {
  margin-top: 10px;
}

.rewrite-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.rewrite-history {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.rewrite-history:empty {
  display: none;
}

.rewrite-entry {
  padding: 10px 12px;
  border: 1px solid #e3e8f2;
  border-radius: 8px;
  background: #fff;
}

.rewrite-entry time {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rewrite-entry p {
  margin-bottom: 0;
  color: var(--ink);
  line-height: 1.55;
}

@media (max-width: 880px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .layout,
  .focus-bar,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .today-box {
    width: 100%;
    min-width: 0;
  }

  .today-box .top-stats-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .book-hint {
    max-width: none;
    text-align: left;
  }

  .book-status {
    justify-items: start;
  }
}

@media (max-width: 760px) {
  html,
  body {
    min-height: 100%;
    overscroll-behavior-x: none;
  }

  body {
    overflow-x: hidden;
    background: #edf2f7;
  }

  .shell {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    padding: 0 !important;
  }

  .topbar,
  .library-panel,
  .review-panel {
    display: none !important;
  }

  .layout.row {
    display: block;
    margin: 0;
  }

  .layout.row > * {
    padding: 0;
  }

  .main-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 100dvh;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
    border-radius: 0;
    background: #edf2f7;
    box-shadow: none !important;
  }

  .current-book-block {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-left: 0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  }

  .focus-bar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .focus-bar span {
    margin-bottom: 3px;
    font-size: 11px;
  }

  .focus-bar strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .book-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }

  .book-hint {
    min-width: 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
  }

  .book-actions {
    flex: 0 0 auto;
    gap: 6px;
  }

  .mobile-random-book-button {
    display: inline-flex;
  }

  .random-note-button,
  .mobile-random-book-button {
    min-width: 72px;
    min-height: 32px;
    justify-content: center;
    border-radius: 8px;
    font-size: 12px;
  }

  .empty-state {
    align-self: center;
  }

  .review-cards {
    display: grid;
    min-height: 0;
  }

  .review-item {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 0;
  }

  .review-card {
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: calc(100dvh - 190px);
    max-height: calc(100dvh - 190px);
    padding: 16px 14px 14px;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14) !important;
    touch-action: pan-y;
    transform: translateX(var(--swipe-x, 0)) rotate(var(--swipe-rotate, 0));
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    user-select: none;
  }

  .review-card.swiping {
    transition: box-shadow 0.12s ease;
  }

  .review-card[data-swipe="left"] {
    box-shadow: -14px 18px 38px rgba(190, 18, 60, 0.18) !important;
  }

  .review-card[data-swipe="right"] {
    box-shadow: 14px 18px 38px rgba(15, 118, 110, 0.18) !important;
  }

  .review-card.swipe-out-left {
    opacity: 0;
    transform: translateX(-115vw) rotate(-12deg);
  }

  .review-card.swipe-out-right {
    opacity: 0;
    transform: translateX(115vw) rotate(12deg);
  }

  .quote-text {
    display: block;
    min-height: 0;
    overflow-y: auto;
    padding: 48px 16px 18px;
    border-left-width: 0;
    color: #111827;
    font-size: 19px;
    line-height: 1.82;
    -webkit-overflow-scrolling: touch;
  }

  .memory-choices {
    flex-wrap: nowrap;
    gap: 10px;
  }

  .memory-choices .choice-button {
    min-height: 52px;
    border-radius: 8px;
    font-size: 16px;
  }

  .memory-choices [data-memory="忘了"] {
    border-color: #fecdd3;
    color: #9f1239;
    background: #fff1f2;
  }

  .memory-choices [data-memory="记得"] {
    border-color: #99f6e4;
    color: #115e59;
    background: #f0fdfa;
  }

  .rewrite-block {
    padding: 10px 12px;
    background: #f1f6ff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  }

  .book-tools {
    margin-top: 8px;
    padding-top: 6px;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 34px;
  }
}
