:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #2a2622;
  --muted: #8a8175;
  --line: #e3dacb;
  --accent: #d2491f;
  --accent-ink: #fff;
  --ann: #1f6fb2;
  --ann-bg: #e6f0fa;
  --ann-hover: #cfe2f5;
  --ai: #7a3fc4;
  --ai-bg: #f1e8fb;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 6px 24px rgba(60,40,20,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --paper: #24211d;
    --ink: #ece6dc;
    --muted: #9b9184;
    --line: #3a352e;
    --accent: #f06a3c;
    --ann: #7cb8ee;
    --ann-bg: #1e3346;
    --ann-hover: #28445d;
    --ai: #c39cf2;
    --ai-bg: #34254a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

header { max-width: 1100px; margin: 0 auto; padding: 40px 16px 12px; }
h1 { margin: 0; font-size: clamp(32px, 6vw, 52px); letter-spacing: .02em; line-height: 1.2; }
.sub { margin: 8px 0 0; color: var(--muted); }

.ann {
  color: var(--ann);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .82em;
  font-weight: 500;
}
h1 .ann { font-size: .55em; vertical-align: .25em; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 820px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px; font-weight: 600;
}
.panel-head small { font-weight: 400; color: var(--muted); margin-left: 6px; }

textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  line-height: 1.8;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  margin-top: 12px;
}
.slider { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.slider input { accent-color: var(--accent); width: 140px; }
#densityLabel { min-width: 5.5em; }
.buttons { display: flex; gap: 8px; }

button {
  font: inherit; font-size: 15px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 18px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
#ai { color: var(--ai); border-color: color-mix(in srgb, var(--ai) 40%, transparent); }
button.link {
  border: none; background: none; padding: 0;
  color: var(--accent); font-size: 14px; font-weight: 500;
}

.settings {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: 14px;
}
.settings summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.settings summary small { margin-left: 6px; color: var(--ai); }
.fields { display: grid; gap: 10px; margin-top: 10px; }
.field { display: grid; grid-template-columns: 5.5em 1fr; align-items: center; gap: 8px; }
.field span { color: var(--muted); }
.field input, .field select {
  width: 100%;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.model-row { display: flex; gap: 6px; min-width: 0; }
.model-row select { flex: 1; }
button.icon { padding: 0 10px; border-radius: 8px; font-size: 16px; line-height: 1; }
button.icon.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.check input { accent-color: var(--accent); }
.hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
[hidden] { display: none !important; }

.output {
  flex: 1;
  min-height: 300px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
}
.placeholder { color: var(--muted); }
.output .chip {
  color: var(--ann);
  background: var(--ann-bg);
  border-radius: 6px;
  padding: 1px 2px;
  cursor: pointer;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .86em;
  transition: background .15s;
}
.output .chip:hover { background: var(--ann-hover); }
.output .chip.ai { color: var(--ai); background: var(--ai-bg); }
.output .chip.pop { animation: pop .25s ease; }
@keyframes pop { 50% { transform: scale(1.12); display: inline-block; } }

.status { margin: 8px 0 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }

footer {
  max-width: 1100px; margin: 0 auto; padding: 8px 16px 32px;
  font-size: 12px; color: var(--muted);
}
