:root {
  --bg: #f3f0e8;
  --ink: #1c2430;
  --muted: #5c6675;
  --line: #d4cfc3;
  --panel: #fffdf8;
  --accent: #0f6e56;
  --accent-soft: #d8efe6;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #0f6e56;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.08);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, #e7f3ee 0%, transparent 42%),
    radial-gradient(circle at 88% 8%, #f7e8d4 0%, transparent 36%),
    var(--bg);
}

.top {
  padding: 28px 24px 8px;
  max-width: 1400px;
  margin: 0 auto;
}

.top h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  letter-spacing: 0.02em;
}

.top p {
  margin: 0;
  color: var(--muted);
  max-width: 52rem;
  line-height: 1.5;
}

.ai-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.ai-nav-item {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}

.ai-nav-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ai-nav-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(320px, 1fr) minmax(280px, 380px);
  gap: 16px;
  padding: 16px 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.layout-hub {
  grid-template-columns: minmax(280px, 360px) minmax(360px, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.hint {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 1.5px dashed #aeb7c2;
  border-radius: 12px;
  background: #faf8f3;
  cursor: pointer;
  padding: 12px;
  text-align: center;
  color: var(--muted);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.dropzone input {
  display: none;
}

.preview-wrap {
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.preview-wrap img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: #f7f7f7;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  font-size: 0.9rem;
}

.field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.status {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f1ea;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.status.busy {
  background: #eef6ff;
  color: #1d4f91;
}

.status.ok {
  background: var(--accent-soft);
  color: var(--ok);
}

.status.err {
  background: #fdecea;
  color: var(--danger);
}

.summary {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.92rem;
}

.summary .rate {
  grid-column: 1 / -1;
  font-size: 1.2rem;
  font-weight: 650;
  color: var(--accent);
}

.canvas-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  background:
    linear-gradient(45deg, #eee 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #eee 25%, transparent 25%) 0 8px / 16px 16px,
    #fafafa;
  min-height: 360px;
  max-height: calc(100vh - 160px);
}

#result-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  pointer-events: none;
}

.question-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 160px);
  overflow: auto;
}

.q-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.q-title {
  font-weight: 650;
}

.badge {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eceff3;
  color: var(--muted);
}

.badge.ok {
  background: var(--accent-soft);
  color: var(--ok);
}

.badge.warn {
  background: #fff4e5;
  color: var(--warn);
}

.q-stem {
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.8em;
  overflow: hidden;
}

.q-analysis {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.field select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.hub-hint {
  margin-top: 12px;
}

.result-md {
  min-height: 360px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  line-height: 1.65;
  font-size: 0.95rem;
}

.result-md h2,
.result-md h3,
.result-md h4 {
  margin: 1em 0 0.4em;
}

.result-md p {
  margin: 0.55em 0;
}

.result-md ul {
  margin: 0.4em 0 0.8em;
  padding-left: 1.25em;
}

@media (max-width: 1100px) {
  .layout,
  .layout-hub {
    grid-template-columns: 1fr;
  }

  .canvas-wrap,
  .question-list,
  .result-md {
    max-height: none;
  }
}
