:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-soft: #fff8ee;
  --ink: #1f2428;
  --muted: #69727d;
  --line: #ded8cd;
  --brand: #e7332f;
  --brand-dark: #b91f1b;
  --teal: #087f7a;
  --blue: #2f5aac;
  --gold: #a66b00;
  --shadow: 0 18px 50px rgba(31, 36, 40, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(231, 51, 47, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(47, 90, 172, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(231, 51, 47, 0.25);
  outline-offset: 2px;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--brand);
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(231, 51, 47, 0.24);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.workspace {
  padding-top: 26px;
}

.intro {
  display: grid;
  gap: 12px;
  max-width: 780px;
  padding: 14px 0 28px;
}

.eyebrow,
.mini-label {
  margin: 0;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  max-width: 720px;
  margin-bottom: 0;
  font-size: clamp(32px, 7vw, 64px);
  line-height: 1.02;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.lead {
  max-width: 690px;
  margin-bottom: 0;
  color: #4c545c;
  font-size: 18px;
  line-height: 1.75;
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trust-row span {
  border: 1px solid rgba(31, 36, 40, 0.12);
  border-radius: 999px;
  padding: 7px 11px;
  color: #3d454d;
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 650;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(31, 36, 40, 0.11);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.input-panel,
.result-stack {
  min-width: 0;
  max-width: 100%;
}

.input-panel {
  display: grid;
  gap: 20px;
  padding: 22px;
}

.field-block {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}

label,
legend {
  color: #262d33;
  font-size: 15px;
  font-weight: 750;
}

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

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 14px 15px;
  line-height: 1.65;
}

select {
  min-height: 46px;
  padding: 0 12px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #5a626b 50%),
    linear-gradient(135deg, #5a626b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 13px) 19px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.choice-card,
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #38414a;
  background: #fff;
  font-weight: 700;
  min-width: 0;
  user-select: none;
}

.choice-card input,
.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.choice-card:has(input:checked),
.chip:has(input:checked) {
  border-color: rgba(231, 51, 47, 0.55);
  color: var(--brand-dark);
  background: #fff1ef;
}

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  flex: 0 1 auto;
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 780;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.primary-button {
  gap: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 12px 28px rgba(231, 51, 47, 0.24);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-button,
.secondary-button {
  min-width: 112px;
  padding: 0 14px;
  border: 1px solid var(--line);
  color: #394149;
  background: #fff;
}

.icon-button {
  width: 44px;
  color: #3d454d;
  border: 1px solid var(--line);
  background: #fff;
}

.result-stack {
  display: grid;
  gap: 14px;
}

.score-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.score-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.score-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece5d9;
}

.score-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--teal));
  transition: width 0.25s ease;
}

.result-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.result-head,
.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.result-head h2,
.insight-panel h2,
.history-panel h2 {
  margin: 3px 0 0;
  font-size: 18px;
  line-height: 1.3;
}

pre {
  max-height: 460px;
  margin: 0;
  overflow: auto;
  border: 1px solid #e5ded3;
  border-radius: var(--radius);
  padding: 16px;
  color: #23292e;
  background: #fffaf2;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
}

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

.insight-panel,
.history-panel {
  padding: 18px;
}

.insight-panel ul {
  display: grid;
  gap: 9px;
  margin: 12px 0 0;
  padding-left: 20px;
  color: #46505a;
  line-height: 1.6;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.history-item {
  display: grid;
  gap: 4px;
  border: 1px solid #e6dfd4;
  border-radius: var(--radius);
  padding: 10px;
  background: #fffdfa;
}

.history-item button {
  padding: 0;
  color: #263039;
  background: transparent;
  text-align: left;
  font-weight: 700;
  line-height: 1.45;
}

.history-item small,
.empty-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-text {
  margin: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(320px, calc(100vw - 36px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #fff;
  background: #20272d;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 920px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding-bottom: 28px;
  }

  .workspace {
    padding-top: 12px;
  }

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .intro {
    padding-bottom: 20px;
  }

  .lead {
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .brand strong {
    max-width: 210px;
  }

  .brand small {
    max-width: 210px;
  }

  h1 {
    font-size: 34px;
  }

  .input-panel,
  .result-panel,
  .score-panel,
  .insight-panel,
  .history-panel {
    padding: 14px;
  }

  .segmented-grid,
  .two-col {
    grid-template-columns: 1fr 1fr;
  }

  .chip {
    flex: 1 1 calc(50% - 8px);
  }

  .primary-button {
    width: 100%;
  }

  .ghost-button,
  .secondary-button {
    flex: 1 1 136px;
  }
}

@media (max-width: 430px) {
  .shell {
    width: min(100% - 16px, 720px);
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .segmented-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .chip {
    flex-basis: 100%;
  }
}
