:root {
  --bg: #eef6f7;
  --surface: #ffffff;
  --muted: #f6fafb;
  --ink: #17252f;
  --soft: #64717d;
  --line: #d8e3e7;
  --teal: #087d86;
  --teal-soft: #dff5f6;
  --blue: #2f65d9;
  --amber: #a76505;
  --amber-soft: #fff0c7;
  --red: #c83f3a;
  --red-soft: #ffe6e3;
  --green: #24744b;
  --green-soft: #ddf3e6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(8, 125, 134, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(8, 125, 134, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  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;
}

.app {
  width: min(440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: #fbfdfe;
  box-shadow: 0 18px 50px rgba(23, 37, 47, 0.12);
}

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

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

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

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

.brand p,
.eyebrow {
  margin-bottom: 3px;
  color: var(--soft);
  font-size: 12px;
}

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

h2 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.3;
}

main {
  padding: 16px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

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

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

.scenario {
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  font-weight: 800;
}

.scenario span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: var(--muted);
  color: var(--teal);
}

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

.panel,
.safety-note,
.avoid,
.reply-card,
.analysis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
}

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

.heading-row strong,
.risk {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  padding: 6px 10px;
  font-size: 12px;
}

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

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

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: 8px;
  background: var(--muted);
  color: var(--ink);
}

textarea {
  min-height: 138px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

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

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

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

.form-grid label {
  color: var(--soft);
  font-size: 12px;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

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

.primary,
.secondary {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 900;
}

.primary {
  width: 100%;
  border: 0;
  background: var(--teal);
  color: #fff;
}

.primary:disabled,
.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
}

.full {
  width: 100%;
  margin-top: 12px;
}

.safety-note {
  margin-top: 14px;
  background: #f8fbfc;
}

.safety-note p,
.avoid p,
.analysis-card p,
.reply-card p,
blockquote {
  margin-bottom: 0;
  color: var(--soft);
  font-size: 14px;
  line-height: 1.65;
}

blockquote {
  margin: 0 0 12px;
  border-left: 4px solid var(--teal);
  background: var(--surface);
  padding: 12px;
}

.cards,
.reply-list {
  display: grid;
  gap: 10px;
}

.analysis-card.risk-card {
  border-color: rgba(200, 63, 58, 0.25);
  background: #fff9f8;
}

.analysis-card.strategy-card {
  border-color: rgba(8, 125, 134, 0.25);
  background: #f7ffff;
}

.analysis-card h3,
.reply-card h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

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

.reply-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--muted);
  padding: 8px 10px;
  font-weight: 800;
}

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

.avoid {
  margin-top: 12px;
  border-color: rgba(167, 101, 5, 0.25);
  background: #fffdf6;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: calc(100vw - 36px);
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 11px 13px;
  font-size: 14px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

@media (max-width: 380px) {
  main {
    padding: 13px;
  }

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