:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --surface-strong: #eef1f4;
  --text: #171a1f;
  --subtext: #667085;
  --muted: #8b95a1;
  --line: #e2e5e9;
  --line-strong: #d3d8df;
  --green: #13b15f;
  --green-dark: #0b8f4b;
  --ink: #243142;
  --amber: #b7791f;
  --red: #b42318;
  --shadow: 0 12px 34px rgba(23, 26, 31, 0.07);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #fbfcfd 0%, var(--bg) 230px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(251, 252, 253, 0.9);
  border-bottom: 1px solid rgba(226, 229, 233, 0.82);
  backdrop-filter: blur(20px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: 0;
}

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

.status-badge {
  flex: 0 0 auto;
  min-width: 82px;
  border: 1px solid #cfe8dc;
  border-radius: 999px;
  background: #f0faf5;
  color: #087743;
  padding: 7px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

main {
  padding: 14px 12px 0;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.compose-card,
.summary-card,
.chat-panel,
.result-panel > article,
.list-card,
.summary-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(23, 26, 31, 0.02);
}

.compose-card,
.summary-card,
.chat-panel {
  padding: 15px;
}

.compose-primary {
  box-shadow: var(--shadow);
}

.compose-head,
.chat-title,
.section-title,
.list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

label {
  display: block;
  margin-bottom: 7px;
  color: #24272d;
  font-size: 14px;
  font-weight: 800;
}

.compose-head p,
.chat-title p {
  margin: 0;
  color: var(--subtext);
  font-size: 12px;
  line-height: 1.45;
}

.mode-chip,
#questionCounter {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--subtext);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

textarea,
.text-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: #fbfcfd;
  color: var(--text);
  padding: 12px;
  font-size: 15px;
  line-height: 1.5;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea:focus,
.text-input:focus {
  border-color: #8fd8b3;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(19, 177, 95, 0.11);
}

#logInput {
  min-height: 172px;
  margin-top: 12px;
  resize: vertical;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  margin-top: 12px;
}

.primary-button,
.plain-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 800;
}

.primary-button {
  background: #111827;
  color: #fff;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.16);
}

.primary-button:active {
  background: #263241;
}

.plain-button {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: #303640;
}

button:disabled {
  opacity: 0.45;
}

.hint {
  margin: 9px 0 0;
  color: var(--subtext);
  font-size: 12px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.chat-panel,
.result-panel,
.summary-card {
  margin-top: 12px;
}

.chat-panel {
  background: #f7f8fa;
}

.chat-list {
  display: grid;
  gap: 12px;
  padding: 15px 0;
}

.message {
  display: flex;
  gap: 9px;
}

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

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #1f2937;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.bubble {
  max-width: min(84%, 580px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  line-height: 1.5;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(23, 26, 31, 0.04);
}

.message.user .bubble {
  border-color: #b7eacb;
  background: #dff8e9;
}

.bubble p {
  margin: 0;
}

.bubble .zh {
  margin-top: 5px;
  color: #53606f;
}

.answer-box {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

#answerInput {
  min-height: 74px;
  resize: vertical;
}

.risk-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.risk-card h2 {
  margin: 0;
  font-size: 38px;
  font-weight: 900;
}

.risk-card[data-risk="L1"],
.risk-card[data-risk="L2"] {
  background: #0f6b45;
}

.risk-card[data-risk="L3"] {
  background: var(--amber);
}

.risk-card[data-risk="L4"],
.risk-card[data-risk="L5"] {
  background: var(--red);
}

.risk-card .eyebrow {
  color: rgba(255, 255, 255, 0.76);
}

.risk-meta {
  display: grid;
  gap: 7px;
  text-align: right;
  font-size: 12px;
}

.risk-meta span {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  padding: 6px 9px;
}

.summary-card h2 {
  font-size: 16px;
}

.section-block,
.offer,
.metric-row,
.list-card {
  border-top: 1px solid var(--line);
  padding-top: 11px;
  margin-top: 11px;
}

.section-block:first-child,
.offer:first-child {
  border-top: 0;
  padding-top: 0;
}

.section-block h3 {
  margin: 0 0 6px;
  color: #24272d;
  font-size: 14px;
}

.section-block p,
.offer p,
.summary-card p {
  margin: 4px 0;
  color: #303640;
  font-size: 14px;
  line-height: 1.55;
}

.section-block .zh,
.offer .zh {
  color: var(--subtext);
}

.offer-head,
.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.offer-name,
.metric-label {
  flex: 1;
  font-weight: 800;
}

.offer-cost,
.metric-value {
  color: var(--green-dark);
  font-weight: 900;
}

.list-header {
  align-items: center;
  margin-bottom: 10px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-card {
  width: 100%;
  text-align: left;
  padding: 13px;
}

.list-card h3 {
  margin: 0;
  font-size: 15px;
}

.list-card p {
  margin: 6px 0 0;
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.45;
}

.summary-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.summary-tile {
  padding: 14px;
  box-shadow: none;
}

.summary-tile strong {
  display: block;
  color: #1f2937;
  font-size: 28px;
}

.summary-tile span {
  color: var(--subtext);
  font-size: 12px;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(820px, 100%);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(226, 229, 233, 0.9);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
}

.bottom-tab {
  display: grid;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #7b818a;
  padding: 5px 0;
}

.bottom-tab span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface-strong);
  font-size: 12px;
  font-weight: 900;
}

.bottom-tab b {
  font-size: 11px;
}

.bottom-tab.active {
  color: var(--green-dark);
}

.bottom-tab.active span {
  background: #e3f6eb;
  color: var(--green-dark);
}

.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(244, 245, 247, 0.96);
  backdrop-filter: blur(20px);
}

.lock-card {
  width: min(370px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 22px;
  text-align: center;
  box-shadow: 0 22px 58px rgba(23, 26, 31, 0.14);
}

.lock-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-weight: 950;
}

.lock-card p {
  color: var(--subtext);
  font-size: 14px;
  line-height: 1.55;
}

.lock-card .primary-button {
  width: 100%;
  margin-top: 10px;
}

.lock-card .text-input {
  margin-top: 9px;
}

@media (min-width: 640px) {
  main {
    padding-inline: 18px;
  }
}

@media (max-width: 420px) {
  .answer-box {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-template-columns: 1fr 84px;
  }
}
