:root {
  --ink: #172522;
  --muted: #66736f;
  --paper: #f7f8f5;
  --surface: #ffffff;
  --line: #dfe5e1;
  --green: #123f35;
  --green-light: #e8f2ed;
  --coral: #f2644b;
  --coral-dark: #cf4630;
  --yellow: #f3c64f;
  --danger: #b23b2b;
  --shadow: 0 20px 60px rgb(23 37 34 / 10%);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

/* 自定义 display 规则不能覆盖元素的业务隐藏状态。 */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.5;
}

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

button {
  color: inherit;
}

.usage-dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--yellow);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgb(0 0 0 / 28%);
  overflow: auto;
}

.usage-dialog::backdrop {
  background: rgb(18 63 53 / 72%);
  backdrop-filter: blur(3px);
}

.usage-dialog form {
  position: relative;
  padding: 30px;
}

.usage-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}

.usage-dialog-close:hover {
  color: var(--ink);
  background: var(--green-light);
}

.usage-dialog-copy {
  margin: 10px 44px 20px 0;
  color: #46534f;
  font-size: 15px;
  line-height: 1.85;
}

.usage-dialog-note {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--green-light);
  border-left: 3px solid var(--green);
  border-radius: 6px;
}

.usage-dialog-note > span {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--yellow);
  border-radius: 50%;
  font-family: STKaiti, KaiTi, serif;
  font-size: 20px;
  font-weight: 800;
}

.usage-dialog-note p {
  min-width: 0;
  margin: 0;
  color: #40504b;
  font-size: 13px;
  line-height: 1.65;
}

.usage-dialog-note strong {
  display: block;
  color: var(--green);
}

.usage-dialog-confirm {
  width: 100%;
  margin-top: 22px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px max(24px, calc((100vw - 1240px) / 2));
  color: white;
  background: var(--green);
}

.topbar p {
  margin: 0;
  color: rgb(255 255 255 / 68%);
  font-size: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--yellow);
  border-radius: 50%;
  font-family: STKaiti, KaiTi, serif;
  font-size: 21px;
  font-weight: 800;
  transform: rotate(-6deg);
}

main {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: 72px;
}

.intro {
  min-height: 250px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  align-items: end;
  gap: 80px;
  padding: 48px 0 44px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--coral-dark);
  font-size: 13px;
  font-weight: 800;
}

.intro h1 {
  margin: 0;
  font-family: STKaiti, KaiTi, serif;
  font-size: clamp(44px, 5vw, 70px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0;
}

.intro h1 span {
  position: relative;
  color: var(--green);
}

.intro h1 span::after {
  position: absolute;
  right: 0;
  bottom: -8px;
  left: 0;
  height: 8px;
  background: var(--yellow);
  border-radius: 50%;
  content: "";
  transform: rotate(-1deg);
}

.intro-copy {
  margin: 0 0 6px;
  padding-left: 22px;
  color: var(--muted);
  border-left: 3px solid var(--coral);
  font-size: 16px;
  line-height: 1.9;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, 0.92fr);
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-panel,
.result-panel {
  min-width: 0;
  padding: 36px;
}

.result-panel {
  min-height: 720px;
  display: flex;
  flex-direction: column;
  color: white;
  background: var(--green);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 28px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.step {
  flex: 0 0 auto;
  color: var(--coral-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
}

.result-heading p {
  color: rgb(255 255 255 / 58%);
}

.result-heading .step {
  color: var(--yellow);
}

.field-grid {
  display: grid;
  gap: 18px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  min-width: 0;
  display: block;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.field > span,
.field > .field-label,
.field legend {
  display: block;
  margin-bottom: 8px;
  color: #34433f;
  font-size: 14px;
  font-weight: 700;
}

.field em {
  color: var(--coral-dark);
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}

input[type="text"],
select,
textarea {
  width: 100%;
  display: block;
  padding: 12px 14px;
  color: var(--ink);
  background: #fbfcfa;
  border: 1px solid #ccd5d1;
  border-radius: 6px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 76px;
  line-height: 1.65;
  resize: vertical;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  background: white;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgb(18 63 53 / 11%);
}

input.invalid,
select.invalid,
textarea.invalid {
  border-color: var(--danger);
}

::placeholder {
  color: #9aa4a0;
}

select {
  min-height: 46px;
  color: var(--ink);
  cursor: pointer;
}

select:invalid,
select option[value=""] {
  color: #87938f;
}

select option {
  color: var(--ink);
}

.custom-field {
  margin-top: 10px;
}

.error-message {
  min-height: 18px;
  display: block;
  padding-top: 3px;
  color: var(--danger);
  font-size: 12px;
}

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

.role-options label,
.segmented-control label {
  position: relative;
  cursor: pointer;
}

.role-options input,
.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.role-options span {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 8px 4px;
  color: #52615d;
  background: #f5f7f4;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
  transition: 150ms ease;
}

.role-options input:checked + span {
  color: var(--green);
  background: var(--green-light);
  border-color: #9bc1b6;
}

.role-options input:focus-visible + span,
.segmented-control input:focus-visible + span {
  outline: 3px solid rgb(242 100 75 / 35%);
  outline-offset: 2px;
}

.role-hint {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--green);
  font-size: 12px;
}

.settings-row {
  align-items: start;
  margin-top: 4px;
}

.compact-field {
  margin-bottom: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  background: #edf1ee;
  border-radius: 6px;
}

.segmented-control span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #65716d;
  font-size: 13px;
  font-weight: 650;
}

.segmented-control input:checked + span {
  color: var(--green);
  background: white;
  box-shadow: 0 1px 4px rgb(23 37 34 / 12%);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 42px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.primary-button {
  padding: 0 20px;
  color: white;
  background: var(--coral);
  border: 1px solid var(--coral);
}

.primary-button span {
  display: inline-block;
  margin-left: 16px;
  font-size: 19px;
}

.primary-button:hover {
  background: var(--coral-dark);
  border-color: var(--coral-dark);
  transform: translateY(-1px);
}

.secondary-button {
  padding: 0 16px;
  color: var(--green);
  background: white;
  border: 1px solid #b7c3bf;
}

.secondary-button:hover {
  background: #f4f7f5;
  border-color: var(--green);
}

.text-button {
  padding: 0 6px;
  color: inherit;
  background: transparent;
  border: 0;
}

.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.empty-state {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
}

.quote-mark {
  height: 74px;
  color: var(--yellow);
  font-family: Georgia, serif;
  font-size: 100px;
  line-height: 1;
}

.empty-state p {
  margin: 12px 0;
  font-family: STKaiti, KaiTi, serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.5;
}

.empty-state span {
  color: rgb(255 255 255 / 48%);
  font-size: 13px;
}

.result-list {
  display: grid;
  gap: 12px;
}

.result-card {
  position: relative;
  padding: 20px 18px 18px;
  background: rgb(255 255 255 / 8%);
  border: 1px solid rgb(255 255 255 / 15%);
  border-radius: 6px;
}

.result-card:first-child {
  background: white;
  color: var(--ink);
  border-color: white;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result-card h3 {
  margin: 0;
  color: var(--yellow);
  font-size: 13px;
}

.result-card:first-child h3 {
  color: var(--coral-dark);
}

.result-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.85;
}

.copy-button {
  min-width: 58px;
  min-height: 30px;
  padding: 0 10px;
  color: inherit;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.72;
}

.copy-button:hover {
  opacity: 1;
}

.result-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 24px;
}

.result-actions .text-button {
  color: white;
}

.history-section {
  margin-top: 56px;
}

.history-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.history-heading h2 {
  margin: 0;
  font-size: 24px;
}

.danger {
  color: var(--danger);
  font-size: 13px;
}

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

.history-item {
  min-width: 0;
  padding: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.history-item p {
  display: -webkit-box;
  margin: 0 0 14px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.75;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.history-item .copy-button {
  color: var(--green);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 16px;
  color: white;
  background: #172522;
  border-radius: 6px;
  box-shadow: 0 12px 36px rgb(0 0 0 / 20%);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

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

@media (max-width: 940px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 30px;
  }

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

  .result-panel {
    min-height: 580px;
  }

  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .usage-dialog {
    width: min(100% - 24px, 440px);
    max-height: calc(100dvh - 24px);
  }

  .usage-dialog form {
    padding: 24px 20px 20px;
  }

  .topbar {
    padding: 10px 18px;
  }

  .topbar p {
    display: none;
  }

  main {
    width: min(100% - 28px, 1240px);
  }

  .intro {
    min-height: 0;
    padding: 36px 4px 34px;
  }

  .intro h1 {
    font-size: 42px;
  }

  .intro-copy {
    font-size: 14px;
  }

  .form-panel,
  .result-panel {
    padding: 26px 20px;
  }

  .two-columns,
  .history-list {
    grid-template-columns: 1fr;
  }

  .role-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-actions {
    display: grid;
    grid-template-columns: 0.9fr 1.4fr;
  }

  .primary-button,
  .secondary-button {
    padding: 0 10px;
  }

  .primary-button span {
    display: none;
  }

  .result-panel {
    min-height: 540px;
  }

  .result-actions {
    flex-wrap: wrap;
  }
}

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