:root {
  --bg: #f8f9f7;
  --bg-strong: #eef2ed;
  --ink: #242927;
  --ink-soft: #69736f;
  --muted: #8f9792;
  --surface: #ffffff;
  --surface-strong: #f5f7f3;
  --line: #e1e7df;
  --line-strong: #c7d2c8;
  --green: #173b2f;
  --green-2: #235245;
  --red: #e85c55;
  --red-deep: #b82928;
  --cyan: #65dedc;
  --gold: #c8a95f;
  --white: #ffffff;
  --shadow: 0 18px 44px rgba(30, 43, 37, 0.12);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(101, 222, 220, 0.16), transparent 18rem),
    radial-gradient(circle at 100% 18%, rgba(232, 92, 85, 0.12), transparent 20rem),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(185, 151, 79, 0.45);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100vw, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  border-left: 1px solid rgba(225, 231, 223, 0.86);
  border-right: 1px solid rgba(225, 231, 223, 0.86);
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

.invite-screen {
  display: flex;
  flex-direction: column;
  padding: 14px 14px calc(22px + var(--safe-bottom));
  gap: 12px;
}

.invite-screen.referral-mode .brand-hero {
  display: none;
}

.referral-flyer {
  overflow: hidden;
  border: 1px solid rgba(225, 231, 223, 0.98);
  border-radius: 14px;
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.flyer-visual {
  position: relative;
  height: clamp(250px, 58vh, 430px);
  min-height: 250px;
  margin: 0;
  overflow: hidden;
  background: #f8f4ea;
}

.flyer-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 46%;
}

.flyer-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(15, 45, 35, 0.04) 0%, rgba(15, 45, 35, 0) 45%, rgba(15, 45, 35, 0.68) 100%);
  pointer-events: none;
}

.flyer-visual figcaption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
  color: #fff8df;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
}

.flyer-copy {
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(200, 169, 95, 0.12), transparent 42%),
    #fffdf8;
}

.flyer-copy h1 {
  margin: 0;
  color: #26342d;
  font-size: clamp(27px, 8vw, 38px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: 0;
}

.flyer-lead {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.7;
}

.flyer-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}

.flyer-benefits span {
  padding: 7px 10px;
  border: 1px solid rgba(200, 169, 95, 0.4);
  border-radius: 999px;
  background: rgba(255, 248, 226, 0.88);
  color: #765d29;
  font-size: 12px;
  font-weight: 800;
}

.flyer-cta {
  margin-top: 16px;
}

.flyer-note {
  margin: 10px 0 0;
  color: var(--red-deep);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.brand-hero {
  display: grid;
  grid-template-rows: auto minmax(178px, 26vh);
  gap: 12px;
}

.brand-copy {
  padding: 8px 2px 0;
}

.private-pill {
  width: fit-content;
  margin: 0 0 9px;
  padding: 5px 9px;
  border: 1px solid rgba(232, 92, 85, 0.28);
  border-radius: 999px;
  background: rgba(232, 92, 85, 0.08);
  color: var(--red-deep);
  font-size: 12px;
  font-weight: 800;
}

.brand-copy h1 {
  margin: 0;
  color: #3d4541;
  font-size: clamp(27px, 8vw, 36px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-copy p:not(.private-pill) {
  margin: 8px 0 0;
  color: #b9d8e6;
  font-size: 15px;
  line-height: 1.65;
}

.portrait-card {
  position: relative;
  min-height: 178px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfaf5;
  box-shadow: var(--shadow);
}

.portrait-card img {
  width: 100%;
  height: 100%;
  min-height: 178px;
  display: block;
  object-fit: cover;
  object-position: 50% 35%;
}

.portrait-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 36%;
  background: linear-gradient(0deg, rgba(248, 249, 247, 0.92), rgba(248, 249, 247, 0));
  pointer-events: none;
}

.symbol-board {
  min-height: 310px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 253, 247, 0.88), rgba(255, 253, 247, 0.88)),
    repeating-linear-gradient(35deg, rgba(185, 151, 79, 0.09) 0 1px, transparent 1px 18px);
  box-shadow: var(--shadow);
}

.paper-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 52%, rgba(31, 51, 41, 0.06) 52% 52.4%, transparent 52.4%),
    linear-gradient(0deg, transparent 0 62%, rgba(31, 51, 41, 0.05) 62% 62.5%, transparent 62.5%);
}

.vertical-title {
  position: absolute;
  left: 14px;
  top: 20px;
  writing-mode: vertical-rl;
  color: rgba(169, 52, 42, 0.48);
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 4px;
}

.ink-mark {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%) rotate(-7deg);
  color: rgba(31, 51, 41, 0.92);
  font-size: clamp(60px, 18vw, 94px);
  font-weight: 900;
  font-family: "STKaiti", "KaiTi", "PingFang SC", serif;
  text-shadow: 0 12px 0 rgba(31, 51, 41, 0.08);
  white-space: nowrap;
}

.ink-shadow {
  position: absolute;
  left: 20%;
  right: 10%;
  bottom: 54px;
  height: 18px;
  border-radius: 999px;
  background: rgba(31, 51, 41, 0.12);
  filter: blur(10px);
}

.red-seal {
  position: absolute;
  right: 30px;
  bottom: 42px;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(169, 52, 42, 0.86);
  color: var(--red);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
  font-weight: 700;
  transform: rotate(8deg);
  background: rgba(255, 250, 240, 0.72);
}

.cloud {
  position: absolute;
  bottom: 26px;
  height: 30px;
  border-top: 3px solid rgba(185, 151, 79, 0.75);
  border-radius: 50%;
}

.cloud-left {
  left: -18px;
  width: 160px;
}

.cloud-right {
  right: -26px;
  width: 150px;
}

.entry-card {
  padding: 16px;
  border: 1px solid rgba(225, 231, 223, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(30, 43, 37, 0.08);
}

.eyebrow,
.war-kicker {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
}

.entry-card h1,
.entry-card h2,
.history-head h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.entry-card h2 {
  font-size: 24px;
  font-weight: 700;
}

.lead,
.helper,
.history-head p {
  color: var(--ink-soft);
  line-height: 1.7;
}

.lead {
  margin: 10px 0 18px;
  font-size: 15px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f3f6f2;
}

.auth-tab {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.active {
  background: #26312c;
  color: var(--white);
}

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

.auth-form .primary-button {
  margin-top: 8px;
}

.field,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

.field {
  min-height: 48px;
  padding: 0 14px;
}

.primary-button,
.send-button,
.tool-button {
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-button {
  width: 100%;
  margin-top: 12px;
  background: linear-gradient(135deg, #20392f, #142b23);
  color: var(--white);
  box-shadow: 0 12px 24px rgba(31, 51, 41, 0.18);
}

.primary-button:active,
.send-button:active,
.tool-button:active {
  transform: translateY(1px);
}

.primary-button.ghost {
  background: var(--surface);
  color: var(--green);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.error-text {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

.helper {
  margin: 6px 0 0;
  font-size: 12px;
}

.referral-hint {
  margin: -4px 0 14px;
  padding: 9px 10px;
  border: 1px solid rgba(200, 169, 95, 0.46);
  border-radius: var(--radius);
  background: rgba(255, 248, 226, 0.8);
  color: #84662b;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.chat-screen {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: #f4f6f2;
}

.war-room {
  position: relative;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
  background:
    linear-gradient(135deg, rgba(232, 92, 85, 0.08), transparent 44%),
    #143529;
  color: var(--white);
  border-bottom: 2px solid rgba(200, 169, 95, 0.9);
}

.war-title-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 10px;
  padding-right: 58px;
}

.war-title-row img {
  width: 46px;
  height: 46px;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 20%;
  background: #f8f4ea;
}

.war-room h1 {
  margin: 0;
  max-width: 100%;
  font-size: 22px;
  letter-spacing: 0;
}

.war-room p {
  margin: 7px 0 0;
  color: rgba(255, 253, 247, 0.78);
  font-size: 13px;
  line-height: 1.5;
}

.war-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.credit-badge {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 6px 9px;
  border: 1px solid rgba(232, 212, 166, 0.5);
  border-radius: var(--radius);
  color: #f7e8bd;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  background: rgba(255, 253, 247, 0.08);
}

.credit-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.recharge-button,
.share-button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.recharge-button {
  border: 1px solid rgba(101, 222, 220, 0.55);
  background: rgba(101, 222, 220, 0.12);
  color: #bff8f5;
}

.share-button {
  border: 1px solid rgba(247, 232, 189, 0.58);
  background: rgba(247, 232, 189, 0.16);
  color: #ffe8a8;
}

.logout-button {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 14px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid rgba(255, 253, 247, 0.3);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.08);
  color: rgba(255, 253, 247, 0.86);
  font-size: 12px;
  font-weight: 800;
}

.war-room .war-kicker {
  color: #e8d4a6;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px 18px;
  scroll-behavior: smooth;
}

.empty-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(54, 44, 24, 0.08);
}

.empty-panel .stamp {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border: 2px solid var(--red);
  color: var(--red);
  font-family: "STKaiti", "KaiTi", serif;
  font-weight: 800;
  transform: rotate(-5deg);
}

.empty-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.empty-panel p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.message-row {
  display: flex;
  margin: 0 0 12px;
}

.message-row.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(82%, 390px);
  padding: 12px 13px;
  border-radius: var(--radius);
  line-height: 1.68;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(30, 43, 37, 0.06);
}

.message-row.assistant .bubble::before {
  content: "教员";
  display: inline-block;
  margin: 0 8px 7px 0;
  padding: 1px 6px;
  border: 1px solid rgba(169, 52, 42, 0.45);
  color: var(--red);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.6;
}

.message-row.user .bubble {
  background: #e2f3ee;
  border: 1px solid #c4e5dc;
  color: #1f3027;
}

.bubble.loading {
  color: var(--muted);
}

.tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 10px 8px;
  background: rgba(248, 249, 247, 0.96);
  border-top: 1px solid var(--line);
}

.tools:has(.admin-tool:not([hidden])) {
  grid-template-columns: repeat(2, 1fr);
}

.tool-button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

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

.composer {
  display: grid;
  grid-template-columns: 1fr 62px;
  gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: #ffffff;
  border-top: 1px solid var(--line);
}

.composer textarea {
  min-height: 44px;
  max-height: 132px;
  resize: none;
  padding: 11px 12px;
  line-height: 1.45;
}

.send-button {
  background: var(--red);
  color: var(--white);
}

.send-button:disabled {
  background: #d8cfc1;
  color: #948774;
}

.history-screen {
  padding: calc(22px + env(safe-area-inset-top, 0px)) 14px calc(20px + var(--safe-bottom));
  background: var(--bg);
}

.admin-screen {
  padding: calc(22px + env(safe-area-inset-top, 0px)) 14px calc(20px + var(--safe-bottom));
  background: var(--bg);
}

.admin-head {
  border-radius: 14px;
}

.admin-user-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-user-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(30, 43, 37, 0.06);
}

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

.admin-user-card strong {
  font-size: 16px;
}

.admin-user-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.credit-form {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
  margin-top: 12px;
}

.credit-input {
  min-height: 44px;
}

.history-head {
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.history-head p {
  margin: 8px 0 0;
}

.history-list {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
}

.history-item {
  width: 100%;
  min-height: 58px;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.history-title {
  display: block;
  font-weight: 800;
}

.history-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  z-index: 10;
  width: min(90vw, 430px);
  transform: translateX(-50%);
  padding: 11px 14px;
  border: 1px solid rgba(169, 52, 42, 0.35);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--red);
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px 16px;
  background: rgba(11, 19, 16, 0.28);
}

.recharge-panel {
  position: relative;
  width: min(100%, 420px);
  min-height: 390px;
  padding: 38px 34px 34px;
  border: 1px solid rgba(225, 231, 223, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 70px rgba(30, 43, 37, 0.2);
}

.share-panel {
  position: relative;
  width: min(100%, 420px);
  padding: 34px 24px 24px;
  border: 1px solid rgba(225, 231, 223, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 250, 235, 0.84), rgba(255, 255, 255, 0.98) 42%),
    #ffffff;
  box-shadow: 0 22px 70px rgba(30, 43, 37, 0.2);
}

.modal-close {
  position: absolute;
  top: 24px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  color: #cbd8e8;
  font-size: 34px;
  font-weight: 200;
  line-height: 1;
}

.modal-kicker {
  margin: 0 0 12px;
  color: transparent;
  font-size: 1px;
}

.recharge-panel h1 {
  margin: 0;
  color: #424947;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0;
}

.modal-lead {
  margin: 26px 0 0;
  color: #d9e9f6;
  font-size: 16px;
  line-height: 1.7;
}

.share-panel .modal-kicker {
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
}

.share-panel h1 {
  margin: 0;
  color: #2f3934;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
}

.share-lead {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 15px;
}

.share-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 18px 0 16px;
}

.share-stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 246, 242, 0.78);
}

.share-stats strong,
.share-stats span {
  display: block;
}

.share-stats strong {
  color: var(--green);
  font-size: 24px;
  line-height: 1;
}

.share-stats span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.invite-link-row {
  display: grid;
  grid-template-columns: 1fr 74px;
  gap: 8px;
}

.invite-link-row .field {
  min-width: 0;
  color: #31443b;
  font-size: 13px;
}

.share-primary {
  margin-top: 14px;
}

.share-helper {
  margin-top: 10px;
  color: var(--muted);
}

.wechat-card {
  margin-top: 52px;
}

.wechat-label {
  display: block;
  margin: 0 0 34px 22px;
  color: #748aa1;
  font-size: 18px;
  font-weight: 400;
}

.wechat-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  align-items: center;
  gap: 10px;
  padding-left: 44px;
}

.wechat-row strong {
  color: #2b3558;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  word-break: break-all;
}

.wechat-row button {
  min-height: 44px;
  background: transparent;
  color: #35e7ee;
  font-size: 17px;
  font-weight: 500;
}

@media (min-width: 760px) {
  body {
    padding: 24px;
  }

  .app-shell {
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(31, 51, 41, 0.18);
  }

  .screen {
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
  }
}

@media (max-width: 340px) {
  .entry-card h1,
  .history-head h1 {
    font-size: 26px;
  }

  .tools {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr 56px;
  }

  .war-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .credit-actions {
    justify-content: flex-start;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
