:root {
  --paper: #f4f1e8;
  --paper-deep: #e9e3d5;
  --surface: #fffdf7;
  --ink: #192321;
  --ink-soft: #52605c;
  --line: #cfc8b8;
  --red: #bd3c2e;
  --red-soft: #f4ddd6;
  --green: #1e6757;
  --green-soft: #dcebe3;
  --yellow: #e2b447;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.65; -webkit-tap-highlight-color: rgba(30, 103, 87, .16); }
a { color: inherit; text-decoration: none; }
button, textarea, [contenteditable] { font: inherit; }
button, a { touch-action: manipulation; }
button { color: inherit; background: none; border: 0; cursor: pointer; }
.shell { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }
.skip-link { position: fixed; z-index: 20; left: 12px; top: 12px; padding: 9px 14px; background: var(--ink); color: white; opacity: 0; pointer-events: none; transform: translateY(-180%); }
.skip-link:focus-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ── Header ─────────────────────────────── */
.site-header { border-bottom: 1px solid var(--line); background: rgba(244, 241, 232, .94); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.header-inner { min-height: 60px; display: flex; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 900; font-size: 19px; white-space: nowrap; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; background: var(--red); color: white; font-size: 15px; transform: rotate(-3deg); }

/* ── Workspace heading ──────────────────── */
.workspace { padding-block: 36px 20px; }
.workspace-heading { margin-bottom: 22px; }
.kicker { margin: 0 0 10px; color: var(--red); font-size: 12px; line-height: 1.4; font-weight: 700; letter-spacing: .12em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-family: var(--serif); font-size: clamp(32px, 5vw, 52px); line-height: 1.15; letter-spacing: 0; text-wrap: balance; }
.headline-accent { color: var(--red); }
.intro { margin: 6px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.9; text-wrap: pretty; max-width: 600px; }

/* ── Editor grid — two panes, equal weight ── */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 460px;
  border: 1px solid var(--ink);
  background: var(--surface);
  box-shadow: 8px 8px 0 var(--paper-deep);
}
.editor-pane, .output-pane { min-width: 0; display: flex; flex-direction: column; }
.editor-pane { border-right: 1px solid var(--ink); }

.pane-bar {
  min-height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.pane-bar > div { min-width: 0; display: flex; align-items: center; gap: 10px; }
.pane-bar h2 { margin: 0; font-family: var(--serif); font-size: 16px; }
.step { color: var(--red); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Clear button */
.icon-button {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color .15s, background .15s;
}
.icon-button:hover { border-color: var(--ink); background: var(--paper); }
.icon-button svg { width: 15px; height: 15px; }

/* Textarea */
#input-text {
  display: block; flex: 1; width: 100%;
  min-height: 310px;
  resize: vertical;
  border: 0; padding: 22px;
  background: transparent; color: var(--ink);
  font-family: var(--serif); font-size: 17px; line-height: 1.95; outline: 0;
}
#input-text::placeholder { color: #938c7e; }
.editor-pane:focus-within { box-shadow: inset 4px 0 0 var(--red); }

/* Footer bar */
.editor-footer {
  min-height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px 10px 22px;
  border-top: 1px solid var(--line);
}
.count { color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
.primary-button {
  min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 24px;
  border: 1px solid var(--ink); background: var(--ink); color: white;
  padding: 9px 16px; cursor: pointer; font-weight: 700; border-radius: 3px;
  transition: background .15s;
}
.primary-button:hover { background: var(--green); border-color: var(--green); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }

/* ── Output pane ────────────────────────── */
.output-pane { background: #f8f5ec; }
.output-tools { display: flex; gap: 6px; align-items: center; }

.empty-state { flex: 1; display: grid; place-items: center; padding: 40px; }
.empty-hint { color: var(--ink-soft); font-size: 14px; font-style: italic; }

.result-content { flex: 1; display: flex; flex-direction: column; min-height: 310px; }
.result-text {
  flex: 1; padding: 22px;
  font-family: var(--serif); font-size: 17px; line-height: 1.95;
  outline: none;
  white-space: pre-wrap;
}
.result-text:focus { background: rgba(30, 103, 87, .04); }

.status-line { padding: 8px 18px; font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line); min-height: 32px; }
.status-line.error { color: var(--red); }
.status-line.success { color: var(--green); }

/* ── Ad containers ──────────────────────── */
.ad-container {
  margin: 20px auto;
  max-width: 728px;
  border: 1px dashed var(--line);
  background: var(--paper-deep);
  min-height: 90px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
}
.ad-container[data-active="false"] { display: none; }
.ad-label { font-size: 11px; color: var(--ink-soft); letter-spacing: .06em; font-weight: 600; }
.ad-slot { width: 100%; min-height: 60px; display: grid; place-items: center; color: var(--ink-soft); font-size: 13px; }

/* ── Footer ─────────────────────────────── */
.site-footer { background: var(--paper-deep); border-top: 1px solid var(--line); }
.footer-inner { min-height: 120px; display: flex; align-items: center; justify-content: center; }
.footer-inner strong { font-family: var(--serif); font-size: 18px; }
.footer-inner p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }

/* ── Focus & accessibility ──────────────── */
button:focus-visible, a:focus-visible, textarea:focus-visible, [contenteditable]:focus-visible {
  outline: 3px solid var(--yellow); outline-offset: 3px;
}
[hidden] { display: none !important; }

/* ── Responsive ─────────────────────────── */
@media (max-width: 800px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-pane { border-right: 0; border-bottom: 1px solid var(--ink); }
  .workspace { padding-block: 28px 16px; }
  h1 { font-size: 30px; }
  #input-text { min-height: 240px; }
}

@media (max-width: 600px) {
  .shell { width: min(calc(100% - 24px), 1180px); }
  .header-inner { min-height: 54px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 28px; height: 28px; font-size: 14px; }
  .workspace-heading { margin-bottom: 16px; }
  .editor-grid { min-height: 0; box-shadow: 5px 5px 0 var(--paper-deep); }
  .pane-bar { min-height: 50px; padding-inline: 14px; }
  .pane-bar h2 { font-size: 15px; }
  #input-text { min-height: 220px; padding: 18px 16px; font-size: 16px; }
  .result-text { padding: 18px 16px; font-size: 16px; }
  .editor-footer { flex-direction: column; align-items: stretch; padding: 12px 14px; gap: 8px; }
  .count { align-self: flex-end; }
  .primary-button { width: 100%; justify-content: center; }
  .ad-container { margin-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
