:root {
  --ink: #22201d;
  --muted: #706b64;
  --line: #dedbd5;
  --paper: #f4f1eb;
  --accent: #e94f1f;
  --accent-dark: #c93e13;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, .wechat-page:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.6px; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { display: flex; flex-direction: column; min-height: 100svh; }
.site-header, .hero, .workspace, footer { width: min(1080px, 100% - 64px); margin-inline: auto; }

.site-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 96px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: 20px; font-weight: 700; }
.brand b { display: block; font-size: 20px; line-height: 1.2; letter-spacing: .08em; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; letter-spacing: .12em; }
.header-note { color: var(--muted); font-size: 14px; }

.hero { padding-block: 64px 44px; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.eyebrow::before { width: 22px; height: 2px; background: var(--accent); content: ""; }
.hero h1 { margin: 18px 0 16px; color: var(--ink); font-size: clamp(30px, 4.2vw, 48px); font-weight: 700; line-height: 1.3; letter-spacing: -.035em; text-wrap: balance; }
.hero h1 span { color: var(--accent); }
.hero-copy { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.8; }
.extract-form { margin-top: 36px; }
.extract-form > label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.extract-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 8px; border: 1px solid #d8d4cd; border-radius: 18px; background: #fff; box-shadow: 0 6px 20px rgba(52, 44, 34, .04); transition: border-color .15s, box-shadow .15s; }
.extract-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(233, 79, 31, .1); }
.extract-bar:has(input:focus-visible) { outline: 2px solid var(--accent-dark); outline-offset: 3px; }
.url-field { display: flex; min-width: 0; align-items: center; gap: 14px; padding: 12px 16px; color: var(--muted); }
.url-field input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.5; }
.url-field input::placeholder { color: rgb(129, 123, 115); }
.primary-button, .copy-button { display: inline-flex; align-items: center; justify-content: center; gap: 20px; border: 0; color: #fff; background: var(--accent-dark); font-weight: 600; white-space: nowrap; transition: background .15s; }
.primary-button { min-height: 56px; padding: 14px 26px; border-radius: 9px; font-size: 16px; }
.primary-button:disabled { cursor: progress; opacity: .65; }
.process-note { display: flex; min-height: 24px; align-items: flex-start; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.process-note.is-done { color: rgb(97, 115, 99); }
.process-note.is-error { color: rgb(182, 70, 42); }
.process-icon { display: inline-grid; width: 18px; height: 18px; flex-shrink: 0; place-items: center; margin-top: 2px; border: 1px solid; border-radius: 50%; font-size: 12px; }
.process-icon svg { width: 13px; height: 13px; }

.workspace { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); overflow: hidden; margin-bottom: 64px; border: 1px solid #d9d5ce; border-radius: 18px; background: #fff; }
.workspace[hidden] { display: none; }
.style-panel { min-width: 0; padding: 28px; border-right: 1px solid var(--line); background: #f8f6f2; }
.preview-panel { display: flex; min-width: 0; flex-direction: column; }
.panel-heading, .preview-toolbar, .panel-heading > div, .preview-toolbar > div:first-child { display: flex; align-items: center; }
.panel-heading, .preview-toolbar { justify-content: space-between; gap: 16px; }
.panel-heading > div, .preview-toolbar > div:first-child { gap: 10px; }
.section-index { color: var(--accent-dark); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; }
.panel-heading h2, .preview-toolbar h2 { margin: 0; font-size: 16px; font-weight: 650; }
.template-name { padding: 30px 0 24px; border-bottom: 1px solid var(--line); }
.template-name > span, .template-name p, .empty-tokens { color: var(--muted); font-size: 14px; }
.template-name .source-title { margin: 9px 0 12px; color: var(--ink); font-size: 21px; font-weight: 650; line-height: 1.5; overflow-wrap: anywhere; text-wrap: balance; }
.template-name p, .empty-tokens { margin: 0; line-height: 1.8; }
.token-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.token { display: flex; min-width: 0; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fffdf9; }
.token-label, .list-label { color: var(--muted); font-size: 14px; }
.token-value { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.token-value i { width: 16px; height: 16px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.12); border-radius: 4px; }
.ink-swatch { background: #22201d; }
.accent-swatch { background: #e94f1f; }
.component-list { margin-top: 32px; }
.list-label { margin: 0 0 8px; font-weight: 500; }
.component-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.6; }
.component-row span:last-child { color: var(--muted); }
.preview-toolbar { min-height: 82px; padding: 18px 28px; border-bottom: 1px solid var(--line); }
.copy-button { min-height: 44px; gap: 12px; padding: 10px 16px; border: 1px solid #b8b1a7; border-radius: 8px; background: #fff; color: var(--ink); font-size: 14px; }
.copy-button svg { width: 16px; height: 16px; }
.phone-stage { flex: 1; padding: 32px 24px 24px; background: #eeebe5; }
.phone-frame { width: min(390px, 100%); margin-inline: auto; overflow: hidden; border: 1px solid #d6d2cb; border-radius: 10px; background: #fff; box-shadow: 0 8px 24px rgba(45, 39, 31, .06); }
.wechat-page { height: 560px; padding: 28px 24px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgb(214, 209, 202) transparent; }
.wechat-page * { overflow-wrap: break-word; }
#wechat-content { color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 16px; line-height: 1.8; letter-spacing: normal; }
#wechat-content h2 { margin: 0 0 12px; color: #1f1f1f; font-size: 23px; line-height: 1.45; letter-spacing: -.2px; }
#wechat-content .article-author { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
#wechat-content p { margin: 0 0 18px; }
#wechat-content blockquote { margin: 24px 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: #fdf5f1; color: #514b44; }
.copy-feedback { max-width: 390px; margin: 16px auto 0; color: var(--ink); text-align: center; font-size: 14px; line-height: 1.7; }
.copy-feedback:empty { margin: 0; }
.preview-caption { max-width: 390px; margin: 18px auto 0; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.7; }
footer { display: flex; justify-content: space-between; gap: 16px; margin-top: auto; padding-block: 24px 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.7; }
footer p { margin: 0; }

@media (hover: hover) {
  .primary-button:hover { box-shadow: inset 0 0 0 100px rgba(0,0,0,.06); }
  .copy-button:hover { background: var(--paper); }
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .style-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .token-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .site-header, .hero, .workspace, footer { width: calc(100% - 40px); }
  .site-header { min-height: 80px; gap: 12px; }
  .header-note { font-size: 12px; }
  .brand small { font-size: 10px; }
  .hero { padding-block: 40px 32px; }
  .hero h1 { max-width: 350px; margin-block: 16px; font-size: 32px; line-height: 1.4; }
  .extract-form { margin-top: 28px; }
  .extract-bar { grid-template-columns: 1fr; gap: 4px; }
  .url-field { gap: 8px; padding: 14px 8px; }
  .url-field svg { width: 18px; height: 18px; }
  .primary-button { min-height: 48px; }
  .workspace { margin-bottom: 40px; border-radius: 12px; }
  .style-panel { padding: 22px 18px; }
  .template-name { padding-top: 24px; }
  .token-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .token { padding: 12px; }
  .token-value { font-size: 14px; }
  .preview-toolbar { flex-wrap: wrap; gap: 8px; padding: 16px 18px; }
  .phone-stage { padding: 0 0 20px; }
  .phone-frame { width: 100%; border: 0; border-radius: 0; box-shadow: none; }
  .wechat-page { height: auto; max-height: 70svh; padding: 24px 18px; }
  .copy-feedback, .preview-caption { padding-inline: 18px; text-align: left; }
  footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media (forced-colors: active) {
  .url-field input:focus-visible { outline: 2px solid highlight; outline-offset: 4px; }
}
