:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #667085;
  --line: #e6e8eb;
  --brand: #1a7a5c;
  --brand-dark: #125c45;
  --accent: #f2a154;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.brand {
  color: var(--brand-dark);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  height: 24px;
  width: auto;
  display: block;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 88px;
}

.card,
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 14px;
}

.login-card {
  margin-top: 48px;
}

h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

h2 {
  font-size: 17px;
  margin: 18px 0 8px;
}

p {
  margin: 0 0 10px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

ul {
  padding-left: 20px;
  margin: 6px 0;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--ink);
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.stack {
  display: flex;
  flex-direction: column;
}

.button {
  display: inline-block;
  text-align: center;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  cursor: pointer;
}

.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.button.loading {
  opacity: 0.8;
  pointer-events: none;
}

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.button.small {
  padding: 7px 12px;
  font-size: 14px;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

.actions .button {
  flex: 1;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #eef6f2;
  color: var(--brand-dark);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 14px;
}

.qa {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.qa:first-of-type {
  border-top: 0;
}

.q {
  font-weight: 700;
}

.a {
  color: #303a47;
}

.source-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.web-a {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.feedback-part {
  margin-top: 14px;
}

.feedback-part + .feedback-part {
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: #fdf7ef;
  color: #5a4a33;
  font-size: 14px;
}

blockquote footer {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.thread {
  margin-top: 14px;
}

.messages {
  margin-bottom: 12px;
}

.message {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fdecea;
  color: #8a2b1e;
}

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.home-grid {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.home-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 16px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.home-card:hover {
  border-color: var(--brand);
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.08);
}

.home-card:active {
  transform: translateY(1px);
}

.home-icon {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 14px;
}

.home-card-ask .home-icon {
  background: #e8f3ff;
}

.home-card-catalog .home-icon {
  background: #eef6f2;
}

.home-card-random .home-icon {
  background: #fdf3e7;
}

.home-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.home-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 3px;
}

.home-card-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.home-arrow {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 26px;
  font-weight: 300;
}

.part-title {
  font-size: 15px;
  color: var(--brand-dark);
  margin: 14px 0 6px;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
}

.chapter-list {
  list-style: none;
  padding: 0;
  margin: 4px 0;
}

.chapter-list li {
  border-top: 1px solid var(--line);
}

.chapter-list li:first-child {
  border-top: 0;
}

.chapter-list a {
  display: flex;
  gap: 10px;
  padding: 11px 4px;
  color: var(--ink);
  text-decoration: none;
}

.chapter-summary {
  background: #f6f8f7;
  border-radius: 10px;
  padding: 12px 14px;
  color: #303a47;
  margin-top: 10px;
}

.section-row {
  padding: 0;
}

.section-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  color: var(--ink);
  text-decoration: none;
}

.section-title {
  font-weight: 600;
}

.read-mark {
  color: var(--brand-dark);
  font-size: 13px;
  white-space: nowrap;
}

.subsection-list {
  padding: 0 16px 12px;
  color: var(--muted);
  line-height: 1.55;
}

.continue-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #eef6f2;
  border: 1px solid #d5e8df;
  color: var(--ink);
  text-decoration: none;
}

.continue-label {
  font-size: 13px;
  color: var(--brand-dark);
  font-weight: 700;
  white-space: nowrap;
}

.continue-text {
  flex: 1;
  font-size: 14px;
  color: #303a47;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 26px;
}

.chapter-title {
  flex: 1;
}

.section-title {
  font-size: 17px;
  color: var(--brand-dark);
  margin: 20px 0 6px;
}

.chapter-body p {
  color: #303a47;
}

.ask-bar {
  margin-top: 18px;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: 76px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.18);
  cursor: pointer;
  z-index: 20;
}

.fab:active {
  background: var(--brand-dark);
}

.notice {
  background: #eef6f2;
  color: var(--brand-dark);
  padding: 10px 12px;
  border-radius: 10px;
  margin: 12px 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  background: var(--card);
}

.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
}

.checkin-item {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.checkin-item:first-of-type {
  border-top: 0;
}

.checkin-item .a {
  margin: 6px 0 4px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 22px;
  color: var(--brand-dark);
}

.stat span {
  font-size: 12px;
  color: var(--muted);
}

.scores {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.score {
  flex: 1;
  background: #eef6f2;
  color: var(--brand-dark);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  font-size: 14px;
}

.calendar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.day {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 14px;
}

.day.done {
  background: var(--brand);
  color: #fff;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.inline-form input {
  flex: 1;
}

.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 12px;
}

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottomnav a {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.bottomnav a:first-child {
  color: var(--brand-dark);
  font-weight: 700;
}

.site-footer {
  text-align: center;
  padding: 20px 16px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer--nav {
  padding-bottom: 88px;
}

/* 打卡图片上传 */
.image-upload {
  margin-top: 4px;
}

.image-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.image-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  line-height: 20px;
  padding: 0;
  cursor: pointer;
}

.drop-zone {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}

.drop-zone input[type="file"] {
  display: none;
}

.drop-zone.dragging {
  border-color: var(--brand);
  background: rgba(26, 122, 92, 0.06);
}

/* 打卡反馈上下文与图片 */
.checkin-context h1 {
  margin: 0 0 6px;
}

.checkin-chapter {
  font-size: 20px;
}

.checkin-question {
  font-weight: 600;
  color: var(--brand-dark);
  margin: 4px 0 0;
}

.checkin-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

.checkin-images img {
  width: 100%;
  max-width: 240px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* 分享图弹窗 */
.share-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.share-modal[hidden] {
  display: none;
}

.share-modal-inner {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  max-width: 360px;
  width: 100%;
}

.share-modal-inner img {
  width: 100%;
  border-radius: 8px;
  display: block;
}
