:root {
  --bg: #f7f3e8;
  --panel: rgba(255, 255, 255, 0.86);
  --ink: #202324;
  --sub: #5e6668;
  --line: #d8d8ce;
  --primary: #106a64;
  --primary-strong: #0d5450;
  --accent: #c65b20;
  --good: #1f7a3f;
  --warn: #995500;
  --bad: #9f2f2f;
  --shadow: 0 12px 28px rgba(28, 34, 39, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 15%, #efe6d1 0%, #f7f3e8 45%, #f3ecdf 100%);
}

code {
  font-family: "Space Grotesk", monospace;
  background: #ece8dc;
  border-radius: 4px;
  padding: 0.06rem 0.3rem;
}

.bg-orb {
  position: fixed;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  filter: blur(60px);
  z-index: -1;
  opacity: 0.52;
}

.orb-1 {
  top: -120px;
  left: -110px;
  background: #f5be86;
}

.orb-2 {
  bottom: -140px;
  right: -90px;
  background: #8ec9bb;
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.desktop-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.left-stack,
.right-stack {
  display: grid;
  gap: 1rem;
  height: 100%;
}

.left-stack {
  grid-template-rows: auto 1fr;
}

.right-stack {
  grid-template-rows: 1fr;
}

.result-panel,
.workspace {
  height: 100%;
}

.hero {
  text-align: center;
  padding: 0.2rem 0.4rem;
}

.eyebrow {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #607066;
}

.hero h1 {
  margin: 0.4rem 0 0.3rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.55rem, 3.7vw, 2.2rem);
  line-height: 1.08;
}

.subtitle {
  margin: 0;
  color: var(--sub);
  font-size: 0.95rem;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  padding: 1rem;
}

.controls {
  display: grid;
  gap: 0.8rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  font-size: 0.9rem;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  font: inherit;
  padding: 0.64rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

textarea:focus,
input:focus {
  outline: 2px solid rgba(16, 106, 100, 0.18);
  border-color: #78b7b0;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.56rem;
}

.controls-actions {
  justify-content: flex-end;
}

.judge-actions {
  justify-content: center;
}

.btn {
  border: 1px solid #cac8ba;
  background: #f6f4ed;
  color: var(--ink);
  padding: 0.56rem 0.84rem;
  border-radius: 999px;
  font: 600 0.9rem "Space Grotesk", "Noto Sans SC", sans-serif;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: #efede4;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

.workspace {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 0.95rem;
}

.quick-tip {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #7c7a6b;
  font-size: 0.74rem;
  line-height: 1.2;
  text-align: right;
  justify-self: end;
}

.answer-toggle {
  border: 0;
  background: transparent;
}

.answer-toggle summary {
  list-style: none;
  cursor: pointer;
  font: 400 0.9rem "Noto Sans SC", sans-serif;
  padding: 0.28rem 0;
  color: #3f4c4a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.answer-toggle summary::after {
  content: "展开";
  font: 400 0.78rem "Noto Sans SC", sans-serif;
  color: #6f7265;
}

.answer-toggle[open] summary::after {
  content: "收起";
}

.answer-toggle summary::-webkit-details-marker {
  display: none;
}

.answer-config {
  border-top: 0;
  padding: 0.42rem 0 0.3rem;
  display: grid;
  gap: 0.7rem;
}

.lane-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.lane {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.count-pill {
  min-width: 1.56rem;
  height: 1.56rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 0.72rem "Space Grotesk", sans-serif;
  background: #e8ece8;
  color: #31403a;
}

.count-pill.accent {
  background: #f7dfd0;
  color: #7a3a17;
}

.lane-foot {
  margin-top: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.42rem;
}

.lane-clear {
  padding: 0.22rem 0.56rem;
  font-size: 0.74rem;
  line-height: 1.15;
  border-radius: 999px;
}

.token-list {
  height: 180px;
  list-style: none;
  margin: 0;
  padding: 0.42rem;
  border: 1px dashed #cfcebe;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  align-content: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
}

.token-list.compose {
  background: linear-gradient(180deg, rgba(198, 91, 32, 0.04), rgba(198, 91, 32, 0));
}

.token-chip {
  user-select: none;
  cursor: grab;
  background: #fff;
  border: 1px solid #c9cfcb;
  border-bottom-width: 2px;
  border-radius: 12px;
  padding: 0.38rem 0.64rem;
  font: 600 0.9rem "Space Grotesk", "Noto Sans SC", sans-serif;
  color: #263532;
  transition: transform 0.12s ease;
}

.token-chip:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.sortable-ghost {
  opacity: 0.38;
}

.sortable-chosen {
  box-shadow: 0 4px 10px rgba(28, 34, 39, 0.2);
}

.preview-wrap {
  border-radius: 12px;
  border: 1px solid #e1ddcf;
  background: #fffdf8;
  padding: 0.78rem;
}

.preview-label {
  margin: 0;
  font-size: 0.82rem;
  color: #6e6f62;
}

.preview-text {
  margin: 0.32rem 0 0;
  min-height: 1.75rem;
  font: 700 1.04rem/1.5 "Space Grotesk", "Noto Sans SC", sans-serif;
}

.progress-text {
  margin: 0.3rem 0 0;
  color: #6e6f62;
  font-size: 0.82rem;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.result-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.result-pill {
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font: 700 0.76rem "Space Grotesk", sans-serif;
}

.result-pill.neutral {
  background: #eef0e8;
  color: #5e6659;
}

.result-pill.good {
  background: #deefdf;
  color: var(--good);
}

.result-pill.warn {
  background: #f8ecd8;
  color: var(--warn);
}

.result-pill.bad {
  background: #f6dfdf;
  color: var(--bad);
}

.score {
  margin: 0.55rem 0 0;
  font: 700 1rem "Space Grotesk", sans-serif;
}

.result-line {
  margin: 0.48rem 0 0;
  font-size: 0.93rem;
}

.result-line.muted {
  color: #5f686a;
}

.result-line.suggestion {
  color: #0d5650;
}

.history-toggle {
  margin-top: 0.8rem;
  border-top: 1px solid #e7e3d5;
  padding-top: 0.48rem;
}

.history-toggle summary {
  list-style: none;
  cursor: pointer;
  font: 400 0.86rem "Noto Sans SC", sans-serif;
  color: #4c5754;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.history-toggle summary::-webkit-details-marker {
  display: none;
}

.history-list {
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
  max-height: 210px;
  overflow-y: auto;
  display: grid;
  gap: 0.45rem;
}

.history-item {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item-btn {
  width: 100%;
  border: 1px solid #e2ddcc;
  border-radius: 10px;
  padding: 0.45rem 0.52rem;
  background: #fffdf8;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-align: left;
  color: inherit;
  font: inherit;
}

.history-item-btn:hover {
  border-color: #c9c2ab;
  background: #fffaf0;
}

.history-item-btn:focus-visible {
  outline: 2px solid rgba(16, 106, 100, 0.32);
  outline-offset: 1px;
}

.history-meta {
  font-size: 0.72rem;
  color: #66706d;
}

.history-main {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: #2b3332;
  line-height: 1.35;
  word-break: break-word;
}

.history-sub {
  margin-top: 0.14rem;
  font-size: 0.76rem;
  color: #596462;
  line-height: 1.3;
  word-break: break-word;
}

.history-empty {
  font-size: 0.78rem;
  color: #7c837f;
}

@media (max-width: 800px) {
  .desktop-grid {
    grid-template-columns: 1fr;
  }

  .lane-grid {
    grid-template-columns: 1fr;
  }

  .token-list {
    height: 180px;
  }
}
