:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #657068;
  --line: #d8ddd6;
  --paper: #f7f3ea;
  --panel: #fffdf8;
  --jade: #1d7050;
  --gold: #b3832e;
  --red: #d73935;
  --blue: #2563d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(29, 112, 80, 0.1), transparent 38%),
    radial-gradient(circle at 85% 18%, rgba(179, 131, 46, 0.18), transparent 28%),
    var(--paper);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 64px;
}

.compact {
  padding-top: 36px;
}

/* ─── Navigation ─── */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 243, 234, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  height: 52px;
}

.nav-brand {
  font-size: 20px;
  font-weight: 800;
  color: var(--jade);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  gap: 6px;
  flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  background: rgba(29, 112, 80, 0.08);
}

.nav-right {
  margin-left: auto;
}

/* ─── Hero ─── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 36px;
  align-items: end;
  min-height: 420px;
  border-bottom: 1px solid var(--line);
}

.fortune-hero {
  min-height: 0;
  align-items: start;
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

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

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

h1 {
  max-width: 760px;
  margin-bottom: 18px;
  font-size: clamp(42px, 7vw, 78px);
  line-height: 1.02;
  font-weight: 800;
}

.page-title {
  margin-bottom: 0;
  font-size: 42px;
}

.subtitle {
  max-width: 620px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.8;
}

.panel,
.reading-card,
.group-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 18px 45px rgba(23, 32, 27, 0.08);
}

.panel {
  padding: 24px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
button {
  min-height: 46px;
  border-radius: 6px;
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #fff;
}

textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--jade);
  box-shadow: 0 0 0 2px rgba(29, 112, 80, 0.12);
}

button {
  border: 0;
  padding: 0 18px;
  color: #fff;
  background: var(--jade);
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.btn-outline {
  background: transparent;
  color: var(--jade);
  border: 1px solid var(--jade);
  min-height: 36px;
  padding: 0 16px;
  font-size: 14px;
}

.btn-outline:hover {
  background: rgba(29, 112, 80, 0.06);
}

.btn-wechat {
  background: #07c160 !important;
  color: #fff !important;
  font-weight: 700;
  border: 0;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-wechat:hover {
  opacity: 0.88;
}

.text-link {
  color: var(--jade);
  font-weight: 700;
  text-decoration: none;
}

.hint,
.disclaimer {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.login-hint a {
  color: var(--jade);
  font-weight: 700;
}

.result {
  padding-top: 34px;
}

.hidden {
  display: none !important;
}

.reading-card {
  padding: 24px;
}

.reading-card h2 {
  margin-bottom: 14px;
  font-size: 26px;
}

.reading-card p {
  color: var(--muted);
  line-height: 1.8;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.meta-grid div {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.meta-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.number-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 30px 0 14px;
}

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

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

.visitor-panel {
  margin-top: 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: rgba(29, 112, 80, 0.06);
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.event-badge {
  display: inline-flex;
  min-width: 44px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--jade);
  background: rgba(29, 112, 80, 0.1);
  font-weight: 700;
}

.referer {
  max-width: 280px;
  word-break: break-all;
  color: var(--muted);
}

.group-card {
  padding: 18px;
}

.group-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.group-title h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.group-title span {
  max-width: 260px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.ball {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.16);
}

.red {
  background: var(--red);
}

.blue {
  background: var(--blue);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(23, 32, 27, 0.92);
  z-index: 999;
}

/* ─── Auth Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 32, 27, 0.5);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(420px, calc(100% - 32px));
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(23, 32, 27, 0.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 0;
}

.auth-tabs {
  display: flex;
  gap: 4px;
}

.auth-tab {
  padding: 8px 20px;
  min-height: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--jade);
  background: #fff;
  border-color: var(--line);
  border-bottom-color: #fff;
}

.modal-close {
  width: 32px;
  height: 32px;
  min-height: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}

.auth-form {
  padding: 20px 24px 28px;
}

.auth-error {
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

/* ─── Fortune ─── */
.fortune-panel textarea {
  margin-bottom: 0;
}

.fortune-meta {
  display: flex;
  gap: 18px;
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.fortune-meta strong {
  color: var(--ink);
}

.fortune-text {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

/* ─── Loading ─── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 0;
  color: var(--muted);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--jade);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── History ─── */
.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.history-question {
  font-weight: 700;
  font-size: 15px;
}

.history-date {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.history-answer {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ─── Today Stats ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-box {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--jade);
}

.today-stats {
  margin-bottom: 20px;
}

/* ════════════════════════════════════════
   响应式适配 — 手机/平板/桌面
   断点: 820px(平板) / 600px(手机) / 400px(小屏机)
   ════════════════════════════════════════ */

/* ─── 平板及以下 (<=820px) ─── */
@media (max-width: 820px) {
  .shell {
    width: min(100% - 24px, 680px);
    padding-top: 28px;
  }

  .hero,
  .groups,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .fortune-hero {
    grid-template-columns: 1fr;
  }

  .nav-links {
    gap: 2px;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 13px;
  }

  .nav-brand {
    font-size: 17px;
  }

  h1 {
    font-size: 42px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .number-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .number-head button {
    width: 100%;
  }

  .group-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .group-title span {
    max-width: none;
    text-align: left;
  }

  .fortune-meta {
    flex-direction: column;
    gap: 6px;
  }

  .fortune-hero {
    min-height: 0;
  }

  .history-meta {
    flex-direction: column;
    gap: 4px;
  }

  .modal-card {
    width: calc(100% - 24px);
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ─── 手机 (<=600px) ─── */
@media (max-width: 600px) {
  body {
    background: var(--paper);
  }

  .shell {
    width: 100%;
    padding: 20px 16px 40px;
  }

  .compact {
    padding-top: 16px;
  }

  /* 导航栏 — 自动换行防止溢出 */
  .nav-inner {
    width: 100%;
    padding: 0 16px;
    gap: 8px;
    flex-wrap: wrap;
    height: auto;
    min-height: 48px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .nav-brand {
    font-size: 16px;
    margin-right: 4px;
  }

  .nav-links {
    gap: 2px;
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }

  .nav-link {
    padding: 5px 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .nav-right {
    margin-left: auto;
  }

  h1 {
    font-size: 32px;
    line-height: 1.1;
  }

  .page-title {
    font-size: 28px;
  }

  .eyebrow {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .subtitle {
    font-size: 15px;
    line-height: 1.7;
  }

  /* 表单输入 */
  .panel {
    padding: 16px;
  }

  input,
  button {
    min-height: 48px;
    font-size: 16px; /* 防止iOS自动缩放 */
  }

  button {
    width: 100%;
  }

  label {
    margin-bottom: 6px;
    font-size: 14px;
  }

  .hint {
    font-size: 12px;
    margin-top: 10px;
  }

  /* 号码卡片 */
  .reading-card {
    padding: 16px;
  }

  .reading-card h2 {
    font-size: 20px;
    margin-bottom: 10px;
  }

  .reading-card p {
    font-size: 14px;
  }

  /* 四象格 (上卦/下卦/动爻/五行) */
  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .meta-grid div {
    min-height: 64px;
    padding: 10px;
  }

  .meta-grid span {
    font-size: 11px;
    margin-bottom: 4px;
  }

  /* 号码球 */
  .groups {
    gap: 10px;
  }

  .group-card {
    padding: 12px;
  }

  .group-title h3 {
    font-size: 15px;
  }

  .group-title span {
    font-size: 12px;
  }

  .balls {
    gap: 6px;
  }

  .ball {
    width: 34px;
    height: 34px;
    font-size: 13px;
    box-shadow: inset 0 -4px 6px rgba(0,0,0,0.12);
  }

  /* 复制按钮已全宽 (见.number-head button) */
  .btn-outline {
    width: 100%;
    min-height: 42px;
    justify-content: center;
  }

  /* 结果区 */
  .result {
    padding-top: 24px;
  }

  .number-head {
    margin: 20px 0 10px;
  }

  .number-head h2 {
    font-size: 18px;
  }

  /* 运势解答 */
  .fortune-text {
    padding: 14px;
    font-size: 14px;
    line-height: 1.8;
  }

  .fortune-panel textarea {
    min-height: 72px;
    font-size: 15px;
  }

  .fortune-meta {
    font-size: 12px;
  }

  /* 占卜历史 */
  .history-item {
    padding: 12px 14px;
  }

  .history-question {
    font-size: 14px;
  }

  .history-answer {
    font-size: 13px;
  }

  /* 今日统计 */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat-box {
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .stat-label {
    margin-bottom: 0;
    font-size: 13px;
  }

  .stat-value {
    font-size: 22px;
  }

  /* Toast */
  .toast {
    bottom: 16px;
    left: 16px;
    right: 16px;
    transform: none;
    text-align: center;
    font-size: 14px;
  }

  /* 微信二维码区域 */
  .wechat-section {
    margin-top: 20px;
    padding: 16px;
  }

  .wechat-inner {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .wechat-qr {
    width: 130px;
    height: 130px;
  }

  .wechat-text strong {
    font-size: 16px;
  }

  .wechat-text p {
    font-size: 13px;
  }

  /* Modal */
  .modal-card {
    width: calc(100% - 16px);
    border-radius: 10px;
  }

  .modal-header {
    padding: 14px 16px 0;
  }

  .auth-form {
    padding: 14px 16px 22px;
  }

  .auth-tab {
    padding: 6px 14px;
    font-size: 13px;
  }

  /* 访客表格 */
  .table-wrap {
    margin: 0 -16px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  th,
  td {
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* ─── 小屏手机 (<=400px) ─── */
@media (max-width: 400px) {
  h1 {
    font-size: 26px;
  }

  .ball {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .balls {
    gap: 4px;
  }

  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .meta-grid div {
    min-height: 56px;
    padding: 8px;
  }

  .nav-links {
    gap: 0;
  }

  .nav-link {
    padding: 4px 6px;
    font-size: 11px;
  }

  .wechat-qr {
    width: 110px;
    height: 110px;
  }
}

/* ─── WeChat QR Section ─── */
.wechat-section {
  margin-top: 28px;
  padding: 20px;
  border: 2px solid #07c160;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0faf4, #e8f5ee);
}

.wechat-inner {
  display: flex;
  align-items: center;
  gap: 20px;
}

.wechat-qr {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 2px solid #07c160;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wechat-qr img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wechat-text {
  flex: 1;
  min-width: 0;
}

.wechat-text strong {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
  color: #1a1a1a;
}

.wechat-text p {
  margin: 0 0 8px;
  color: #555;
  font-size: 14px;
  line-height: 1.6;
}

.wechat-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #07c160;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}


