:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-muted: #f7f9fb;
  --ink: #1d2733;
  --ink-soft: #667085;
  --line: #d9e0e7;
  --teal: #0f766e;
  --teal-soft: #d9f2ef;
  --coral: #d94f45;
  --coral-soft: #ffe6e2;
  --gold: #a76f04;
  --gold-soft: #fff0bf;
  --violet: #6750d9;
  --violet-soft: #ece8ff;
  --green: #237a4b;
  --green-soft: #dff3e7;
  --shadow: 0 18px 50px rgba(31, 45, 61, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    sans-serif;
  letter-spacing: 0;
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.stage {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(260px, 360px);
  gap: 32px;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 28px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: min(880px, calc(100vh - 56px));
  min-height: 680px;
  overflow: hidden;
  border: 1px solid rgba(29, 39, 51, 0.1);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 10px;
  align-items: center;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
}

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

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

.eyebrow,
.mini-label {
  margin: 0 0 3px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.2;
}

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

h1 {
  margin-bottom: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.3;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible,
.text-button:hover,
.text-button:focus-visible,
.secondary-action:hover,
.secondary-action:focus-visible,
.scenario-card:hover,
.scenario-card:focus-visible,
.tab:hover,
.tab:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.16);
  outline-offset: 2px;
}

.hidden {
  visibility: hidden;
}

.screen-stack {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #fbfcfd;
}

.screen {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 18px;
}

.screen.active {
  display: block;
}

.usage-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.usage-strip strong {
  display: block;
  font-size: 14px;
}

.text-button {
  border: 0;
  border-radius: var(--radius);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 700;
  padding: 8px 11px;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 14px 0;
}

.scenario-card {
  display: flex;
  min-height: 82px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.scenario-card span:last-child {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.scenario-card.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.scenario-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: #fff;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.tool-panel,
.profile-panel,
.feedback-panel,
.avoid-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.section-heading,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.status-pill,
.risk-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  background: var(--violet-soft);
  color: var(--violet);
}

.risk-badge {
  background: var(--gold-soft);
  color: var(--gold);
}

.risk-badge.high {
  background: var(--coral-soft);
  color: var(--coral);
}

.risk-badge.low {
  background: var(--green-soft);
  color: var(--green);
}

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

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--ink);
}

textarea {
  min-height: 128px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

textarea:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--teal);
  background: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.form-row label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

select {
  display: block;
  height: 42px;
  margin-top: 6px;
  padding: 0 10px;
}

.quick-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.quick-examples button {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  padding: 7px 10px;
  font-size: 12px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-action {
  width: 100%;
  min-height: 48px;
  border: 0;
  background: var(--teal);
  color: #fff;
  font-size: 16px;
}

.primary-action:disabled {
  cursor: not-allowed;
  background: #aebbc5;
}

.secondary-action {
  flex: 1;
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.insight-band {
  margin-top: 14px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius);
  background: #f3fbfa;
  padding: 14px;
}

.insight-band p {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.signal-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: center;
}

.signal-line {
  position: absolute;
  right: 18%;
  left: 18%;
  height: 2px;
  background: rgba(15, 118, 110, 0.3);
}

.signal-node {
  z-index: 1;
  display: grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 999px;
  background: #fff;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.signal-node.active {
  background: var(--teal);
  color: #fff;
}

.quote-block {
  margin-bottom: 14px;
  border-left: 4px solid var(--teal);
  background: var(--surface);
  padding: 12px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.55;
}

.analysis-grid,
.reply-list,
.list-stack,
.membership-grid {
  display: grid;
  gap: 10px;
}

.analysis-card,
.reply-card,
.saved-item,
.history-item,
.membership-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.analysis-card h3,
.reply-card h3,
.saved-item h3,
.history-item h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--ink);
}

.analysis-card p,
.reply-card p,
.saved-item p,
.history-item p,
.feedback-panel p,
.membership-grid p {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.58;
}

.analysis-card.accent-risk {
  border-color: rgba(217, 79, 69, 0.28);
  background: #fff9f8;
}

.analysis-card.accent-action {
  border-color: rgba(15, 118, 110, 0.25);
  background: #f7fffd;
}

.action-bar {
  display: flex;
  gap: 10px;
  margin: 14px 0 10px;
}

.reply-card {
  position: relative;
}

.reply-card.good {
  border-color: rgba(35, 122, 75, 0.25);
}

.reply-card.boundary {
  border-color: rgba(103, 80, 217, 0.25);
}

.reply-card.polished {
  border-color: rgba(167, 111, 4, 0.25);
}

.reply-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.reply-actions button,
.item-actions button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 700;
}

.avoid-panel {
  margin-top: 12px;
  border-color: rgba(217, 79, 69, 0.28);
  background: #fff9f8;
}

.avoid-panel p {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

.saved-item,
.history-item {
  display: grid;
  gap: 10px;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px 16px;
  color: var(--ink-soft);
  text-align: center;
}

.profile-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.profile-stats span {
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 10px;
  color: var(--ink-soft);
  font-size: 12px;
}

.profile-stats strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.membership-grid {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}

.membership-grid article {
  min-height: 152px;
}

.membership-grid .highlight {
  border-color: rgba(15, 118, 110, 0.28);
  background: #f7fffd;
}

.membership-grid strong {
  display: block;
  margin-top: 12px;
  color: var(--teal);
}

.feedback-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.tab {
  display: grid;
  min-height: 50px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}

.tab span {
  font-size: 19px;
  line-height: 1;
}

.tab.active {
  background: var(--teal-soft);
  color: var(--teal);
}

.desktop-notes {
  max-width: 360px;
  border: 1px solid rgba(29, 39, 51, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  padding: 24px;
  box-shadow: 0 12px 36px rgba(31, 45, 61, 0.08);
}

.desktop-notes h2 {
  margin-bottom: 10px;
  font-size: 28px;
}

.desktop-notes p {
  color: var(--ink-soft);
  line-height: 1.65;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.metric-row strong {
  color: var(--teal);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(320px, calc(100vw - 32px));
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: #1d2733;
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  body {
    background: #fbfcfd;
  }

  .stage {
    display: block;
    min-height: 100vh;
    padding: 0;
  }

  .app-shell {
    width: 100%;
    height: 100vh;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .desktop-notes {
    display: none;
  }
}

@media (max-width: 390px) {
  .topbar {
    grid-template-columns: 36px 1fr 36px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .screen {
    padding: 14px;
  }

  .scenario-grid {
    gap: 7px;
  }

  .scenario-card {
    min-height: 78px;
    padding: 9px;
  }

  .scenario-card span:last-child {
    font-size: 13px;
  }

  .form-row,
  .membership-grid {
    grid-template-columns: 1fr;
  }

  h2 {
    font-size: 18px;
  }
}
