:root {
  color-scheme: light;
  --bg: #f4f7f3;
  --surface: #fffefa;
  --surface-soft: #eef4ef;
  --surface-cool: #f4f7fa;
  --ink: #181b18;
  --muted: #626b62;
  --line: #d6ded2;
  --line-strong: #bac7b7;
  --accent: #176c64;
  --accent-strong: #0f514b;
  --accent-soft: #e3f0ec;
  --warning: #8a6220;
  --danger: #a33d35;
  --mono: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --sans: "MiSans", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --radius: 8px;
  --shadow: 0 18px 45px rgba(42, 50, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(255, 254, 250, 0.92), rgba(244, 247, 243, 0) 240px),
    repeating-linear-gradient(90deg, rgba(24, 27, 24, 0.025) 0 1px, transparent 1px 28px),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
}

.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;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 20;
  transform: translateY(-160%);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  padding: 10px 14px;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 14px;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: var(--surface);
  font-size: 15px;
  font-weight: 800;
}

.brand-text {
  min-width: 0;
}

.brand-name,
.brand-sub {
  margin: 0;
}

.brand-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.status-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.78);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready {
  color: var(--accent-strong);
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.generator-form {
  display: grid;
  gap: 12px;
}

.panel-header,
.output-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-kicker {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.section-title {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 850;
  line-height: 1.25;
}

.section-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.52;
}

.mini-title {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.3;
}

.step-error {
  margin: 0;
  border: 1px solid rgba(163, 61, 53, 0.28);
  border-left: 5px solid var(--danger);
  border-radius: var(--radius);
  background: #fff2ef;
  color: #842d27;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.55;
}

.material-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.textarea-wrap {
  position: relative;
  display: block;
}

#material {
  width: 100%;
  min-height: 255px;
  resize: vertical;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fffefa;
  color: var(--ink);
  outline: none;
  padding: 13px 13px 42px;
  font-size: 16px;
  line-height: 1.72;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

#material::placeholder {
  color: #858d82;
}

#material:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(23, 108, 100, 0.16);
}

.char-count {
  position: absolute;
  right: 11px;
  bottom: 10px;
  min-width: 70px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  pointer-events: none;
}

.idea-bank {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-cool);
  padding: 10px;
}

.idea-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.idea-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.idea-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffefa;
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 100ms ease;
}

.idea-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.auto-route-state {
  min-height: 46px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 9px 10px;
}

.auto-route-state strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 780;
  line-height: 1.35;
}

.auto-route-state span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.screen-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  gap: 8px;
  padding-top: 2px;
  background: var(--surface);
}

.primary-button,
.secondary-button,
.ghost-button,
.copy-button,
.plain-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    color 150ms ease,
    transform 100ms ease;
}

.primary-button {
  min-height: 52px;
  width: 100%;
  background: var(--accent);
  color: #fffefa;
  padding: 0 16px;
  font-size: 16px;
  box-shadow: 0 12px 22px rgba(23, 108, 100, 0.18);
}

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

  .primary-button:active,
  .secondary-button:active,
  .ghost-button:active,
  .copy-button:active,
  .plain-button:active,
  .idea-chip:active,
  .style-card:active,
  .type-button:active {
    transform: translateY(1px);
  }

.primary-button[disabled] {
  background: #a8b5ae;
  box-shadow: none;
}

.secondary-button,
.ghost-button,
.copy-button {
  min-height: 34px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
}

.secondary-button:hover,
.ghost-button:hover,
.copy-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.prompt-button {
  justify-self: start;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffefa;
  color: var(--ink);
  outline: none;
  padding: 0 10px;
}

input,
select {
  min-height: 42px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
summary:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(23, 108, 100, 0.16);
}

label,
fieldset {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span,
legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.4;
}

.advanced-options {
  border-top: 1px solid var(--line);
}

.advanced-options summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 820;
  cursor: pointer;
  user-select: none;
}

.advanced-options summary::-webkit-details-marker,
.key-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-options summary::after {
  content: "展开";
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 650;
}

.advanced-options[open] summary::after {
  content: "收起";
}

.advanced-grid {
  display: grid;
  gap: 12px;
  padding: 0 0 4px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.key-settings {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-cool);
  overflow: hidden;
}

.key-settings summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 820;
  cursor: pointer;
}

.settings-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 0 12px 12px;
}

.key-note {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.style-cards,
.type-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.style-card,
.type-button {
  min-width: 0;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffefa;
  color: var(--ink);
  padding: 11px;
  text-align: left;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 100ms ease;
}

.style-card:hover,
.type-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.style-card[aria-pressed="true"],
.type-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(23, 108, 100, 0.14);
}

.style-name,
.type-name {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.35;
}

.style-note,
.type-use {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

.type-selector {
  margin: 0;
  border: 0;
  padding: 0;
}

.type-guide {
  border: 1px solid #e1d8c5;
  border-left: 5px solid var(--warning);
  border-radius: var(--radius);
  background: #fffaf0;
  overflow: hidden;
}

.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e1d8c5;
  padding: 11px 12px;
}

.guide-head span {
  color: var(--warning);
  font-size: 12px;
  font-weight: 850;
}

.guide-head strong {
  color: var(--ink);
  font-size: 15px;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.guide-item {
  min-width: 0;
  padding: 12px;
}

.guide-item + .guide-item {
  border-top: 1px solid #e1d8c5;
}

.guide-item dt {
  margin: 0 0 6px;
  color: var(--warning);
  font-size: 12px;
  font-weight: 850;
}

.guide-item dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.65;
}

.guide-example {
  white-space: pre-wrap;
}

.output-panel {
  min-height: 390px;
}

.output-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 11px;
}

.output-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.result-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

.result-state {
  min-height: 235px;
  display: grid;
  align-content: center;
  gap: 8px;
  margin-top: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fffefa;
  padding: 22px;
  color: var(--muted);
  text-align: left;
}

.result-state.hidden {
  display: none;
}

.state-title {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.5;
}

.result-state p:last-child {
  margin: 0;
  max-width: 36ch;
  font-size: 13px;
  line-height: 1.65;
}

.results {
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.result-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
  padding: 12px;
}

.result-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.result-index {
  display: block;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.result-title {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.4;
}

.copy-button {
  min-width: 62px;
  min-height: 36px;
  border-color: var(--line-strong);
  color: var(--accent-strong);
  font-weight: 850;
}

.copy-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.result-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.78;
}

@media (min-width: 680px) {
  .app-shell {
    padding: 18px;
  }

  .field-grid,
  .style-cards,
  .type-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-strip {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .settings-strip label:first-child {
    grid-column: 1 / -1;
  }
}

@media (min-width: 960px) {
  .app-shell {
    padding: 18px 22px 24px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
    gap: 14px;
  }

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

  .screen-actions {
    position: static;
  }

  #material {
    min-height: 330px;
  }

  .output-panel {
    min-height: calc(100dvh - 104px);
  }

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

  .guide-item + .guide-item {
    border-top: 0;
    border-left: 1px solid #e1d8c5;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-sub {
    display: none;
  }

  .status-pill {
    min-height: 30px;
    padding: 0 8px;
    font-size: 11px;
  }

  .input-panel,
  .output-panel {
    padding: 12px;
  }

  .panel-header,
  .output-head {
    gap: 8px;
  }

  .section-title {
    font-size: 17px;
  }

  .secondary-button,
  .ghost-button {
    padding: 0 8px;
  }

  #material {
    min-height: 238px;
    font-size: 15px;
  }
}

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