:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-soft: #e9efeb;
  --text: #1f2a25;
  --muted: #68756f;
  --line: #d9e0dc;
  --primary: #0d6f5c;
  --primary-dark: #095746;
  --accent: #c8683d;
  --warning: #b68a2d;
  --danger: #b6413c;
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

body {
  min-height: 100dvh;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100dvh;
  max-width: 920px;
  margin: 0 auto;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
}

.brand p {
  margin: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.send-button,
.text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.icon-button svg,
.send-button svg,
.tab svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-content {
  flex: 1;
  padding-bottom: calc(76px + var(--safe-bottom));
}

.view {
  display: none;
  min-height: 100%;
  padding: 18px 16px 28px;
}

.view.is-active {
  display: block;
}

.view-heading {
  min-height: 52px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.view-heading h1 {
  margin: 2px 0 0;
  font-size: 25px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #b9d8cf;
  border-radius: 999px;
  color: var(--primary-dark);
  background: #edf7f3;
  font-size: 12px;
  white-space: nowrap;
}

.status-pill.is-offline {
  border-color: #e3c7b9;
  color: #8b482b;
  background: #fcf0eb;
}

.chat-list {
  min-height: 330px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}

.message {
  max-width: 88%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  border-color: #b9d8cf;
  background: #eaf6f1;
}

.message.assistant {
  align-self: flex-start;
}

.message.pending {
  color: var(--muted);
}

.citation-list {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.citation {
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fafbf9;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}

.suggestions::-webkit-scrollbar {
  display: none;
}

.suggestions button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.composer {
  position: sticky;
  bottom: calc(70px + var(--safe-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

textarea {
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 9px 8px;
  color: var(--text);
  background: transparent;
  line-height: 1.5;
}

.send-button {
  width: 44px;
  min-height: 44px;
  padding: 11px;
  border-radius: 7px;
  color: #fff;
  background: var(--primary);
}

.send-button:disabled,
.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  min-height: 108px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat span,
.points-panel span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong,
.points-panel strong {
  display: inline-block;
  margin-top: 8px;
  color: var(--primary-dark);
  font-size: 34px;
  line-height: 1;
}

.stat small,
.points-panel small {
  margin-left: 5px;
  color: var(--muted);
}

.checkin-form,
.post-form {
  margin-bottom: 24px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.checkin-form label,
.post-form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 14px;
}

.primary-button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font-weight: 700;
}

.primary-button:hover,
.send-button:hover {
  background: var(--primary-dark);
}

.section-block {
  margin-top: 20px;
}

.section-title {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.section-title h2 {
  margin: 0;
  font-size: 16px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.record-list,
.course-list,
.post-list,
.reward-list,
.status-list {
  display: flex;
  flex-direction: column;
}

.record,
.course,
.post,
.reward,
.status-list > div {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.record {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
}

.record time {
  color: var(--muted);
  font-size: 12px;
}

.record p,
.course p,
.post p,
.reward p {
  margin: 0;
  line-height: 1.6;
}

.course {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.course strong,
.reward strong {
  font-size: 14px;
}

.course span,
.reward small {
  color: var(--muted);
  font-size: 12px;
}

.post header,
.reward {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.post header {
  margin-bottom: 6px;
}

.post time {
  color: var(--muted);
  font-size: 12px;
}

.post p {
  color: #35423c;
  font-size: 14px;
}

.text-button {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #b9d8cf;
  border-radius: 7px;
  color: var(--primary-dark);
  background: #edf7f3;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.text-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.points-panel {
  padding: 18px;
  border: 1px solid #e2cfc0;
  border-radius: var(--radius);
  background: #fbf5f0;
}

.points-panel strong {
  color: #8d482b;
}

.points-panel small {
  display: block;
  margin: 8px 0 0;
  line-height: 1.5;
}

.reward button {
  flex: 0 0 auto;
  min-width: 70px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--primary-dark);
  background: var(--surface);
  cursor: pointer;
}

.reward button:disabled {
  color: var(--muted);
  opacity: 0.6;
  cursor: not-allowed;
}

.status-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-list strong {
  color: var(--primary-dark);
  font-size: 13px;
}

.empty {
  padding: 18px 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  min-height: calc(66px + var(--safe-bottom));
  padding: 6px max(12px, calc((100vw - 896px) / 2)) calc(6px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.tab svg {
  width: 22px;
  height: 22px;
}

.tab.is-active {
  color: var(--primary);
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--safe-bottom));
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 10px 13px;
  border-radius: var(--radius);
  color: #fff;
  background: rgba(31, 42, 37, 0.94);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 13px;
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 760px) {
  .app-shell {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  .chat-list {
    min-height: 420px;
  }
}

@media (max-width: 420px) {
  .view {
    padding-left: 13px;
    padding-right: 13px;
  }

  .view-heading h1 {
    font-size: 23px;
  }

  .message {
    max-width: 93%;
  }
}

