:root {
  --bg: #f7ead8;
  --panel: #fffaf2;
  --ink: #2f2118;
  --muted: #7a604b;
  --line: #e2c9aa;
  --red: #b43a22;
  --red-dark: #8f2b18;
  --teal: #176f61;
  --gold: #c47b1b;
  --wood: #5b351f;
  --shadow: 0 16px 38px rgba(83, 45, 22, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 8%, rgba(255, 244, 207, 0.95), transparent 30%),
    linear-gradient(135deg, #f9eddc 0%, #f3d8b8 52%, #f8efe1 100%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

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

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 4px solid var(--wood);
  padding: 20px 0 18px;
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 0;
  width: 180px;
  height: 5px;
  background: var(--red);
  border-radius: 999px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--wood);
  font-size: 14px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.16;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(180, 58, 34, 0.28);
  background: #fff0d8;
  color: var(--red-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.input-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  position: sticky;
  top: 16px;
  border-top: 6px solid var(--wood);
  padding: 22px;
}

.result-panel {
  border-top: 6px solid var(--red);
  min-height: 640px;
  padding: 22px;
}

.panel-head {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 16px;
}

.panel-head h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

label {
  display: block;
  margin-bottom: 16px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: #503725;
  font-size: 15px;
  font-weight: 700;
}

.field-help {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
  padding: 12px 13px;
  line-height: 1.6;
}

select {
  min-height: 49px;
}

textarea {
  resize: vertical;
  min-height: 136px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(183, 47, 36, 0.12);
}

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

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff7eb;
  padding: 11px 12px;
}

.check-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.check-row span {
  margin: 0;
  color: #503725;
  font-size: 14px;
  line-height: 1.55;
}

.actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.primary-btn,
.secondary-btn,
.copy-btn {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.primary-btn {
  flex: 1;
  background: linear-gradient(180deg, #c94628, var(--red-dark));
  color: #fff;
  padding: 13px 18px;
}

.primary-btn:hover {
  background: var(--red-dark);
}

.secondary-btn,
.copy-btn {
  border: 1px solid var(--line);
  background: #fffaf2;
  color: #503725;
}

.secondary-btn {
  padding: 13px 18px;
}

.copy-btn {
  min-width: 72px;
  padding: 8px 12px;
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-btn:hover,
.copy-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  border: 1px dashed #d5a86b;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.output-section + .output-section {
  margin-top: 28px;
}

.provider-note,
.error-note {
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
}

.provider-note {
  background: #ecf6ed;
  color: var(--teal);
}

.error-note {
  background: #fff4e3;
  color: #8a5a08;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title span {
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
}

.section-title h2 {
  margin-bottom: 0;
  font-size: 24px;
}

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

.result-card,
.rewrite-card,
.extra-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 16px;
}

.result-card h3,
.rewrite-card h3,
.extra-card h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.result-card p,
.rewrite-card p,
.extra-card p {
  margin-bottom: 0;
  color: #4d3a2c;
  font-size: 15px;
  line-height: 1.75;
}

.rewrite-grid {
  display: grid;
  gap: 12px;
}

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

.rewrite-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.rewrite-head h3 {
  margin-bottom: 0;
}

.purpose-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.purpose-strip span {
  border: 1px solid #e7c894;
  border-radius: 6px;
  background: linear-gradient(180deg, #fff6e9, #ffe7bf);
  color: #6a3f17;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
  padding: 9px 6px;
  text-align: center;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .input-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 12px;
  }

  .input-panel,
  .result-panel {
    padding: 16px;
  }

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

  .actions {
    flex-direction: column;
  }

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

  .secondary-btn {
    width: 100%;
  }
}
