:root {
  --bg: #f4f6f1;
  --panel: #ffffff;
  --ink: #20221f;
  --muted: #687066;
  --line: #d8ddd3;
  --soft: #ecf1e9;
  --soft-2: #f8faf6;
  --accent: #176b5d;
  --accent-strong: #0d4f45;
  --warn: #a9472f;
  --shadow: 0 18px 50px rgba(37, 49, 39, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    linear-gradient(135deg, rgba(23, 107, 93, 0.08), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 8px 0 14px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.search-benefits {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
}

.search-benefits li {
  min-height: 56px;
  padding: 9px 11px;
  border: 1px solid rgba(23, 107, 93, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.search-benefits b,
.search-benefits span {
  display: block;
}

.search-benefits b {
  color: var(--accent-strong);
  font-size: 13px;
  line-height: 1.35;
}

.search-benefits span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.product-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  border: 1px solid rgba(23, 107, 93, 0.2);
  font-size: 12px;
  font-weight: 850;
}

.product-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.product-strip div {
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.product-strip b,
.product-strip span {
  display: block;
}

.product-strip b {
  font-size: 13px;
  line-height: 1.35;
}

.product-strip span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.shell {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(680px, 1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.input-panel,
.output-panel {
  min-height: 0;
}

.input-panel {
  position: sticky;
  top: 14px;
  align-self: start;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.input-body,
.output-body {
  padding: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.strategy-note {
  margin: -2px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 107, 93, 0.18);
  border-radius: 8px;
  background: rgba(23, 107, 93, 0.05);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.title-input,
.draft-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-2);
  color: var(--ink);
  outline: none;
}

.title-input {
  min-height: 42px;
  padding: 0 12px;
}

select.title-input {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
    var(--soft-2);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 12px) 18px,
    0 0;
  background-size: 5px 5px, 5px 5px, 100% 100%;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.draft-input {
  min-height: clamp(260px, 34dvh, 380px);
  padding: 13px 14px;
  resize: vertical;
  line-height: 1.72;
  font-size: 15px;
}

.title-input:focus,
.draft-input:focus {
  border-color: rgba(23, 107, 93, 0.68);
  box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.13);
  background: #ffffff;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  color: var(--ink);
  background: var(--soft);
  font-weight: 750;
}

.btn.primary {
  background: var(--accent);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.ghost {
  border-color: var(--line);
  background: #ffffff;
}

.btn.warn {
  background: rgba(169, 71, 47, 0.1);
  color: var(--warn);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

.metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-2);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 62px;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 750;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "index name"
    "index file";
  column-gap: 9px;
  row-gap: 2px;
  text-align: left;
  align-items: center;
}

.tab.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.tab.ready:not(.active) {
  background: #ffffff;
}

.tab-index {
  grid-area: index;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 850;
}

.tab.active .tab-index {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.tab-name {
  grid-area: name;
  min-width: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-file {
  grid-area: file;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 650;
}

.tab.active .tab-file {
  color: rgba(255, 255, 255, 0.78);
}

.output-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  flex-wrap: wrap;
}

.filename {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.output-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  max-width: 70ch;
}

.preview-stack {
  display: grid;
  gap: 10px;
}

.wechat-preview,
.wechat-frame {
  width: 100%;
  min-height: clamp(520px, 66dvh, 820px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.wechat-preview {
  overflow: auto;
  padding: 0;
}

.wechat-preview main {
  max-width: 680px;
}

.text-output {
  width: 100%;
  min-height: clamp(520px, 66dvh, 820px);
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  background: #ffffff;
  color: var(--ink);
  line-height: 1.72;
  outline: none;
}

.text-output:focus {
  border-color: rgba(23, 107, 93, 0.68);
  box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.13);
}

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

.check {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-2);
  padding: 9px 10px;
}

.check b {
  display: block;
  font-size: 12px;
}

.check span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.check.pass {
  border-color: rgba(23, 107, 93, 0.28);
}

.check.review {
  border-color: rgba(169, 71, 47, 0.32);
}

.seo-section {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.seo-copy {
  max-width: 860px;
}

.seo-copy h2,
.faq-list h2 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.4;
}

.seo-copy p,
.seo-grid p,
.faq-list p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.seo-copy p + p {
  margin-top: 10px;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.seo-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-2);
}

.seo-grid h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.faq-list {
  margin-top: 20px;
  max-width: 860px;
}

.faq-list details {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.faq-list summary {
  cursor: pointer;
  font-weight: 800;
}

.faq-list details p {
  margin-top: 8px;
}

.site-cta {
  margin-top: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 750;
}

.site-cta a {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
}

.empty {
  min-height: clamp(260px, 36dvh, 420px);
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(18px);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 8px;
  background: #20221f;
  color: #ffffff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 980px) {
  .app {
    width: min(100% - 18px, 760px);
  }

  .topbar,
  .search-benefits,
  .product-strip,
  .shell {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .input-panel,
  .output-panel {
    position: static;
    min-height: auto;
  }

  .draft-input,
  .text-output,
  .wechat-frame {
    min-height: 420px;
  }

  .quality,
  .metrics,
  .project-grid,
  .seo-grid {
    grid-template-columns: 1fr;
  }

  .site-cta {
    align-items: stretch;
    flex-direction: column;
  }

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